cpnepo commited on
Commit
42dac5b
1 Parent(s): e9514e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -31,8 +31,8 @@ book1_raw_1 = re.sub(r'Mr. ', 'Mr ', book1_raw_1)
31
  book1_raw_1 = re.sub(r'Ms. ', 'Ms ', book1_raw_1)
32
  book1_raw_1 = re.sub(r'Mrs. ', 'Mrs ', book1_raw_1)
33
 
34
- # Group into 5 sentences-long parts
35
- paragraphs = re.findall("[^.?!]+[.?!][^.?!]+[.?!][^.?!]+[.?!][^.?!]+[.?!][^.?!]+[.?!]", book1_raw_1)
36
 
37
  st.title('Harry Potter and the Extractive Question Answering Model')
38
 
@@ -55,7 +55,7 @@ if st.button('Accio Responsa!'):
55
 
56
  #Sort by decreasing score and get only 3 most similar groups
57
  doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1],
58
- reverse=True)[:3]
59
 
60
  # Join these similar groups to form the context
61
  context = "".join(x[0] for x in doc_score_pairs)
@@ -63,5 +63,5 @@ if st.button('Accio Responsa!'):
63
  # Perform the querying
64
  QA_input = {'question': query, 'context': context}
65
  res = pipe(QA_input)
66
- out = res.get('answer')
67
- st.write(out)
 
31
  book1_raw_1 = re.sub(r'Ms. ', 'Ms ', book1_raw_1)
32
  book1_raw_1 = re.sub(r'Mrs. ', 'Mrs ', book1_raw_1)
33
 
34
+ # Group into 6 sentences-long parts
35
+ paragraphs = re.findall("[^.?!]+[.?!][^.?!]+[.?!][^.?!]+[.?!][^.?!]+[.?!][^.?!]+[.?!][^.?!]+[.?!]", book1_raw_1)
36
 
37
  st.title('Harry Potter and the Extractive Question Answering Model')
38
 
 
55
 
56
  #Sort by decreasing score and get only 3 most similar groups
57
  doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1],
58
+ reverse=True)[:1]
59
 
60
  # Join these similar groups to form the context
61
  context = "".join(x[0] for x in doc_score_pairs)
 
63
  # Perform the querying
64
  QA_input = {'question': query, 'context': context}
65
  res = pipe(QA_input)
66
+ #out = res.get('answer')
67
+ st.write(res)