import sys import elemento.elemento as el from colorama import Fore, Style notion = el.Notion() filename = sys.argv[1] f = open("books/" + filename, "r+") text = f.readlines() notion.process_text(text, verbose=True) print(Fore.CYAN) for idee in notion.idees: print(idee) print(Style.RESET_ALL)
from elemento import elemento as el notion = el.Notion('elemento/patterns', 'elemento/time') f = open("books/Ginger_the_girafe.txt", "r+") raw_lines = f.readlines() text = [] for l in raw_lines: if len(l) > 0 and l[0] != '\n': L = l.split('.') text += L exclude = ['\n'] text = [t for t in text if t not in exclude] notion.process_text(text, verbose=True) print(notion) idees = notion.idees idees.sort(key=lambda idee: idee.get_weight()) for idee in notion.idees: print(idee.get_words())
from colorama import Fore, Style import requests import json import re from nltk.corpus import stopwords import gensim.downloader as api import sys from gensim.models.word2vec import Word2Vec print("Loading models...") model = api.load("glove-wiki-gigaword-300") RATIO = 0.8 LIMIT = 3 SCORE = 0 while (True): notion = el.Notion(model=model) question = input("Ask your question: ") question = str(question) words = [] stopwords_ = stopwords.words('english') splitted = re.split(r"\s+(?=[^()]*(?:\(|$))", question) for word in splitted: word = word.translate({ord(i): None for i in '¿?()\x00'}) if word not in stopwords_: words.append(word) print("Reading question...") asker = el.Notion(model=model) question = question.translate({ord(i): None for i in '\n\t\x00\([(^)]+'}) asker.process_sentence(question)
import sys import elemento.elemento as el from colorama import Fore, Style import gensim.downloader as api print("Loading models...") model = api.load("glove-wiki-gigaword-300") print("Models loaded") notion = el.Notion(model=model) filename = sys.argv[1] f = open("books/" + filename, "r+") text = f.readlines() notion.process_text(text, verbose=True, solve_pronouns=True) questions = [] for idee in notion.idees: questions.extend(el.generate_questions(idee)) print("QUESTIONS:") for question in questions: print("Question:", question["question"]) print("Answer:", question["answer"]) print("\n") print(Style.RESET_ALL)