Procházet zdrojové kódy

fix #917 #915 (#946)

### What problem does this PR solve?

#917 
#915

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.7.0
KevinHuSh před 1 rokem
rodič
revize
7eee193956
Žádný účet není propojen s e-mailovou adresou tvůrce revize
5 změnil soubory, kde provedl 15 přidání a 5 odebrání
  1. 1
    1
      deepdoc/parser/pdf_parser.py
  2. 11
    3
      rag/app/naive.py
  3. 1
    1
      rag/nlp/rag_tokenizer.py
  4. 1
    0
      requirements.txt
  5. 1
    0
      requirements_dev.txt

+ 1
- 1
deepdoc/parser/pdf_parser.py Zobrazit soubor

b["text"].strip()[-1] in ",;:'\",、‘“;:-", b["text"].strip()[-1] in ",;:'\",、‘“;:-",
len(b["text"].strip()) > 1 and b["text"].strip( len(b["text"].strip()) > 1 and b["text"].strip(
)[-2] in ",;:'\",‘“、;:", )[-2] in ",;:'\",‘“、;:",
b["text"].strip()[0] in "。;?!?”)),,、:",
b_["text"].strip()[0] in "。;?!?”)),,、:",
] ]
# features for not concating # features for not concating
feats = [ feats = [

+ 11
- 3
rag/app/naive.py Zobrazit soubor

from rag.nlp import rag_tokenizer, naive_merge, tokenize_table, tokenize_chunks, find_codec from rag.nlp import rag_tokenizer, naive_merge, tokenize_table, tokenize_chunks, find_codec
from deepdoc.parser import PdfParser, ExcelParser, DocxParser from deepdoc.parser import PdfParser, ExcelParser, DocxParser
from rag.settings import cron_logger from rag.settings import cron_logger
from rag.utils import num_tokens_from_string
class Docx(DocxParser): class Docx(DocxParser):
def __init__(self): def __init__(self):
if not l: if not l:
break break
txt += l txt += l
sections = txt.split("\n")
sections = [(l, "") for l in sections if l]
sections = []
for sec in txt.split("\n"):
if num_tokens_from_string(sec) > 10 * parser_config.get("chunk_token_num", 128):
sections.append((sec[:int(len(sec)/2)], ""))
sections.append((sec[int(len(sec)/2):], ""))
else:
sections.append((sec, ""))
callback(0.8, "Finish parsing.") callback(0.8, "Finish parsing.")
elif re.search(r"\.doc$", filename, re.IGNORECASE): elif re.search(r"\.doc$", filename, re.IGNORECASE):
else: else:
raise NotImplementedError( raise NotImplementedError(
"file type not supported yet(doc, docx, pdf, txt supported)")
"file type not supported yet(pdf, xlsx, doc, docx, txt supported)")
st = timer() st = timer()
chunks = naive_merge( chunks = naive_merge(

+ 1
- 1
rag/nlp/rag_tokenizer.py Zobrazit soubor

def loadDict_(self, fnm): def loadDict_(self, fnm):
print("[HUQIE]:Build trie", fnm, file=sys.stderr) print("[HUQIE]:Build trie", fnm, file=sys.stderr)
try: try:
of = open(fnm, "r")
of = open(fnm, "r", encoding='utf-8')
while True: while True:
line = of.readline() line = of.readline()
if not line: if not line:

+ 1
- 0
requirements.txt Zobrazit soubor

loguru==0.7.2 loguru==0.7.2
umap-learn umap-learn
fasttext==0.9.2 fasttext==0.9.2
volcengine

+ 1
- 0
requirements_dev.txt Zobrazit soubor

redis==5.0.4 redis==5.0.4
fasttext==0.9.2 fasttext==0.9.2
umap-learn umap-learn
volcengine

Načítá se…
Zrušit
Uložit