Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/report gen #186

Merged
merged 9 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions backend/Detection_Engine/biometric_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,50 @@ def biometric_detect_all(self,pdf_path):
if (pdf_path.endswith('.pdf')):
# extract_images_from_pdf(pdf_path)

images = [f'./Detection_Engine/extracted_images/pdf_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/pdf_images') if i.endswith('.png')]
images = [f'./Detection_Engine/extracted_images/pdf_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/pdf_images') if i.endswith('.png') or i.endswith('.jpg')]

output = []
count = 0
for image in images:
count += 1
output.append(self.biometric_detect_people(image))

png_files = glob.glob(os.path.join("./Detection_Engine/extracted_images/pdf_images", '*.png'))
for file in png_files:
os.remove(file)

return output
return count

elif (pdf_path.endswith('.docx')):
# extract_images_from_docx(pdf_path)
images = [f'./Detection_Engine/extracted_images/docx_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/docx_images') if i.endswith('.png')]
images = [f'./Detection_Engine/extracted_images/docx_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/docx_images') if i.endswith('.png') or i.endswith('.jpg')]
output = []
count = 0
for image in images:
count += 1
output.append(self.biometric_detect_people(image))

png_files = glob.glob(os.path.join("./Detection_Engine/extracted_images/docx_images", '*.png'))
for file in png_files:
os.remove(file)

return output
return count

elif (pdf_path.endswith('.xlsx')):
# extract_images_from_excel(pdf_path)
images = [f'./Detection_Engine/extracted_images/xlsx_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/xlsx_images') if i.endswith('.png')]
images = [f'./Detection_Engine/extracted_images/xlsx_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/xlsx_images') if i.endswith('.png') or i.endswith('.jpg')]
# images = [f'extracted_images/xlsx_images/{i}' for i in os.listdir('extracted_images/xlsx_images')]
output = []
count = 0
for image in images:
count += 1
output.append(self.biometric_detect_people(image))

png_files = glob.glob(os.path.join("./Detection_Engine/extracted_images/xlsx_images", '*.png'))
for file in png_files:
os.remove(file)

return output
return count

