Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DKE_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc Feger
DKE_project
Commits
e8208db0
Commit
e8208db0
authored
6 years ago
by
Marc Feger
Browse files
Options
Downloads
Patches
Plain Diff
Remove route to collect seperate titles
parent
b9f833cc
No related branches found
No related tags found
No related merge requests found
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
app.py
+1
-6
1 addition, 6 deletions
app.py
src/main.py
+0
-52
0 additions, 52 deletions
src/main.py
static/wikidata_title.sparql
+0
-8
0 additions, 8 deletions
static/wikidata_title.sparql
static/wikidata_titles_and_labels.txt
+0
-1
0 additions, 1 deletion
static/wikidata_titles_and_labels.txt
with
1 addition
and
67 deletions
app.py
+
1
−
6
View file @
e8208db0
...
...
@@ -3,7 +3,7 @@ from flask.json import jsonify
from
src.main
import
assemble_wikidata_groundtruth_english
,
assemble_dbpedia_groundtruth_english
,
\
assemble_wikidata_triples
,
\
assemble_dbpedia_triples
,
collect_wikidata_results_with_title
,
test_if_data_is_enlargeable_for_dbpedia
assemble_dbpedia_triples
,
test_if_data_is_enlargeable_for_dbpedia
app
=
Flask
(
__name__
)
...
...
@@ -17,11 +17,6 @@ def dbpedia_data_can_enlarge():
return
jsonify
(
test_if_data_is_enlargeable_for_dbpedia
())
@app.route
(
'
/wikidata/collect/title
'
)
def
wikidata_collect_title
():
return
jsonify
(
collect_wikidata_results_with_title
())
@app.route
(
'
/dbpedia/n3
'
)
def
dbpedia_n3
():
return
jsonify
(
assemble_dbpedia_triples
())
...
...
This diff is collapsed.
Click to expand it.
src/main.py
+
0
−
52
View file @
e8208db0
...
...
@@ -254,55 +254,3 @@ def assemble_dbpedia_triples() -> List:
predicate
=
dbp
+
'
productionCompanies
'
,
value
=
production_companies
).
as_ete_triple
()]
return
triples
def
collect_wikidata_results_with_title
()
->
Dict
:
"""
This method collects the wikidata results with a Title in different languages.
Therefore rdfs:label and wdt:title are used.
:warning: Takes a long time.
:return: The List of all titles grouped in a dict with the corresponding film.
"""
data
=
FileReader
(
source
=
'
static/wikidata_groundtruth.txt
'
).
as_json
()
titles
=
{}
progress
=
0
print
(
'
[GET] Collect Wikidata film labels and titles in different languages:
'
)
print
(
str
(
'
\t
'
)
+
str
(
progress
)
+
'
of
'
+
str
(
len
(
data
)))
for
result
in
data
:
movie_id
=
Decapper
(
result
[
ResultKeys
.
movie
.
value
]).
unpack
()
query_label
=
FileReader
(
source
=
'
static/wikidata_title.sparql
'
)
\
.
as_string
()
\
.
replace
(
'
subject
'
,
'
<
'
+
movie_id
+
'
>
'
)
\
.
replace
(
'
predicate
'
,
'
rdfs:label
'
)
\
.
replace
(
'
value
'
,
'
Label
'
)
engine_label
=
SPARQLEngine
(
entrypoint
=
WIKIDATA_ENTRYPOINT
,
query
=
query_label
)
query_title
=
FileReader
(
source
=
'
static/wikidata_title.sparql
'
)
\
.
as_string
()
\
.
replace
(
'
subject
'
,
'
<
'
+
movie_id
+
'
>
'
)
\
.
replace
(
'
predicate
'
,
'
wdt:P1476
'
)
\
.
replace
(
'
value
'
,
'
Title
'
)
engine_title
=
SPARQLEngine
(
entrypoint
=
WIKIDATA_ENTRYPOINT
,
query
=
query_title
)
titles
[
movie_id
]
=
{
'
Labels
'
:
engine_label
.
get_json_with_query
()[
"
results
"
][
"
bindings
"
],
'
Titles
'
:
engine_title
.
get_json_with_query
()[
"
results
"
][
"
bindings
"
]
}
progress
+=
1
if
progress
%
100
==
0
:
print
(
str
(
'
\t
'
)
+
str
(
progress
)
+
'
of
'
+
str
(
len
(
data
)))
print
(
'
Done
'
)
print
(
'
[WRITE] Data to static/wikidata_titles_and_labels.txt
'
)
writer
=
FileWriter
(
destination
=
'
static/wikidata_titles_and_labels.txt
'
,
data
=
titles
)
writer
.
as_filtered_json
()
print
(
'
Done
'
)
return
titles
This diff is collapsed.
Click to expand it.
static/wikidata_title.sparql
deleted
100644 → 0
+
0
−
8
View file @
b9f833cc
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
SELECT DISTINCT ?value
WHERE{
OPTIONAL {subject predicate ?value.}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
static/wikidata_titles_and_labels.txt
deleted
100644 → 0
+
0
−
1
View file @
b9f833cc
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