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

Integration/first #52

Merged
merged 25 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7190a46
Did a simple setup of Angular and Electron
Nevin-Thomas Jun 7, 2024
8571e0d
chore: Update Angular and Electron dependencies
paul-nhlapo Jun 8, 2024
aebaa69
Implemented Inbox Component
Yeshlen Jun 9, 2024
e37f023
Fixed the error on inbox.component.ts file
Nevin-Thomas Jun 9, 2024
0a36d2a
Creating the violations page (still in progress)
Nevin-Thomas Jun 9, 2024
f8caeb5
Add new routes for home, report, and upload document components
paul-nhlapo Jun 9, 2024
49ea47b
Landing page, report page and upload page
paul-nhlapo Jun 9, 2024
f240336
Add new routes for home, report, and upload document components and m…
paul-nhlapo Jun 9, 2024
ea15bf0
some progress on the Violatons page
Nevin-Thomas Jun 10, 2024
a077528
update on Violations page
paul-nhlapo Jun 10, 2024
f10cd3e
update to Violations page
paul-nhlapo Jun 10, 2024
ba83d79
I sorted out the violation folder by using the ng generate command
Nevin-Thomas Jun 10, 2024
762f084
Violation buttons loads different documents according to file type
Nevin-Thomas Jun 10, 2024
68d5085
Adding flowbite
paul-nhlapo Jun 10, 2024
f418fa3
Merge branch 'feature/new-frontend' of https://github.com/COS301-SE-2…
paul-nhlapo Jun 10, 2024
20afaa6
Update dependencies and add Tailwind CSS for styling , Fixed some co…
paul-nhlapo Jun 10, 2024
973862b
This commit adds lazy loading for images in the app component to impr…
paul-nhlapo Jun 10, 2024
3d593fb
General CSS styling changes
Yeshlen Jun 11, 2024
dea9e68
feat: Add lazy loading for images in app component and update routing…
paul-nhlapo Jun 11, 2024
c8c3b5f
Merge branch 'feature/new-frontend' of https://github.com/COS301-SE-2…
Yeshlen Jun 15, 2024
0d2b07b
Added Fast API
Yeshlen Jun 16, 2024
2839943
Frontend with API
Yeshlen Jun 20, 2024
55cc9c9
Backend endpoint integration
u21598012 Jun 20, 2024
79a2dfd
File removal post processing
u21598012 Jun 20, 2024
fabe0ef
Analysis is displayed
Yeshlen Jun 20, 2024
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
bin/
obj/
/__pycache__/

venv/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from lang_detection import location_finder
from regex_layer import regex_layer
from .lang_detection import location_finder
from .regex_layer import regex_layer

class detection_engine:

Expand All @@ -19,7 +19,7 @@ def determine_country_of_origin(self, path):
result += '\n'

else:
result = "Could not determine the country of origin."
result = "Could not determine the country of origin. /n"

return result

Expand All @@ -33,8 +33,11 @@ def process(self, path):
location = self.determine_country_of_origin(path)
reg_result = self.regex_report(text)

print(location)
print("Violation Report: \n")
print(reg_result)
result = location
result += "\n"
result+= "Violation Report: \n"
result += reg_result

return result


Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ def categorize_and_print_report(self,results):
}

report = ""
exclude = ""
for category, keys in categories.items():
report += f"Category: {category}\n"
for key in keys:
if key in results and results[key]:
for instance in results[key]:
report += f" {key}: {instance}\n"
exclude += f" {key}: {instance}\n"
total = sum(len(results[key]) for key in keys)
report += f"Total per category: {total}\n\n"

Expand Down
Binary file not shown.
Binary file modified backend/Document_parser/__pycache__/document_parser.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified backend/Document_parser/__pycache__/validator.cpython-310.pyc
Binary file not shown.
Binary file modified backend/Document_parser/__pycache__/validator.cpython-312.pyc
Binary file not shown.
8 changes: 4 additions & 4 deletions backend/Document_parser/document_parser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# import os
import sys
from validator import validator
from text_extractor import text_extractor
from storage_and_submission import storage_and_submission
from text_preprocessor import text_preprocessor
from .validator import validator
from .text_extractor import text_extractor
from .storage_and_submission import storage_and_submission
from .text_preprocessor import text_preprocessor

class document_parser:
def __init__(self):
Expand Down
22 changes: 0 additions & 22 deletions backend/Document_parser/main.py

This file was deleted.

Binary file added backend/__pycache__/api.cpython-310.pyc
Binary file not shown.
Binary file added backend/__pycache__/api.cpython-312.pyc
Binary file not shown.
Binary file added backend/__pycache__/backend_entry.cpython-310.pyc
Binary file not shown.
Binary file not shown.
38 changes: 38 additions & 0 deletions backend/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import JSONResponse
import os
from fastapi.middleware.cors import CORSMiddleware
from backend_entry import backend_entry
import os

app = FastAPI()
report_analysis = None

endpoint = backend_entry()

app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Adjust this to your needs
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

@app.post("/file-upload")
async def upload_file(file: UploadFile = File(...)):
file_location = f"uploads/{file.filename}"


with open(file_location, "wb") as f:
f.write(await file.read())

result = endpoint.process(file_location)
os.remove(file_location)


return JSONResponse(content = {"filename": file.filename, "result": result})


if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
26 changes: 26 additions & 0 deletions backend/backend_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from Document_parser.document_parser import document_parser
from Detection_Engine.detection_engine import detection_engine
import sys

class backend_entry:

@staticmethod
def process(path):

parser = document_parser()
engine = detection_engine()
# path = input("File Name: ")
file = parser.process(path)
result = engine.process(file)
# print(result)

# print(file)
return result


if __name__ == "__main__":
try:
backend_entry.main()
except SystemExit as e:
print("An error occurred: ", e)
sys.exit(1)
Binary file modified backend/requirements.txt
Binary file not shown.
Binary file added backend/uploads/Tutorial_1_2024.pdf
Binary file not shown.
16 changes: 16 additions & 0 deletions gnd-app/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions gnd-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
4 changes: 4 additions & 0 deletions gnd-app/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}
20 changes: 20 additions & 0 deletions gnd-app/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}
42 changes: 42 additions & 0 deletions gnd-app/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}
27 changes: 27 additions & 0 deletions gnd-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# GndApp

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.0.3.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
Binary file added gnd-app/__pycache__/api.cpython-310.pyc
Binary file not shown.
Loading
Loading