Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement]: Museum - Rule #1044

Open
MarketingPip opened this issue Sep 14, 2023 · 0 comments
Open

[Improvement]: Museum - Rule #1044

MarketingPip opened this issue Sep 14, 2023 · 0 comments

Comments

@MarketingPip
Copy link
Contributor

MarketingPip commented Sep 14, 2023

Another rule set -

Probably can be expanded and more than likely should be checking for "and" in next word. If match found - do not match. As we may miss full matches.

function museumRule(str) {
  // Create an NLP document from the input text
  let doc = nlp(str);
  // Check for patterns like Scottish National Gallery
  let match = doc.match("(#Place+|#Place|#ProperNoun|#Noun) national (art museum|museum of arts|museum of art|museum of fine arts|museum of fine art|museum|art gallery|gallery|art institute)");
  if (match.found) {
    return match.out("text");
  }
  
    
   // Check for patterns like 'National Gallery of Ireland'
  match = doc.match("national (art museum|museum of arts|museum of art|museum of fine arts|museum of fine art|museum|art gallery|gallery) (of|in) (#Place+|#Place|#ProperNoun|#Noun)");
  if (match.found) {
    return match.out("text");
  }

   // Check for patterns like 'National Gallery Singapore'
  match = doc.match("national (art museum|museum of arts|museum of art|museum of fine arts|museum of fine art|museum|art gallery|gallery) (#Place+|#Place|#ProperNoun|#Noun)");
  if (match.found) {
    return match.out("text");
  }
  
  // 	Denver Art Museum
  match = doc.match("(#Place+|#Place|#ProperNoun|#Noun) (art museum|museum of arts|museum of art|museum of fine arts|museum of fine art|museum|art gallery|art institute|gallery)");
  if (match.found) {
    return match.out("text");
  }


   // Check for patterns like 'Art Gallery of Ontario'
  match = doc.match("(art museum|art gallery|art institute|gallery) of (#Place+|#Place|#ProperNoun|#Noun)");
  if (match.found) {
    return match.out("text");
  }

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

Basic tests:

console.log(museumRule("Denver Art Museum")) 

console.log(museumRule("Scottish National Gallery")) 

console.log(museumRule("National Museum of Scotland")) 

console.log(museumRule("National Museum in Krakow")) 

console.log(museumRule("national art gallery of canada"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant