spencermountain / compromise

modest natural-language processing

Home Page:http://compromise.cool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Improvement]: Location Disambiguation \ Human Name Matching - Rule

MarketingPip opened this issue · comments

This might not be ideal but feel free to address concerns. We will need to check for words after. (Most likely need to drop proper noun at end & expand last name list - or will return things like "Toronto Maple" as person).

function nameRule(str) {
  // Create an NLP document from the input text
  let doc = nlp(str);
  // Check for patterns like  "Orlando Bloom" or "Paris Hilton"
  let match = doc.match("(#Place+|#Place|#ProperNoun|#Noun) (#LastName|#Person|#ProperNoun)");
  if (match.found) {
    return match.out("text");
  }
 

  return false; // Return null if no name is found
}


console.log(nameRule("I went to Orlando today to visit Orlando Bloom")) 
console.log(nameRule("I went to Paris today and seen Paris Hilton")) 

This should tag things like "Orlando Bloom" only as a "person" same way compromise handles "Paris Hilton" and does not return a place.

Now only if we can solve handling names like "North West" ie: Kayne / Kim's kid as a person and not directions without a neural network. 😿

You're free to do this in your own project!

@spencermountain - do you not think this might not be useful for determining if a entity is a name or location properly...? As said tho - the last proper noun should be dropped and the last name list should be expanded.

That would tag all consecutive Propernouns as people. Please try it on some text, and see how it works, before proposing a change to this project.

@spencermountain - I am going to sound stupid (nor trying to sound arrogant) but can I have some examples of some strings so I can see what you mean?

And if not a rule already maybe just #Place #LastName and expand last name list?