spencermountain / compromise

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

Verb is mistakenly parsed as a noun. #1108

Closed NikhilVerma closed 4 months ago

NikhilVerma commented 4 months ago

Request

nlp('My friend who lives nearby looks like Homer Simpson.').debug();

Response

[
    {
        "text": "My",
        "tags": "[Noun, Possessive, Actor]"
    },
    {
        "text": "friend",
        "tags": "[Noun, Actor, Singular]"
    },
    {
        "text": "who",
        "tags": "[Determiner]"
    },
    {
        "text": "lives",
        "tags": "[Verb, PresentTense]"
    },
    {
        "text": "nearby",
        "tags": "[Adjective]"
    },
    {
        "text": "looks", // ⚠️ looks is a verb here
        "tags": "[Noun, Plural]"
    },
    {
        "text": "like",
        "tags": "[Preposition]"
    },
    {
        "text": "Homer",
        "tags": "[Noun, Singular, Person, FirstName, ProperNoun, MaleName]"
    },
    {
        "text": "Simpson",
        "tags": "[ProperNoun, Noun, Singular, Person, LastName]"
    }
]

I think a noun (which also exists in verbs) followed by a preposition should be marked as a verb?

spencermountain commented 4 months ago

hey Nikhil, I believe looks like works a verb in that sentence - if the sentence were john looks like joe, wouldn't it be the verb of that sentence also? of course you're free to change it - you can do this:

doc.match('[#Noun] #Preposition', 0 ).tag('Verb')

that should fix your case, but be wary of other changes it will make cheers

NikhilVerma commented 4 months ago

@spencermountain thanks for the quick reply! I'll take your suggestion for this case