Skip to content
Snippets Groups Projects
Commit e64040a0 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

improve wikidata data parsing.

parent e8c6ecba
No related merge requests found
Pipeline #109320 passed
......@@ -128,7 +128,6 @@ func (w WikidataRest) extractDescriptions(item WikidataItem) map[string]string {
}
func (w WikidataRest) extractProperties(item WikidataItem) map[string][]*shared.Data {
properties := map[string][]*shared.Data{}
label:
for statementKey, statementItem := range item.Statements {
......@@ -141,14 +140,14 @@ label:
}
for _, statement := range statementItem {
switch statement.Property.DataType {
case "commonsMedia", "geographicshape", "tabular-data":
case "commonsMedia", "geo-shape", "tabular-data":
if _, ok := properties[statementKey]; !ok {
properties[statementKey] = []*shared.Data{}
}
properties[statementKey] = append(properties[statementKey], &shared.Data{
Simple: CommonsUrl + strings.Replace(statement.Value.Content.(string), " ", SpaceReplacement, -1),
})
case "globecoordinate":
case "globe-coordinate":
if _, ok := properties[statementKey]; !ok {
properties[statementKey] = []*shared.Data{}
}
......@@ -178,7 +177,7 @@ label:
properties[statementKey] = append(properties[statementKey], &shared.Data{
Time: statement.Value.GetTime(),
})
case "wikibase-item", "external-id", "url", "string", "musicalnote", "mathematical-expression":
case "wikibase-item", "wikibase-property", "external-id", "url", "string", "musicalnote", "mathematical-expression":
if _, ok := properties[statementKey]; !ok {
properties[statementKey] = []*shared.Data{}
}
......
......@@ -95,7 +95,10 @@ func (v StatementValue) GetMonolingualText() *shared.MonoLingualText {
}
func (v StatementValue) GetGlobeCoordinate() *shared.GlobeCoordinate {
content := v.Content.(map[string]interface{})
content, ok := v.Content.(map[string]interface{})
if !ok {
return &shared.GlobeCoordinate{}
}
lat, latOk := content["latitude"].(string)
lon, lonOk := content["longitude"].(string)
globe, globeOk := content["globe"].(string)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment