tomaarsen / Inflex

Natural Language Inflection in English
https://www.tomaarsen.com/projects/inflex/try
GNU General Public License v3.0
11 stars 0 forks source link

a function to align two words #7

Open lsmith77 opened 2 years ago

lsmith77 commented 2 years ago

I want to align two words, ie. if I have challenges, I pass question to this alignment function it would generate questions.

Is this something within the scope of this library?

lsmith77 commented 2 years ago

I am using spacy in my project, so I did a quick hack which works but is very inelegant:

        a_text = a_token.text
        b_text = b_token.lemma_
        a_verb = Verb(a_text)
        b_verb = Verb(b_text)

        if a_verb.is_singular():
            b_text = b_verb.singular()
            b_verb = Verb(b_text)
        elif a_verb.is_plural():
            b_text = b_verb.plural()
            b_verb = Verb(b_text)

        if a_verb.is_past():
            b_text = b_verb.past()
        elif a_verb.is_pres_part():
            b_text = b_verb.pres_part()
        elif a_verb.is_past_part():
            b_text = b_verb.past_part()

        return b_text
tomaarsen commented 2 years ago

That is indeed a bit inelegant. That functionality does not exist, although it certainly could.

lsmith77 commented 2 years ago

so you would be open to a PR? in that case I will see if I can find some time for this.

tomaarsen commented 2 years ago

Yes, I would be!