spencermountain / compromise

modest natural-language processing
http://compromise.cool
MIT License
11.3k stars 645 forks source link

are/were #14

Closed MichaelPaulukonis closed 9 years ago

MichaelPaulukonis commented 9 years ago

I'm new to nlp and am weak on my grammar, so maybe I'm barking up the wrong trees.

I'm using nlp_compromise to switch the verb-tense in sentences from past to present, or present to past, using nlp.verb(vb).to_present() or nlp.verb(vb).to_past() as required.

It's working great, for the most part, except for when I try to swap the tense of "They are friends" or "They were friends".

Is there some other way I should be going about this, am I using the wrong tools, or is this something that can be extended with some new rules?

spencermountain commented 9 years ago

hi Michael, thanks for the kind words. "they are friended"? ;) the intended way to change tense of a sentence is to parse its grammar first, with nlp.pos() like this:

nlp.pos("they are friends")[0].to_past().text()

though you can see 1) its sorta a ridiculous syntax, and 2) it still fumbles your example.

so it definitely needs some work. I'll put some time into it this week.

What would be the best way for it to behave, for your purpose? cheers

MichaelPaulukonis commented 9 years ago

I'm using it for a NaNoGenMo project right now, that has output like this. I'm hoping to be able to switch between tales of the past, and telling them as though they are happening.

Currently, I'm tagging verbs as "Foo bar {{verb}} baz foo" in templates, then extracting them from the output, processing, and replacing the original. I could try it on the sentence level and see how it flies.

spencermountain commented 9 years ago

hi Michael, think I got it. Should be fixed now. Lemme know if you run into something

Some years before you were born, near madchestered in the city-state Prussia, there was a decayed mansion where maried the Eager lived. Maria lived with Shy Alexandra. Haley the Mean, Alert Allison, Victoria the Caustic, Ella the Unhelpful, Volcanic Hailey, resigned Holly Shiftwell, Local Sydney, Joan of Arc the Supercilious, Pretty Brienne of Tarth, Julia the Quick-tempered, and Jessica the Beneficent were friends of Maria. Sooner or later, Alexandra died It happened to everyone eventually. It happened to her sooner. "Vroom?" said Maria to nobody in particular. Chloe killed Holly Shiftwell. "Whoops!" said Chloe to nobody in particular. Chloe the Callous is given a tongue-lashing by Maria the Eager. God evidently did it to punish Chloe for her great greediness. Maria settled down and dated for a few years, but decided to remain single. Maria still mourns the stinging loss of Holly Shiftwell.

MichaelPaulukonis commented 9 years ago

Thanks for this; I'm getting back to this aspect, now.