[Improvement]: Bank of #Place - Rule.
MarketingPip opened this issue · comments
Jared Van Valkengoed commented
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
}
spencer kelly commented
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