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

remove removeAllZeroNumericPrefix filter #504

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion integration/analyzer_peliasIndexOneEdgeGram.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ module.exports.tests.analyze = function(test, common){
'4:a', '4:ab', '4:abc', '4:abcd', '4:abcde', '4:abcdef',
'4:abcdefg', '4:abcdefgh', '4:abcdefghi', '4:abcdefghij'
] );
assertAnalysis( 'removeAllZeroNumericPrefix', '00001', ['1'] );

assertAnalysis( 'unique', '1 1 1', ['1','1','1'] );
assertAnalysis( 'notnull', ' / / ', [] );
Expand Down
4 changes: 0 additions & 4 deletions integration/analyzer_peliasPhrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ module.exports.tests.analyze = function(test, common){
assertAnalysis( 'british_american_english', 'town theatre', ['0:town', '1:theatre', '1:theater'] );
assertAnalysis( 'british_american_english', 'town theater', ['0:town', '1:theater', '1:theatre'] );

// remove leading zeros from numeric input
assertAnalysis( 'leading_zeros', '01000', ['0:1000'] );
assertAnalysis( 'leading_zeros', '09999', ['0:9999'] );

suite.run( t.end );
});
};
Expand Down
3 changes: 1 addition & 2 deletions integration/analyzer_peliasQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports.tests.analyze = function(test, common){
assertAnalysis('tokenizer', 'foo-bar baz//42', ['foo','bar','baz','42']);
assertAnalysis('tokenizer', 'foo bar baz 42', ['foo','bar', 'baz', '42']);
assertAnalysis('tokenizer', 'foo-bar baz\\42', ['foo', 'bar','baz', '42']);
assertAnalysis('thai_digits', '๐๑๒๓๔๕๖๗ ๘๙', ['1234567', '89']); // leading zero removed
assertAnalysis('thai_digits', '๐๑๒๓๔๕๖๗ ๘๙', ['01234567', '89']); // leading zero remains
assertAnalysis('thai_digits', '๑๒๓๔๕๖๗๐ ๘๙', ['12345670', '89']);
assertAnalysis('digit_glued_to_word', 'john doe42', ['john', 'doe42']);
if (config.schema.icuTokenizer) {
Expand All @@ -41,7 +41,6 @@ module.exports.tests.analyze = function(test, common){
assertAnalysis('trim', ' f ', ['f']);
assertAnalysis('remove_ordinals', '26t', ['26']);
assertAnalysis('remove_ordinals', '26th', ['26']);
assertAnalysis('removeAllZeroNumericPrefix', '00001', ['1']);
assertAnalysis('unique', '1 1 1', ['1','1','1']);
assertAnalysis('notnull', ' / / ', []);

Expand Down
8 changes: 0 additions & 8 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function generate(){
"name_synonyms_multiplexer",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"peliasOneEdgeGramFilter",
"unique_only_same_position",
"notnull",
Expand All @@ -73,7 +72,6 @@ function generate(){
"trim",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"unique_only_same_position",
"notnull"
]
Expand All @@ -92,7 +90,6 @@ function generate(){
"name_synonyms_multiplexer",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"unique_only_same_position",
"notnull",
"flatten_graph"
Expand Down Expand Up @@ -231,11 +228,6 @@ function generate(){
"min_gram" : 1,
"max_gram" : 24
},
"removeAllZeroNumericPrefix" :{
"type" : "pattern_replace",
"pattern" : "^(0*)",
"replacement" : ""
},
"remove_ordinals" : {
"type" : "pattern_replace",
"pattern": "(?i)((^| )((1)st?|(2)nd?|(3)rd?|([4-9])th?)|(([0-9]*)(1[0-9])th?)|(([0-9]*[02-9])((1)st?|(2)nd?|(3)rd?|([04-9])th?))($| ))",
Expand Down
8 changes: 0 additions & 8 deletions test/fixtures/expected-icu-tokenizer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"name_synonyms_multiplexer",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"peliasOneEdgeGramFilter",
"unique_only_same_position",
"notnull",
Expand All @@ -79,7 +78,6 @@
"trim",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"unique_only_same_position",
"notnull"
]
Expand All @@ -103,7 +101,6 @@
"name_synonyms_multiplexer",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"unique_only_same_position",
"notnull",
"flatten_graph"
Expand Down Expand Up @@ -270,11 +267,6 @@
"min_gram": 1,
"max_gram": 24
},
"removeAllZeroNumericPrefix": {
"type": "pattern_replace",
"pattern": "^(0*)",
"replacement": ""
},
"remove_ordinals": {
"type": "pattern_replace",
"pattern": "(?i)((^| )((1)st?|(2)nd?|(3)rd?|([4-9])th?)|(([0-9]*)(1[0-9])th?)|(([0-9]*[02-9])((1)st?|(2)nd?|(3)rd?|([04-9])th?))($| ))",
Expand Down
8 changes: 0 additions & 8 deletions test/fixtures/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"name_synonyms_multiplexer",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"peliasOneEdgeGramFilter",
"unique_only_same_position",
"notnull",
Expand All @@ -74,7 +73,6 @@
"trim",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"unique_only_same_position",
"notnull"
]
Expand All @@ -96,7 +94,6 @@
"name_synonyms_multiplexer",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"unique_only_same_position",
"notnull",
"flatten_graph"
Expand Down Expand Up @@ -252,11 +249,6 @@
"min_gram": 1,
"max_gram": 24
},
"removeAllZeroNumericPrefix": {
"type": "pattern_replace",
"pattern": "^(0*)",
"replacement": ""
},
"remove_ordinals": {
"type": "pattern_replace",
"pattern": "(?i)((^| )((1)st?|(2)nd?|(3)rd?|([4-9])th?)|(([0-9]*)(1[0-9])th?)|(([0-9]*[02-9])((1)st?|(2)nd?|(3)rd?|([04-9])th?))($| ))",
Expand Down
16 changes: 0 additions & 16 deletions test/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ module.exports.tests.peliasIndexOneEdgeGramAnalyzer = function(test, common) {
"name_synonyms_multiplexer",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"peliasOneEdgeGramFilter",
"unique_only_same_position",
"notnull",
Expand Down Expand Up @@ -145,7 +144,6 @@ module.exports.tests.peliasQueryAnalyzer = function (test, common) {
'trim',
'icu_folding',
'remove_ordinals',
'removeAllZeroNumericPrefix',
'unique_only_same_position',
'notnull'
]);
Expand Down Expand Up @@ -177,7 +175,6 @@ module.exports.tests.peliasPhraseAnalyzer = function(test, common) {
"name_synonyms_multiplexer",
"icu_folding",
"remove_ordinals",
"removeAllZeroNumericPrefix",
"unique_only_same_position",
"notnull",
"flatten_graph"
Expand Down Expand Up @@ -516,19 +513,6 @@ module.exports.tests.peliasOneEdgeGramFilter = function(test, common) {
});
};

// this filter removed leading 0 characters. eg. 0001 -> 1
module.exports.tests.removeAllZeroNumericPrefixFilter = function(test, common) {
test('has removeAllZeroNumericPrefix filter', function(t) {
var s = settings();
t.equal(typeof s.analysis.filter.removeAllZeroNumericPrefix, 'object', 'there is a removeAllZeroNumericPrefix filter');
var filter = s.analysis.filter.removeAllZeroNumericPrefix;
t.equal(filter.type, 'pattern_replace');
t.equal(filter.pattern, '^(0*)');
t.equal(filter.replacement, '');
t.end();
});
};

// this filter provides synonyms for street suffixes
// eg. road=>rd
module.exports.tests.streetSynonymFilter = function(test, common) {
Expand Down