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

Add more place classification #49

Merged
merged 2 commits into from
Jun 18, 2019
Merged
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
17 changes: 9 additions & 8 deletions classifier/WhosOnFirstClassifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,16 @@ class WhosOnFirstClassifier extends PhraseClassifier {
}

each (span) {
// do not classify tokens preceeded by an 'IntersectionClassification' or 'StopWordClassification'
let confidence = 1.0
// do not classify tokens preceeded by an 'IntersectionClassification' or add a penality to 'StopWordClassification'
let firstChild = span.graph.findOne('child:first') || span
let prev = firstChild.graph.findOne('prev')
if (
prev && (
prev.classifications.hasOwnProperty('IntersectionClassification') ||
prev.classifications.hasOwnProperty('StopWordClassification')
)) {
return
if (prev) {
if (prev.classifications.hasOwnProperty('IntersectionClassification')) {
return
} else if (prev.classifications.hasOwnProperty('StopWordClassification')) {
confidence = confidence / 2
}
}

// do not classify tokens preceeding 'StreetSuffixClassification' or 'PlaceClassification'
Expand All @@ -116,7 +117,7 @@ class WhosOnFirstClassifier extends PhraseClassifier {
) { return }

// classify tokens
placetypes[placetype].classifications.forEach(Class => span.classify(new Class()))
placetypes[placetype].classifications.forEach(Class => span.classify(new Class(confidence)))
}
})
}
Expand Down
34 changes: 34 additions & 0 deletions classifier/scheme/place.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,39 @@ module.exports = [
not: []
}
]
},
{
// University of Somewhere
confidence: 0.8,
Class: PlaceClassification,
scheme: [
{
is: ['PlaceClassification'],
not: ['StreetClassification']
},
{
is: ['StopWordClassification'],
not: ['StreetClassification']
},
{
is: ['AreaClassification'],
not: ['StreetClassification']
}
]
},
{
// Ecole Jules Vernes
confidence: 0.8,
Class: PlaceClassification,
scheme: [
{
is: ['PlaceClassification'],
not: ['StreetClassification']
},
{
is: ['PersonClassification'],
not: ['StreetClassification']
}
]
}
]
12 changes: 12 additions & 0 deletions test/address.fra.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ const testcase = (test, common) => {
assert('12 Cité Roland Garros', [
{ housenumber: '12' }, { street: 'Cité Roland Garros' }
])

assert('École Paul Valéry Montpellier', [
{ place: 'École Paul Valéry' }, { locality: 'Montpellier' }
])

assert('Université de Montpellier', [
{ place: 'Université de Montpellier' }
])

assert('École Jules Vernes Villetaneuse', [
{ place: 'École Jules Vernes' }, { locality: 'Villetaneuse' }
])
}

module.exports.all = (tape, common) => {
Expand Down
8 changes: 8 additions & 0 deletions test/address.usa.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ const testcase = (test, common) => {
assert('N DWIGHT AVE Portland Oreg', [{ street: 'N DWIGHT AVE' }, { locality: 'Portland' }])
assert('N DWIGHT AVE Portland Orego', [{ street: 'N DWIGHT AVE' }, { locality: 'Portland' }])
assert('N DWIGHT AVE Portland Oregon', [{ street: 'N DWIGHT AVE' }, { locality: 'Portland' }, { region: 'Oregon' }])

assert('University of Hawaii', [{ place: 'University of Hawaii' }])

// Maybe one day this test will pass...
// see: https://github.com/pelias/parser/pull/49
// assert('University of Hawaii at Hilo', [
// { place: 'University of Hawaii at Hilo' }
// ])
}

module.exports.all = (tape, common) => {
Expand Down