directories = [
"./Detection_Engine/extracted_images/xlsx_images",
Expand Down
18 changes: 9 additions & 9 deletions backend/Detection_Engine/report_generation_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ def Image_report(self, path):

def Image_report_generation(self, path):
arr_ = self.image_classification_layer.biometric_detect_all(path)
# return arr_
if arr_ is None:
return 0
# # return arr_
# if arr_ is None:
# return 0

count = 0
for detection_list in arr_:
for detection in detection_list:
if detection.get('label') == 'person':
count += 1
# count = 0
# for detection_list in arr_:
# for detection in detection_list:
# if detection.get('label') == 'person':
# count += 1

return count
return arr_

#----------------------------------------------------------REPORT GEN END------------------------------------------------------------------#

Expand Down
1 change: 0 additions & 1 deletion backend/Reports/NCEWD1_report.txt

This file was deleted.

1 change: 0 additions & 1 deletion backend/Reports/NCEX1_report.txt

This file was deleted.

25 changes: 0 additions & 25 deletions backend/Reports/dutch.txt

This file was deleted.

1 change: 0 additions & 1 deletion backend/Reports/twoBirds_report.txt

This file was deleted.

2 changes: 1 addition & 1 deletion backend/backend_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def process(self, path):
engine = detection_engine()
# path = input("File Name: ")
file = parser.process(path)
result = engine.process(file,path)
# result = engine.process(file,path)
result_new = engine.report_generation(file, path)
# print(result)

Expand Down
8 changes: 8 additions & 0 deletions gnd-app/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ export class HomeComponent implements OnInit, OnDestroy {
element: '#home',
intro: 'This button will always navigate you back to the home page'
},
{
element:'#upload-document',
intro:'This button will navigate you to the upload document page. Where you can upload a document.'
},
{
element: '#inbox',
intro: 'This button will navigate you to the inbox page. Where you can see all the attachments in the received inbox.'
},
{
element: '#help',
intro: 'This button will navigate you to the help page. Where you will see how to use the app.'
Expand Down
12 changes: 2 additions & 10 deletions gnd-app/src/app/upload-document/upload-document.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,8 @@ <h2 class="analysis-header">
</div>

<div class="upload-data" *ngIf="result">

<!-- <div class="comp-status">
<span *ngIf="documentStatus == 'Compliant'" class="bg-green-100 text-green-800 text-4xl font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">{{ documentStatus }}</span>
<span *ngIf="documentStatus == 'Non-Compliant'" class="bg-red-100 text-red-800 text-4xl font-medium me-2 px-2.5 py-0.5 rounded dark:bg-red-900 dark:text-red-300">{{ documentStatus }}</span>
</div> -->

<div class="ner-data">
<!-- <strong>NER Count:</strong> {{ nerCount }} -->
<p class="text-lg font-roboto-bold text-gray-900 dark:text-black">This document potentially references {{ nerCount }} different individuals</p>
</div>

Expand Down Expand Up @@ -122,10 +117,7 @@ <h2 class="analysis-header">
</div>

<div class="divider-text"></div>

<!-- <div class="CA-data">
<strong>Consent Agreement:</strong> {{ consentAgreement }}
</div> -->

</div>

<div class="consent-status-container" *ngIf="result">
Expand Down
114 changes: 114 additions & 0 deletions gnd-app/src/app/upload-document/upload-document.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,117 @@
// expect(resultContent.innerHTML).toContain('<b>line1</b><br>line2');
// });
// });
// import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
// import { UploadDocumentComponent } from './upload-document.component';
// import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
// import { DebugElement } from '@angular/core';
// import { By } from '@angular/platform-browser';
// import { NO_ERRORS_SCHEMA } from '@angular/core';
// import { RouterTestingModule } from '@angular/router/testing';
// import { ActivatedRoute } from '@angular/router';
// import { of } from 'rxjs';

// describe('UploadDocumentComponent', () => {
// let component: UploadDocumentComponent;
// let fixture: ComponentFixture<UploadDocumentComponent>;
// let httpMock: HttpTestingController;
// let debugElement: DebugElement;

// beforeEach(async () => {
// await TestBed.configureTestingModule({
// imports: [RouterTestingModule, HttpClientTestingModule, UploadDocumentComponent],
// providers: [
// {
// provide: ActivatedRoute,
// useValue: {
// paramMap: of({
// get: (key: string) => {
// switch (key) {
// case 'fileType': return 'someFileType';
// default: return null;
// }
// }
// })
// }
// }
// ],
// schemas: [NO_ERRORS_SCHEMA]
// })
// .compileComponents();

// fixture = TestBed.createComponent(UploadDocumentComponent);
// component = fixture.componentInstance;
// fixture.detectChanges();
// debugElement = fixture.debugElement;
// httpMock = TestBed.inject(HttpTestingController);
// });

// it('should create', () => {
// expect(component).toBeTruthy();
// });

// afterEach(() => {
// httpMock.verify();
// });

// it('should call onFileSelected and upload file', fakeAsync(() => {
// const file = new File(['file content'], 'test.txt', { type: 'text/plain' });
// const input = fixture.debugElement.query(By.css('input[type="file"]')).nativeElement;

// spyOn(component, 'onFileSelected').and.callThrough();

// input.dispatchEvent(new Event('change'));
// input.files = [file];

// fixture.detectChanges();
// tick();

// expect(component.onFileSelected).toHaveBeenCalled();
// expect(component.fileName).toBe('test.txt');

// const req = httpMock.expectOne('http://127.0.0.1:8000/file-upload-new');
// expect(req.request.method).toBe('POST');
// req.flush({
// fileName: 'test.txt',
// result: 'file processed',
// documentStatus: 'Compliant',
// nerCount: 5,
// location: 'New York',
// personalData: 'Present',
// financialData: 'Present',
// contactData: 'Present',
// medicalData: 'Absent',
// ethnicData: 'Absent',
// biometricData: 'Absent',
// consentAgreement: 'Consent obtained'
// });

// fixture.detectChanges();
// tick();

// expect(component.result).toBe('file processed');
// expect(component.documentStatus).toBe('Compliant');
// }));

// it('should display the analysis result in the analysis window', () => {
// const file = new File(['file content'], 'test.txt', { type: 'text/plain' });
// const input = debugElement.query(By.css('input[type="file"]')).nativeElement;

// const dataTransfer = new DataTransfer();
// dataTransfer.items.add(file);

// input.files = dataTransfer.files;
// input.dispatchEvent(new Event('change', { bubbles: true, cancelable: true }));

// const req = httpMock.expectOne('http://127.0.0.1:8000/file-upload-new');
// req.flush({ fileName: 'test.txt', result: 'line1\nline2' });

// fixture.detectChanges();

// const analysisHeader = debugElement.query(By.css('.analysis-box-header')).nativeElement;
// const resultContent = debugElement.query(By.css('.result-content')).nativeElement;

// expect(analysisHeader.textContent).toContain('Analysis Result:');
// expect(resultContent.innerHTML).toContain('<b>line1</b><br>line2');
// });
// });
Loading