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

venue work: changes to how ampersands are parsed #120

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions classifier/IntersectionClassifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class IntersectionClassifier extends PhraseClassifier {
// blacklist
// delete this.index.corner

// index defined in code below, no dictionary files loaded:
this.index['&'] = true
this.index.and = true
this.index.und = true
Expand All @@ -39,6 +40,17 @@ class IntersectionClassifier extends PhraseClassifier {

// use an inverted index for full token matching as it's O(1)
if (this.index.hasOwnProperty(span.norm)) {
// do not classify 'and' sandwiched by two 'PlaceClassification'
// as an 'IntersectionClassification'.
// eg. 'Bar & Restaurant'
if (
['&', 'and', 'und'].includes(span.norm) &&
prev.classifications.hasOwnProperty('PlaceClassification') &&
next.classifications.hasOwnProperty('PlaceClassification')
) {
return
}

// classify phrase
span.classify(new IntersectionClassification(1))

Expand Down
30 changes: 15 additions & 15 deletions classifier/scheme/person.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module.exports = [
scheme: [
{
is: ['GivenNameClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['GivenNameClassification'],
not: ['StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
not: ['PunctuationClassification', 'StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
}
]
},
Expand All @@ -24,11 +24,11 @@ module.exports = [
scheme: [
{
is: ['GivenNameClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['SurnameClassification'],
not: ['StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
not: ['PunctuationClassification', 'StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
}
]
},
Expand All @@ -39,15 +39,15 @@ module.exports = [
scheme: [
{
is: ['GivenNameClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['StopWordClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['SurnameClassification'],
not: ['StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
not: ['PunctuationClassification', 'StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
}
]
},
Expand All @@ -58,15 +58,15 @@ module.exports = [
scheme: [
{
is: ['GivenNameClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['GivenNameClassification', 'SurnameClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['SurnameClassification'],
not: ['StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
not: ['PunctuationClassification', 'StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
}
]
},
Expand All @@ -77,11 +77,11 @@ module.exports = [
scheme: [
{
is: ['GivenNameClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['AlphaClassification'],
not: ['StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
not: ['PunctuationClassification', 'StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
}
]
},
Expand All @@ -92,15 +92,15 @@ module.exports = [
scheme: [
{
is: ['GivenNameClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['StopWordClassification'],
not: ['StreetClassification', 'IntersectionClassification']
not: ['PunctuationClassification', 'StreetClassification', 'IntersectionClassification']
},
{
is: ['AlphaClassification'],
not: ['StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
not: ['PunctuationClassification', 'StreetClassification', 'StreetPrefixClassification', 'StopWordClassification']
}
]
}
Expand Down
Loading