Esempio n. 1
0
def replace_plural_head(head):
    print(head.text)
    if (head.text == "'re"):
        return "'s"
    regex = re.compile('[a-z]+')
    lex = Lexicon.getDefaultLexicon()
    realiser = Realiser(lex)
    nlgFactory = NLGFactory(lex)
    p = nlgFactory.createClause()
    p.setVerb(head.text)
    p.setSubject("she")
    verb_match = regex.match(realiser.realiseSentence(p).split(" ")[1])
    if (verb_match):
        return verb_match.group()
    else:
        return head.text
Esempio n. 2
0
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), "SimpleNLG-4.4.8.jar"))

from simplenlg.framework import NLGFactory, CoordinatedPhraseElement, ListElement, PhraseElement
from simplenlg.lexicon import Lexicon
from simplenlg.realiser.english import Realiser
from simplenlg.features import Feature, Tense, NumberAgreement
from simplenlg.phrasespec import NPPhraseSpec

from java.lang import Boolean

lexicon = Lexicon.getDefaultLexicon()
nlgFactory = NLGFactory(lexicon)
realiser = Realiser(lexicon)

print("hello world")

p = nlgFactory.createSentence("my dog is happy")
sentence = realiser.realiseSentence(p)
print(sentence)

p = nlgFactory.createClause()
p.setSubject("Mary")
p.setVerb("chase")
p.setObject("the monkey")

sentence2 = realiser.realiseSentence(p)
print(sentence2)