Commit 81730d65 authored by Tobinsk's avatar Tobinsk
Browse files

Merge branch '7-wrong-transformation' into 'master'

Resolve "wrong transformation"

Closes #7

See merge request histhub/wikidata-normalizer!15
parents 071b4267 d47a5618
......@@ -8,6 +8,7 @@ import ProducerStream = require('node-rdkafka/lib/producer-stream');
import AnalyserTransformable from './analyser-transformable';
import {BootstrapWikidata, InterfaceProperty} from './bootstrap-wikidata';
import WikiNormalizer from './wiki-normalizer';
import Debug from 'geolinker-common/dist/stream/debug';
/**
* load sourcemap and config
......@@ -71,6 +72,7 @@ kafka.init().then(async () => {
.pipe(new WikiNormalizer({objectMode: true}, core.getLogger(), wikidataProperties))
.pipe(new ReporterCounter({objectMode: true}, core.getReporter('normalizer'), 'write'))
.pipe(new StreamProducerPreparer({objectMode: true, topic: core.getNconf().get('producer:normalizer:topics'), partition: -1}))
.pipe(new Debug({objectMode: true}, '---'))
.pipe(new ProducerStream(normProducer, {objectMode: true, topic: core.getNconf().get('producer:normalizer:topics')}));
// todo: we need a second consumer and we need a second reporter. So we need to update common libs
......
......@@ -60,7 +60,7 @@ class WikiNormalizer extends Transform {
url: `https://www.wikidata.org/wiki/${obj.id}`,
name: this.getName(obj),
alternative_name: this.getAlternativNames(obj).join(', '),
description: ramda.path(['descriptions', 'en', 'value'], obj),
// description: ramda.path(['descriptions', 'en', 'value'], obj),
country: this.getValue(obj, 'P17', 'id'),
start: this.getStart(obj),
end: this.getEnd(obj),
......@@ -212,7 +212,7 @@ class WikiNormalizer extends Transform {
* @param {string} value
*/
private getValue(obj, property: string, value: string = '') {
return ramda.path(['claims', property, 0, 'mainsnak', 'datavalue', 'value', value], obj);
return ramda.path(['claims', property, 0, 'mainsnak', 'datavalue', 'value', value], obj) || null;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment