Upgrade to name-suggestion-index v2

(closes #6073)
This commit is contained in:
Bryan Housel
2019-03-20 23:12:05 -04:00
parent 790d2e867e
commit 99d46e9f70
4 changed files with 669 additions and 384 deletions
+14 -14
View File
@@ -19,7 +19,7 @@ const YAML = require('js-yaml');
const fieldSchema = require('./data/presets/schema/field.json');
const presetSchema = require('./data/presets/schema/preset.json');
const suggestions = require('name-suggestion-index').names;
const suggestions = require('name-suggestion-index').brands.brands;
const deprecated = require('./data/deprecated.json').dataDeprecated;
// fontawesome icons
@@ -200,18 +200,18 @@ function generateFields(tstrings, faIcons) {
function suggestionsToPresets(presets) {
for (var key in suggestions) {
for (var value in suggestions[key]) {
for (var name in suggestions[key][value]) {
addSuggestion(key, value, name);
}
}
}
Object.keys(suggestions).forEach(k => {
const suggestion = suggestions[k];
const qid = suggestion.tags['brand:wikidata'];
if (!qid || !/^Q\d+$/.test(qid)) return; // wikidata tag missing or looks wrong..
const parts = k.split('|', 2);
const tag = parts[0].split('/', 2);
const key = tag[0];
const value = tag[1];
const name = parts[1].replace('~', ' ');
function addSuggestion(key, value, name) {
var suggestion = suggestions[key][value][name];
var presetID, preset;
let presetID, preset;
// sometimes we can find a more specific preset then key/value..
if (suggestion.tags.cuisine) {
@@ -238,8 +238,8 @@ function suggestionsToPresets(presets) {
return;
}
var wikidataTag = { 'brand:wikidata': suggestion.tags['brand:wikidata'] };
var suggestionID = presetID + '/' + name;
let wikidataTag = { 'brand:wikidata': qid };
let suggestionID = presetID + '/' + name;
presets[suggestionID] = {
name: name,
@@ -252,7 +252,7 @@ function suggestionsToPresets(presets) {
matchScore: 2,
suggestion: true
};
}
});
return presets;
}
+651 -367
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -1,16 +1,17 @@
import _clone from 'lodash-es/clone';
import { filters } from 'name-suggestion-index';
import { t } from '../util/locale';
import { utilPreset } from '../util';
import { validationIssue, validationIssueFix } from '../core/validator';
import { actionChangeTags } from '../actions';
import { discardNames } from '../../node_modules/name-suggestion-index/config/filters.json';
export function validationGenericName() {
var type = 'generic_name';
// known list of generic names (e.g. "bar")
var discardNamesRegexes = discardNames.map(function(discardName) {
var discardNamesRegexes = filters.discardNames.map(function(discardName) {
return new RegExp(discardName, 'i');
});
+1 -1
View File
@@ -74,7 +74,7 @@
"minimist": "^1.2.0",
"mocha": "^6.0.0",
"mocha-phantomjs-core": "^2.1.0",
"name-suggestion-index": "1.0.6",
"name-suggestion-index": "2.0.0",
"npm-run-all": "^4.0.0",
"osm-community-index": "0.6.0",
"phantomjs-prebuilt": "~2.1.11",