Skip to content

Commit 5f49917

Browse files
committed
test
1 parent ff43b09 commit 5f49917

File tree

6 files changed

+72
-18
lines changed

6 files changed

+72
-18
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Backend/summariser.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@ async def gen_summary(file):
6464
return await loop.run_in_executor(None, summary, text)
6565

6666

67-
# router_summariser = APIRouter()
67+
router_summariser = APIRouter()
6868

6969

70-
# @router_summariser.post("/get-summary")
71-
# async def get_summary(file: UploadFile = File(...)):
72-
# data = await gen_summary(file)
73-
# return data
70+
@router_summariser.post("/get-summary")
71+
async def get_summary(file: UploadFile = File(...)):
72+
data = await gen_summary(file)
73+
return data
7474

75-
# @router_summariser.get("/summary-gen-progress") # route to track progress of summarization
76-
# def get_summary_progress():
77-
# global progress
78-
# if progress is None :
79-
# return {"status" : "No summarisation process in progress" }
80-
# elif progress == 100 :
81-
# return {"status" : "Completed" , "value" : progress}
82-
# elif progress in range(0,101) :
83-
# return {"status" : progress}
84-
# else :
85-
# return {"invalid data detected"}
75+
@router_summariser.get("/summary-gen-progress") # route to track progress of summarization
76+
def get_summary_progress():
77+
global progress
78+
if progress is None :
79+
return {"status" : "No summarisation process in progress" }
80+
elif progress == 100 :
81+
return {"status" : "Completed" , "value" : progress}
82+
elif progress in range(0,101) :
83+
return {"status" : progress}
84+
else :
85+
return {"invalid data detected"}

Backend/test2.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import random
2+
import re
3+
4+
def generate_questions(note):
5+
# Split the note into paragraphs
6+
paragraphs = note.split('\n\n')
7+
8+
# Generate questions from the paragraphs
9+
questions = []
10+
for paragraph in paragraphs:
11+
# Split the paragraph into sentences
12+
sentences = re.split(r'(?<=[.!?])\s+', paragraph.strip())
13+
14+
# Generate questions based on sentence structure
15+
for i in range(len(sentences)):
16+
sentence = sentences[i].strip()
17+
if sentence:
18+
if i == 0:
19+
# Start with a general question about the paragraph
20+
question = "What is the main topic of this paragraph?"
21+
elif i == len(sentences) - 1:
22+
# End with a reflection or summary question
23+
question = "What are the key takeaways from this paragraph?"
24+
else:
25+
# Generate a random question related to the content of the sentence
26+
question = generate_random_question(sentence)
27+
28+
questions.append(question)
29+
30+
# Shuffle the order of the questions
31+
random.shuffle(questions)
32+
33+
return questions
34+
35+
def generate_random_question(sentence):
36+
# Implement your logic to generate a random question based on the content of the sentence
37+
# Here's a simple example that generates a generic question
38+
return "What can you infer from the statement: '" + sentence + "'?"
39+
40+
# Example usage
41+
note = """
42+
Chapter 1: Introduction to Biology
43+
44+
Biology is the study of living organisms. It encompasses various aspects such as the structure, function, growth, origin, evolution, and distribution of organisms.
45+
46+
Cell Theory states that all living organisms are composed of cells, which are the basic structural and functional units of life.
47+
48+
DNA, or deoxyribonucleic acid, carries the genetic information of an organism and is responsible for transmitting hereditary traits.
49+
50+
"""
51+
52+
questions = generate_questions(note)
53+
for question in questions:
54+
print(question)

__pycache__/main.cpython-310.pyc

0 Bytes
Binary file not shown.

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
# Mount the API routers
1313
#app.include_router(api1_router)
14-
#app.include_router(summariser)
15-
app.include_router(generate_question)
14+
app.include_router(summariser)
15+
#app.include_router(generate_question)
1616
#app.include_router(api4_router)
1717

1818
# include other API routers as needed

0 commit comments

Comments
 (0)