Skip to content

Commit

Permalink
Simplified pipeline for speed (Main.py). Pronoun replacement working.
Browse files Browse the repository at this point in the history
  • Loading branch information
NU-1 committed Feb 29, 2020
1 parent dc36a1f commit e7e648b
Show file tree
Hide file tree
Showing 34 changed files with 34 additions and 0 deletions.
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.
34 changes: 34 additions & 0 deletions Flashcard Generator/Main.py
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()


#Print
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.

0 comments on commit e7e648b

Please sign in to comment.