Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wikidata-service
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
This server has been upgraded to GitLab release
17.10
.
Show more breadcrumbs
ub-unibas
wikidata-service
Commits
e64040a0
Commit
e64040a0
authored
1 year ago
by
Jonas Waeber
Browse files
Options
Downloads
Patches
Plain Diff
improve wikidata data parsing.
parent
e8c6ecba
Loading
Loading
No related merge requests found
Pipeline
#109320
passed
1 year ago
Stage: build
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/rest/wikidata.go
+3
-4
3 additions, 4 deletions
pkg/rest/wikidata.go
pkg/rest/wikidata_item.go
+4
-1
4 additions, 1 deletion
pkg/rest/wikidata_item.go
with
7 additions
and
5 deletions
pkg/rest/wikidata.go
+
3
−
4
View file @
e64040a0
...
...
@@ -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"
,
"geo
graphic
shape"
,
"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
{}
}
...
...
This diff is collapsed.
Click to expand it.
pkg/rest/wikidata_item.go
+
4
−
1
View file @
e64040a0
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment