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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marc Feger
DKE_project
Commits
5d9efa3c
Commit
5d9efa3c
authored
May 9, 2019
by
Marc Feger
Browse files
Options
Downloads
Patches
Plain Diff
Add path to test if the dbpedia result set is enlargeable
parent
5ebf4eb2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app.py
+10
-1
10 additions, 1 deletion
app.py
src/main.py
+30
-3
30 additions, 3 deletions
src/main.py
static/dbpedia_groundtruth.txt
+1
-1
1 addition, 1 deletion
static/dbpedia_groundtruth.txt
with
41 additions
and
5 deletions
app.py
+
10
−
1
View file @
5d9efa3c
...
...
@@ -3,11 +3,20 @@ 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
assemble_dbpedia_triples
,
collect_wikidata_results_with_title
,
test_if_data_is_enlargeable_for_dbpedia
app
=
Flask
(
__name__
)
# Todo: Füge eine Route ein die die englischen Werte nicht enhält
# Todo: Füge eine Route ein die die zusätlichen Werte in die Triple-Dateien einbringt.
# Todo: Es soll vorher immer erst der Grunddatensatz erzeugt werden und dann die zusätzlichen Informationen ergänzt werden.
@app.route
(
'
/dbpedia/collect/enlargeable
'
)
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
())
...
...
This diff is collapsed.
Click to expand it.
src/main.py
+
30
−
3
View file @
5d9efa3c
import
json
from
tokenize
import
String
from
typing
import
Dict
,
List
from
src
import
WIKIDATA_ENTRYPOINT
,
DBPEDIA_ENTRYPOINT
from
src.dbpedia.keys
import
ResultKeys
from
src.lib.decapper
import
Decapper
from
src.lib.engine
import
SPARQLEngine
from
src.lib.reader
import
FileReader
from
src.lib.ntriple
import
NTriple
from
src.lib.reader
import
FileReader
from
src.lib.writer
import
FileWriter
from
src.wikidata.keys
import
ResultKeys
from
src.dbpedia.keys
import
ResultKeys
def
test_if_data_is_enlargeable_for_dbpedia
()
->
Dict
:
"""
This method assembles a groundtruth an checks during 10 iterations if the collected data size increase or not.
:return: Result set with the information if it is possible for dbpedia to gain more data.
"""
engine
=
SPARQLEngine
(
entrypoint
=
DBPEDIA_ENTRYPOINT
,
query
=
'
static/dbpedia_groundtruth.sparql
'
)
data
=
engine
.
get_json
()
size
=
len
(
data
[
'
results
'
][
'
bindings
'
])
increased
=
False
for
i
in
range
(
0
,
10
):
all_movies
=
[
Decapper
(
movie
[
ResultKeys
.
movie
.
value
]).
unpack
()
for
movie
in
data
[
'
results
'
][
'
bindings
'
]]
engine
=
SPARQLEngine
(
entrypoint
=
DBPEDIA_ENTRYPOINT
,
query
=
'
static/dbpedia_groundtruth.sparql
'
)
appendix_res
=
engine
.
get_json
()
for
candidate
in
appendix_res
[
'
results
'
][
'
bindings
'
]:
if
Decapper
(
candidate
[
ResultKeys
.
movie
.
value
]).
unpack
()
not
in
all_movies
:
data
[
'
results
'
][
'
bindings
'
]
+=
[
candidate
]
increased
=
True
print
(
'
Gain after step
'
+
str
(
i
)
+
'
is:
'
+
str
(
size
-
len
(
all_movies
)))
size
=
len
(
all_movies
)
return
{
'
increase
'
:
increased
,
'
current_size
'
:
size
}
def
assemble_wikidata_groundtruth_english
()
->
Dict
:
...
...
This diff is collapsed.
Click to expand it.
static/dbpedia_groundtruth.txt
+
1
−
1
View file @
5d9efa3c
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