ipvikas commited on
Commit
67e7348
1 Parent(s): e34fa68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -169,20 +169,20 @@ from transformers import MBartForConditionalGeneration, MBart50Tokenizer
169
  #tokenizer = MBart50Tokenizer.from_pretrained(model_name)
170
 
171
  import re, string, unicodedata
172
- # import wikipedia as wk #pip install wikipedia
173
  from collections import defaultdict
174
 
175
- # def wikipedia_data(input_text):
176
- # reg_ex = re.search('from wikipedia (.*)', input_text)#tell me about
177
- # try:
178
- # if reg_ex:
179
- # topic = reg_ex.group(1)
180
- # wiki = wk.summary(topic, sentences = 3)
181
- # return wiki
182
- # else:
183
- # print("My apology, Can you please rephrase your query?")
184
- # except Exception as e:
185
- # print("I do not understand...Please rephrase")
186
 
187
 
188
  def get_response(input_text):
@@ -208,9 +208,9 @@ def get_response(input_text):
208
  if tag == intent["tag"]:
209
  return random.choice(intent['responses'])#responses
210
  else:
211
- #if "From Wikipedia" in sentence:
212
- #if sentence:
213
- robo_response = wikipedia_data(input_text)
214
  return robo_response
215
 
216
 
 
169
  #tokenizer = MBart50Tokenizer.from_pretrained(model_name)
170
 
171
  import re, string, unicodedata
172
+ import wikipedia as wk #pip install wikipedia
173
  from collections import defaultdict
174
 
175
+ def wikipedia_data(input_text):
176
+ reg_ex = re.search('from wikipedia (.*)', input_text)#tell me about
177
+ try:
178
+ if reg_ex:
179
+ topic = reg_ex.group(1)
180
+ wiki = wk.summary(topic, sentences = 3)
181
+ return wiki
182
+ else:
183
+ print("My apology, Can you please rephrase your query?")
184
+ except Exception as e:
185
+ print("I do not understand...Please rephrase")
186
 
187
 
188
  def get_response(input_text):
 
208
  if tag == intent["tag"]:
209
  return random.choice(intent['responses'])#responses
210
  else:
211
+ if "From Wikipedia" in sentence:
212
+ if sentence:
213
+ robo_response = wikipedia_data(input_text)
214
  return robo_response
215
 
216