-
-
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(FillSolver): Add FillSolver, it will add unclassified tokens to …
…the street This will be used only when StreetPrefixClassification is used. Remove Paris from regions and add cité in street_types. Paris is always used as a locality
- Loading branch information
Showing
4 changed files
with
52 additions
and
1 deletion.
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
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,23 @@ | ||
class FillSolver { | ||
solve (tokenizer) { | ||
tokenizer.solution.forEach(solution => { | ||
// Get streets from this solution | ||
const streets = solution.pair.filter(p => p.classification.constructor.name === 'StreetClassification') | ||
// Get all nodes that are not in the solution | ||
const missings = tokenizer.section[0].graph.edges.child.filter(c => !solution.pair.some(p => p.span.intersects(c))) | ||
|
||
missings.forEach(missing => { | ||
const street = streets.find(s => s.span.end === missing.start - 1) | ||
const prefix = street && street.span.graph.findOne('child:first') | ||
if (prefix && prefix.classifications.StreetPrefixClassification) { | ||
street.span.setBody(`${street.span.body} ${missing.body}`) | ||
street.span.graph.add('child', missing) | ||
street.span.graph.remove('child:last', street.span.graph.findOne('child:last')) | ||
street.span.graph.add('child:last', missing) | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
module.exports = FillSolver |
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