Samarth991 commited on
Commit
fe84c5e
·
1 Parent(s): c95667e

adding app

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -71,16 +71,17 @@ def summarize_data(docs,llm_model,chain_type='refine'):
71
  output_key="output_text",
72
  )
73
  summary = chain({"input_documents": docs}, return_only_outputs=True)
74
- output_text = summary["output_text"].strip()
75
- regex = r"CONCISE SUMMARY:(.*)"
76
-
77
- matches = re.finditer(regex, output_text, re.DOTALL)
78
- for matchNum, match in enumerate(matches, start=1):
79
- for groupNum in range(0, len(match.groups())):
80
- groupNum = groupNum + 1
81
- lines = match.group(groupNum).strip().split("\n")
 
 
82
 
83
- return " ".join(lines)
84
 
85
 
86
  def process_documents(texts,data_chunk=1000,chunk_overlap=10):
@@ -134,7 +135,7 @@ iface = gr.Interface(
134
  "file"
135
  ],
136
  outputs="text",
137
- description ="Summarize your PDF Document having Image • HuggingFace",
138
  )
139
 
140
  iface.launch()
 
71
  output_key="output_text",
72
  )
73
  summary = chain({"input_documents": docs}, return_only_outputs=True)
74
+ output_text = summary["output_text"].replace('\n','')
75
+
76
+ consice_sumary = re.search("CONCISE SUMMARY:.*\.*$", text).group(0)
77
+ dash_id = consice_sumary.find('-')
78
+ return consice_sumary[:dash_id]
79
+ # matches = re.finditer(regex, output_text, re.DOTALL)
80
+ # for matchNum, match in enumerate(matches, start=1):
81
+ # for groupNum in range(0, len(match.groups())):
82
+ # groupNum = groupNum + 1
83
+ # lines = match.group(groupNum).strip().split("\n")
84
 
 
85
 
86
 
87
  def process_documents(texts,data_chunk=1000,chunk_overlap=10):
 
135
  "file"
136
  ],
137
  outputs="text",
138
+ description ="Summarize your PDF Document having Image • HuggingFace",
139
  )
140
 
141
  iface.launch()