BillBojangeles2000 commited on
Commit
d028ca3
1 Parent(s): c79abf3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -20
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
- entity = res
25
- prefix = "https://wiki.kidzsearch.com/wiki/"
26
- page = requests.get(f'{prefix}{entity}')
27
- res = BeautifulSoup(page.content, 'html.parser')
28
-
29
- text = [i.get_text() for i in res.find_all('p')]
30
-
31
- cleaned_text = ' '.join(text)
32
- cleaned_text = re.sub(r'[^a-zA-Z0-9.,]', ' ', cleaned_text)
33
- paragraphs = [p.strip() for p in re.split(r'\n', cleaned_text) if p.strip()]
34
-
35
- # Process text using SpaCy
36
- nlp = spacy.load("en_core_web_sm")
37
- doc = nlp(cleaned_text)
38
-
39
- sentences = [sent.text for sent in doc.sents]
40
-
41
- # Combine sentences into paragraphs
42
- paragraphs = [f"{sentences[i]} {sentences[i + 1]}" if i + 1 < len(sentences) else sentences[i] for i in range(0, len(sentences), 2)]
 
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