Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
histhub
wikidata-lib
Commits
c34f8368
Commit
c34f8368
authored
Aug 16, 2018
by
Tobias Steiner
Browse files
Add a debug flag
parent
e1d1df30
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/index.ts
View file @
c34f8368
...
...
@@ -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
...
...
src/wiki-normalizer.ts
View file @
c34f8368
...
...
@@ -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
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment