Skip to content

Commit 4ff60f5

Browse files
Merge pull request hack2skill#11 from ANGELOANTU7/dev2
Dev2
2 parents 37befa7 + 4950b02 commit 4ff60f5

File tree

9 files changed

+114
-104
lines changed

9 files changed

+114
-104
lines changed
800 Bytes
Binary file not shown.

Backend/summariser.py

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,40 @@
44
import shutil
55
import os
66
import asyncio
7+
import boto3
8+
from botocore.exceptions import NoCredentialsError
9+
10+
11+
s3_access_key = "AKIAZTHHIOR4CN6UXO6N"
12+
s3_secret_access_key = "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"
13+
s3_bucket_name = "learnmateai"
14+
15+
def save_file_to_s3(filename, content):
16+
try:
17+
# Connect to Amazon S3
18+
s3 = boto3.client(
19+
"s3",
20+
aws_access_key_id=s3_access_key,
21+
aws_secret_access_key=s3_secret_access_key
22+
)
23+
24+
# Set the desired S3 key
25+
s3_key = f"Generated_Files/Summarised_Notes/summarised_{filename}"
26+
27+
# Save the file content to Amazon S3
28+
s3.put_object(Body=content.encode('utf-8'), Bucket=s3_bucket_name, Key=s3_key)
29+
30+
return {"message": "File uploaded successfully"}
31+
except NoCredentialsError:
32+
return {"message": "AWS credentials not found"}
33+
34+
35+
36+
737

838
progress = None # just for tracking progress
939

10-
def summary(text):
40+
def summary(text,filename):
1141
# Load the summarization pipeline
1242
summarizer = pipeline("summarization")
1343
# Split the text into smaller chunks
@@ -44,33 +74,44 @@ def summary(text):
4474
# Print and return the combined summary
4575
print("Combined Summary:")
4676
print(combined_summary)
47-
print("Deleting the saved file.......")
48-
os.remove("dat.txt")
49-
print("deleted....")
50-
return{"summary" : combined_summary,"exceptions" : exceptions}
77+
with open(f'Local_Storage\Generated_Files\Summarised_Notes\summarised_{filename}', 'w', encoding='utf-8') as file:
78+
file.write(combined_summary)
79+
response = save_file_to_s3(filename, combined_summary)
80+
print(response)
81+
5182

5283

53-
async def gen_summary(file):
54-
try:
55-
with open("dat.txt", "wb") as buffer: # saving file
56-
shutil.copyfileobj(file.file, buffer)
57-
finally:
58-
file.file.close()
84+
async def gen_summary():
85+
# reading file
86+
folder_path = 'Local_Storage\\notes_txt'
87+
# Get the list of files in the folder
88+
file_list = os.listdir(folder_path)
89+
90+
# Iterate over each file in the folder
91+
for file_name in file_list:
92+
# Construct the full file path
93+
file_path = os.path.join(folder_path, file_name)
94+
95+
# Check if the path is a file (not a directory)
96+
if os.path.isfile(file_path):
97+
98+
with open(file_path, 'r', encoding='utf-8') as file:
99+
text = file.read()
100+
101+
loop = asyncio.get_running_loop() # making it to run in background
102+
await loop.run_in_executor(None, summary, text,file_name)
59103

60-
with open("dat.txt", "r", encoding='utf-8') as file:
61-
text = file.read() # reading file
62104

63-
loop = asyncio.get_running_loop() # making it to run in background
64-
return await loop.run_in_executor(None, summary, text)
105+
65106

66107

67108
router_summariser = APIRouter()
68109

69110

70111
@router_summariser.post("/get-summary")
71-
async def get_summary(file: UploadFile = File(...)):
72-
data = await gen_summary(file)
73-
return data
112+
async def get_summary():
113+
await gen_summary()
114+
return {"status" : 1}
74115

75116
@router_summariser.get("/summary-gen-progress") # route to track progress of summarization
76117
def get_summary_progress():

Backend/test4.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

Backend/test5.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

Local_Storage/Generated_Files/Summarised_Notes/module1_summarized.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This is to certify that Mr./Ms....ofFree/Euphoria secured... Second...... . place during the National Level Intercollegiate Techno-Cultural Fest, held on 12th of August 2022, organized by the Department of Computer Science, Rajagiri College of Social Sciences (Autonomous), Kalamassery, Kochi, Kerala . The Certificate is awarded to "Angelo Antu, School Of Engine, School of Engine" The certificate was awarded to Mr/Ms. Sanjay Murthy, the Higher Education, the Minister of Education of India .
2+
3+
"HackManthan" is a National level Hackathon for security - 13th to 20th June 2022 . The certificate is proudly presented to Cochin University of Science And Technology's Angelo Antu. Dinha and Dr. Pradeep K, Sinha for participating in Smart India Hackathon, 2022 . Anand Deshpande was selected for selection as a finalist in HackManthan's finalist . Anil D. Sahasrabudhe was awarded a Certificate of Appreciation .
4+
5+
Angelo Antu secured second prize for the hackathon conducted as part of DROID 2.0, hosted by IEEE FISAT SB in December 2021 . The prize was awarded to Angelo Antu, 4-ZERO-4IEEERobotics &.AutomationSociety . Ardra Saji and Professor Bejoy Varghese will receive the award in DotSlash 5.0 conducted at the National Institute of Technology, Surat on 7th-9th Jan, 2022 .
6+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The Indian Income-Tax Return of Income was filed in Form ITR-1 (SAHAJ) and Form II (ITR-4(SUGAM) The return of Income is filed and verified . The return is required to be submitted to the Indian National Revenue Service (N.S.T.L.D.T.) The Return of Tax returns are returned to the tax authorities in accordance with the Indian Income Tax Rules, 1962 . The tax returns are subject to an individual’s annual tax bill, which is refundable only, and the amount of tax paid is refunded only once .
2+
3+
The tax return was submitted electronically on 29-11-2020 11:42:01 from IP address 115.96.113.113 . The return was verified by using the electronic Verification Code 6A9ECLA5JI generated through the use of the OTPITR-4 . Do not send the return to CPC, BENGALURU, Bengaluru, India, or CPC, for verification purposes. The return has been verified by the Indian Revenue Service.
4+

0 commit comments

Comments
 (0)