pelias / pelias/parser

Option to do the address parsing for a specific country

Open
#172 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
64
Forks
26
PR merge metrics
No merged PRs in 30d

Description

The way the pelias-parser Classifiers works is, that they take all the configured tokens for the configured countries and apply them to given address string irrespective of which country the address belong to.

For example the CompoundStreetClassifier reads in the tokens for the following countries:

libpostal.load(this.suffixes, ['de', 'nl', 'sv', 'nb'], 'concatenated_suffixes_separable.txt')
libpostal.load(this.suffixes, ['de', 'nl', 'nb'], 'concatenated_suffixes_inseparable.txt')

The problem here is that if we have define a street type for Denmark (de), which is not the a valid street type for Norway (nb), the classifier will still try to classify the Norwegian addresses with the Danish Street types and the other street types defined for other countries.

So for example we want to add land and lien as valid street types for Norway, but will then it will affect other countries addresses, like the following unit test for French address fails when adding 'lien' as street type for Norway.

address FRA: Rue de l'Empereur Julien Paris
      expected: |-
        [ { street: 'Rue de l\'Empereur Julien' }, { locality: 'Paris' } ]
      actual: |-
        [ { street: 'Rue de l\'Empereur' }, { locality: 'Julien' } ]

This works best when our scope is full earth, where we don't know in advance which country the address belongs to. But in our case for example we know that we have norwegian addresses, so it would be nice if the classifier can be optionally configured to use only the Norwegian street types and not from the other countries.

Solution

The solution is obviously be able to configure the countries we want the parser to work on.
We can use the options parameter in parser/Parser.js to send in the configuration.
And in case of pelias-api, we can add the configuration option in the pelias-config, which pelias-api can send further into the pelias-parser.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in parser/Parser.js and trace how the options parameter reaches the classifiers, especially CompoundStreetClassifier. Review the existing French regression test and the country-specific token loading shown in the issue. Done means callers can optionally restrict parsing to configured countries without changing the default full-earth behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.