-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(streets_with_no_suffix): improved support for streets with no su…
…ffix, such as "broadway"
- Loading branch information
1 parent
72d6463
commit 90481c5
Showing
15 changed files
with
214 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const Classification = require('./Classification') | ||
|
||
class StreetProperNameClassification extends Classification { | ||
constructor (confidence, meta) { | ||
super(confidence, meta) | ||
this.label = 'street_proper_name' | ||
} | ||
} | ||
|
||
module.exports = StreetProperNameClassification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const Classification = require('./StreetProperNameClassification') | ||
|
||
module.exports.tests = {} | ||
|
||
module.exports.tests.constructor = (test) => { | ||
test('constructor', (t) => { | ||
let c = new Classification() | ||
t.false(c.public) | ||
t.equals(c.label, 'street_proper_name') | ||
t.equals(c.confidence, 1.0) | ||
t.deepEqual(c.meta, {}) | ||
t.end() | ||
}) | ||
} | ||
|
||
module.exports.all = (tape, common) => { | ||
function test (name, testFunction) { | ||
return tape(`StreetProperNameClassification: ${name}`, testFunction) | ||
} | ||
|
||
for (var testCase in module.exports.tests) { | ||
module.exports.tests[testCase](test, common) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const WordClassifier = require('./super/WordClassifier') | ||
const StreetProperNameClassification = require('../classification/StreetProperNameClassification') | ||
|
||
/** | ||
Special handling of streets with no suffix | ||
see: https://github.com/pelias/parser/issues/140 | ||
**/ | ||
|
||
class StreetProperNameClassifier extends WordClassifier { | ||
setup () { | ||
this.index = { | ||
'broadway': true, | ||
'esplanade': true | ||
} | ||
} | ||
|
||
each (span) { | ||
// skip spans which contain numbers | ||
if (span.contains.numerals) { return } | ||
|
||
// classify tokens in the index as 'street_proper_name' | ||
if (this.index[span.norm] === true) { | ||
span.classify(new StreetProperNameClassification(0.7)) | ||
} | ||
} | ||
} | ||
|
||
module.exports = StreetProperNameClassifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const StreetProperNameClassifier = require('./StreetProperNameClassifier') | ||
const StreetProperNameClassification = require('../classification/StreetProperNameClassification') | ||
const Span = require('../tokenization/Span') | ||
const classifier = new StreetProperNameClassifier() | ||
|
||
module.exports.tests = {} | ||
|
||
function classify (body) { | ||
let s = new Span(body) | ||
classifier.each(s, null, 1) | ||
return s | ||
} | ||
|
||
module.exports.tests.contains_numerals = (test) => { | ||
test('contains numerals: honours contains.numerals boolean', (t) => { | ||
let s = new Span('example') | ||
s.contains.numerals = true | ||
classifier.each(s, null, 1) | ||
t.deepEqual(s.classifications, {}) | ||
t.end() | ||
}) | ||
} | ||
|
||
module.exports.tests.street_proper_names = (test) => { | ||
let valid = [ | ||
'broadway', | ||
'esplanade' | ||
] | ||
|
||
valid.forEach(token => { | ||
test(`street_proper_names: ${token}`, (t) => { | ||
let s = classify(token) | ||
t.deepEqual(s.classifications, { | ||
StreetProperNameClassification: new StreetProperNameClassification(0.7) | ||
}) | ||
t.end() | ||
}) | ||
}) | ||
} | ||
|
||
module.exports.all = (tape, common) => { | ||
function test (name, testFunction) { | ||
return tape(`StreetProperNameClassifier: ${name}`, testFunction) | ||
} | ||
|
||
for (var testCase in module.exports.tests) { | ||
module.exports.tests[testCase](test, common) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
cité|cite | ||
cités|cites | ||
|
||
# https://github.com/pelias/parser/pull/141#issuecomment-895230721 | ||
!esplanades|esps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
resources/pelias/dictionaries/whosonfirst/locality/name:fra_x_preferred.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# https://github.com/pelias/parser/issues/140 | ||
!broadway |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters