Skip to content

Commit

Permalink
feat(unit): add mask for unit and unit_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit committed May 4, 2020
1 parent cbf4916 commit fa9175a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion solver/Solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Solution {

// return a mask of the input for this solution
// which shows the areas covered by different types of classification
// N = housenumber, S = street, P = postcode, A = administrative
// N = housenumber, S = street, P = postcode, A = administrative, U = unit
mask (tokenizer) {
// use the original input, mask should be the same length
let body = tokenizer.span.body
Expand All @@ -67,6 +67,8 @@ class Solution {
'housenumber': 'N',
'street': 'S',
'postcode': 'P',
'unit': 'U',
'unit_type': 'U',
'default': 'A'
}

Expand Down
9 changes: 9 additions & 0 deletions solver/Solution.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ module.exports.tests.mask = (test, common) => {
t.equal(tokenizer.solution[0].mask(tokenizer), 'VVVVVVVV NN SSSSSSS AAAAAA PPPPP ')
t.end()
})
test('mask', (t) => {
// 'UUU UU NNN SSSSSSSSSSSSSS AAAAAAAAAAAA AAA PPPP'
let tokenizer = new Tokenizer('Lot 12/345 Illawarra Road Marrickville NSW 2204')
common.parser.classify(tokenizer)
common.parser.solve(tokenizer)

t.equal(tokenizer.solution[0].mask(tokenizer), 'UUU UU NNN SSSSSSSSSSSSSS AAAAAAAAAAAA AAA PPPP')
t.end()
})
}

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

0 comments on commit fa9175a

Please sign in to comment.