mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Add Q&A and Book, fix task running bugs (#50)
This commit is contained in:
@ -1,11 +1,9 @@
|
||||
import copy
|
||||
import re
|
||||
from collections import Counter
|
||||
from rag.app import callback__, bullets_category, BULLET_PATTERN, is_english, tokenize
|
||||
from rag.nlp import huqie, stemmer
|
||||
from rag.parser.docx_parser import HuDocxParser
|
||||
from rag.app import tokenize
|
||||
from rag.nlp import huqie
|
||||
from rag.parser.pdf_parser import HuParser
|
||||
from nltk.tokenize import word_tokenize
|
||||
import numpy as np
|
||||
from rag.utils import num_tokens_from_string
|
||||
|
||||
@ -18,20 +16,20 @@ class Pdf(HuParser):
|
||||
zoomin,
|
||||
from_page,
|
||||
to_page)
|
||||
callback__(0.2, "OCR finished.", callback)
|
||||
callback(0.2, "OCR finished.")
|
||||
|
||||
from timeit import default_timer as timer
|
||||
start = timer()
|
||||
self._layouts_paddle(zoomin)
|
||||
callback__(0.47, "Layout analysis finished", callback)
|
||||
callback(0.47, "Layout analysis finished")
|
||||
print("paddle layouts:", timer() - start)
|
||||
self._table_transformer_job(zoomin)
|
||||
callback__(0.68, "Table analysis finished", callback)
|
||||
callback(0.68, "Table analysis finished")
|
||||
self._text_merge()
|
||||
column_width = np.median([b["x1"] - b["x0"] for b in self.boxes])
|
||||
self._concat_downward(concat_between_pages=False)
|
||||
self._filter_forpages()
|
||||
callback__(0.75, "Text merging finished.", callback)
|
||||
callback(0.75, "Text merging finished.")
|
||||
tbls = self._extract_table_figure(True, zoomin, False)
|
||||
|
||||
# clean mess
|
||||
@ -101,7 +99,7 @@ class Pdf(HuParser):
|
||||
break
|
||||
if not abstr: i = 0
|
||||
|
||||
callback__(0.8, "Page {}~{}: Text merging finished".format(from_page, min(to_page, self.total_page)), callback)
|
||||
callback(0.8, "Page {}~{}: Text merging finished".format(from_page, min(to_page, self.total_page)))
|
||||
for b in self.boxes: print(b["text"], b.get("layoutno"))
|
||||
print(tbls)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user