In [1]:
from spacy.en import English
from spacy.symbols import nsubj, VERB
from pattern.en import conjugate, PAST, PRESENT, FUTURE, tenses, SINGULAR, PLURAL, SUBJUNCTIVE, IMPERATIVE
from itertools import tee
import string
from HTMLParser import HTMLParser
from tenseflow import change_tense, get_subjects_of_verb
from tenseflow.utils import pairwise
In [2]:
npl = English()
In [3]:
text = u'The rooms were filled with cupboards and book-shelves.'
doc = npl(text)
print([(x.text, x.tag_, x.dep_, list(x.ancestors)) for x in list(doc.sents)[0]])
change_tense(text,'future')
Out[3]:
In [7]:
text = u'The will says otherwise.'
doc = npl(text)
print([(x.text, x.tag_, x.dep_, list(x.ancestors)) for x in list(doc.sents)[0]])
change_tense(text,'future')
Out[7]:
In [6]:
text = u'I will be filled.'
doc = npl(text)
print([(x.text, x.tag_, x.dep_, list(x.ancestors)) for x in list(doc.sents)[0]])
change_tense(text,'future')
Out[6]:
In [28]:
text = u'The rooms were filled with cupboards and book-shelves.'
doc = npl(text)
tok = [x for x in list(doc.sents)[0] if x.text == 'filled'][0]
tok.dep_
Out[28]:
In [28]:
aa = conjugate('will', tense=PRESENT, person=3, number=SINGULAR, negated=True)
aa
Out[28]:
In [7]:
text = u'I have gone to the store.'
doc = npl(text)
print([(x.text, x.tag_, x.dep_) for x in list(doc.sents)[0]])
change_tense(text,'past')
Out[7]:
In [12]:
text = u'I will have lived.'
doc = npl(text)
print([(x.text, x.tag_) for x in list(doc.sents)[0]])
change_tense(text,'future')
Out[12]:
In [9]:
text = u'I will have five cookies.'
doc = npl(text)
print([(x.text, x.tag_) for x in list(doc.sents)[0]])
change_tense(text,'future')
Out[9]:
In [13]:
a = conjugate('do',tense=PAST, person=3, number=SINGULAR)
a
Out[13]:
In [5]:
doc = npl(u'The will says otherwise.')
In [4]:
change_tense('The will says otherwise.','future')
Out[4]:
In [6]:
Out[6]:
In [8]:
In [16]:
tok.vocab
Out[16]:
In [ ]: