Spaces:
Runtime error
Runtime error
BillBojangeles2000
commited on
Commit
•
d028ca3
1
Parent(s):
c79abf3
Update app.py
Browse files
app.py
CHANGED
@@ -20,26 +20,27 @@ def grammar_sense(sentence):
|
|
20 |
# Web scraping and text cleaning
|
21 |
Quiz_Gen = st.form("Quiz Generation")
|
22 |
res = Quiz_Gen.text_input("What topic do you want to get quizzed on?")
|
23 |
-
Quiz_Gen.form_submit_button("Submit")
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
cleaned_text =
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
43 |
|
44 |
class SubjectiveTest:
|
45 |
|
|
|
20 |
# Web scraping and text cleaning
|
21 |
Quiz_Gen = st.form("Quiz Generation")
|
22 |
res = Quiz_Gen.text_input("What topic do you want to get quizzed on?")
|
23 |
+
sub = Quiz_Gen.form_submit_button("Submit")
|
24 |
+
if sub:
|
25 |
+
entity = res
|
26 |
+
prefix = "https://wiki.kidzsearch.com/wiki/"
|
27 |
+
page = requests.get(f'{prefix}{entity}')
|
28 |
+
res = BeautifulSoup(page.content, 'html.parser')
|
29 |
+
|
30 |
+
text = [i.get_text() for i in res.find_all('p')]
|
31 |
+
|
32 |
+
cleaned_text = ' '.join(text)
|
33 |
+
cleaned_text = re.sub(r'[^a-zA-Z0-9.,]', ' ', cleaned_text)
|
34 |
+
paragraphs = [p.strip() for p in re.split(r'\n', cleaned_text) if p.strip()]
|
35 |
+
|
36 |
+
# Process text using SpaCy
|
37 |
+
nlp = spacy.load("en_core_web_sm")
|
38 |
+
doc = nlp(cleaned_text)
|
39 |
+
|
40 |
+
sentences = [sent.text for sent in doc.sents]
|
41 |
+
|
42 |
+
# Combine sentences into paragraphs
|
43 |
+
paragraphs = [f"{sentences[i]} {sentences[i + 1]}" if i + 1 < len(sentences) else sentences[i] for i in range(0, len(sentences), 2)]
|
44 |
|
45 |
class SubjectiveTest:
|
46 |
|