spencermountain / compromise

modest natural-language processing

Home Page:http://compromise.cool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Improvement]: Bank of #Place - Rule.

MarketingPip opened this issue · comments

Another rule kit - for things like "Bank of Canada".

/**
 * Extracts Bank of #Place from a given text.
 *
 * @param {string} str - The input text to analyze.
 * @returns {string|false} - The extracted bank name or false if no match is found.
 */

function bankOfRule(str) {
  // Create an NLP document from the input text
  let doc = nlp(str);
  
  // Check for patterns like "the national bank of Canada"
  let match = doc.match("(international|national) bank of (#Place+|#Place)");
  if (match.found) {
    return match.out("text");
  }
  
  
    // Check for patterns like "bank of Canada"
   match = doc.match("bank of (#Place+|#Place)");
  if (match.found) {
    return match.out("text");
  }


  return false; // Return null if no bank names is found
}

good idea - 'bank' is already in orgwords but bank of #Place+ is a good candidate for ./postTagger/model/orgs is you wanted to add it - (the + matches one or more matches)
cheers