-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (49 loc) · 1.95 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# leggere pdf
# riassunto overview sopra i capitoli o i testi
# Bullet points o cose del genere
# generazione domande di fine capitolo
# verifica della correttezza delle risposte
# Generazione delle flashcards
# estrazione del testo da audio / video (magari usare ffmpeg)
# riutilizzo delle operazioni precedenti con la trascrizione
# Dare opzione di usare font che possono leggere persone dislessiche (?)
# Dare opzione di fare un read aloud
import pdf_miner
import langChain
if __name__ == '__main__':
# Example usage
pdf_path = 'pdf/P1-10-sequence-learning.pdf'
text = pdf_miner.extract_text_from_pdf(pdf_path)
#text = pdf_miner.format_text(text)
#print(text)
#print("\n----------------------------------------------------------------\n")
#print(gemma.get_summarization(text))
#print(gemma.get_questions(text))
"""
# PDF pagina per pagina
text = pdf_miner.format_text_per_page(text)
print(text[0])
print("\n----------------------------------------------------------------\n")
#for page in text:
#print(gemma.get_summarization(page))
#print("QUESTIONS: " + gemma.get_questions(page))
# QA
langChain = langChain.Chain_Class()
langChain.init_chain(text)
print(langChain.get_answer("What is the LSTM method?"))
"""
"""
pdf_loader = PyPDFLoader(pdf_path)
pages = pdf_loader.load_and_split()
print(pages[0].page_content)
# summerize
langChain = langChain.Chain_Class(pdf_path)
print(langChain.get_summarize(pages)['output_text'])
"""
# web page summarize
Model_Class = langChain.Model_Class(pdf_path)
text_array = Model_Class.get_webpage("https://en.wikipedia.org/wiki/Large_language_model")
for doc in Model_Class.formatted_webpage(text_array):
print(doc.page_content)
print("\n----------------------------------------------------------------\n")
print(Model_Class.get_web_summarize(text_array)['output_text'])