-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified pipeline for speed (Main.py). Pronoun replacement working.
- Loading branch information
Showing
34 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#Speedup: bash runStanfordParserServer.sh, bash runSSTServer.sh | ||
|
||
import sys | ||
import pip | ||
import spacy | ||
import neuralcoref | ||
import lexnlp.nlp.en.segments.sentences as lex_sentences | ||
import question_generator as gen | ||
|
||
|
||
#Load | ||
direct_path = '' | ||
with open(direct_path, 'r') as file: | ||
brief = file.read() | ||
|
||
|
||
#Preprocess | ||
brief = lex_sentences.pre_process_document(brief) | ||
pronouns = spacy.load('en') | ||
neuralcoref.add_to_pipe(pronouns,greedyness=0.5,max_dist=100,blacklist=False) | ||
neural = pronouns(brief) | ||
brief = neural._.coref_resolved | ||
|
||
|
||
#Tokenize | ||
sentences = list(lex_sentences.get_sentence_list(brief)) | ||
questions = gen.QuestionGenerator() | ||
|
||
|
||
for sentence in sentences: | ||
flashcard = questions.generate_question(sentence) | ||
if flashcard: | ||
print("Question: {}\n\nAnswer: {}\n-------------\n".format(flashcard[0]['Q'], flashcard[0]['A'])) |
File renamed without changes.
File renamed without changes.
File renamed without changes.