Skip to content

Commit

Permalink
Merge pull request #139 from fnielsen/138-add-false-friend-to-sense
Browse files Browse the repository at this point in the history
Fix #138 and #135 homophones and false friends
  • Loading branch information
fnielsen authored Jul 5, 2022
2 parents db3461a + 1e97868 commit ccf0cbe
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ordia/app/static/ordia.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function sparqlToDataTable(sparql, element, options={}) {
var paging = (typeof options.paging === 'undefined') ? true : options.paging;
var sDom = (typeof options.sDom === 'undefined') ? 'lfrtip' : options.sDom;

var post_url = "https://query.wikidata.org/bigdata/namespace/wdq/sparql";
var post_url = "https://query.wikidata.org/sparql";
var post_data = "query=" + encodeURIComponent(sparql) + '&format=json'

$.post(post_url, post_data, function(response) {
Expand Down
50 changes: 48 additions & 2 deletions ordia/app/templates/lf.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
formDataSparql = `
# Data for a specific sense
SELECT
?description
?description ?descriptionUrl
?value ?valueLabel ?valueUrl
?source ?sourceUrl
WHERE {
Expand Down Expand Up @@ -56,9 +56,55 @@
?value ontolex:representation ?valueLabel .
BIND("alternative form" AS ?description)
}
UNION
{
# Homofon form
BIND(13 AS ?order)
BIND("homophone form" AS ?description)
BIND("../property/P10822" AS ?descriptionUrl)
?form wdt:P10822 ?value .
?value ontolex:representation ?valueLabel .
}
UNION
{
BIND(20 AS ?order)
BIND("Described in" AS ?description)
BIND("../property/P1343" AS ?descriptionUrl)
?form p:P1343 ?value_statement .
?value_statement ps:P1343 ?value .
?value rdfs:label ?valueLabel .
FILTER (LANG(?valueLabel) = 'en')
BIND(CONCAT("reference/", SUBSTR(STR(?value), 32)) AS ?value_Url)
OPTIONAL {
?value_statement prov:wasDerivedFrom / pr:P854 ?sourceUrl .
BIND("↗" AS ?source)
}
}
UNION
{
BIND(21 AS ?order)
BIND("Not described in" AS ?description)
BIND("../property/P9660" AS ?descriptionUrl)
?form p:P9660 ?value_statement .
?value_statement ps:P9660 ?value .
?value rdfs:label ?valueLabel .
FILTER (LANG(?valueLabel) = 'en')
BIND(CONCAT("reference/", SUBSTR(STR(?value), 32)) AS ?value_Url)
OPTIONAL {
?value_statement prov:wasDerivedFrom / pr:P854 ?sourceUrl .
BIND("↗" AS ?source)
}
}
UNION
{
BIND(25 AS ?order)
BIND("Attested in" AS ?description)
?form p:P5323 ?value_statement .
?value_statement ps:P5323 ?value_ .
Expand All @@ -82,7 +128,7 @@
}
UNION
{
BIND(21 AS ?order)
BIND(26 AS ?order)
?lexeme ontolex:lexicalForm ?form .
?lexeme p:P5831 ?value_statement .
?value_statement ps:P5831 ?value .
Expand Down
18 changes: 17 additions & 1 deletion ordia/app/templates/ls.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
# Data for a specific sense
SELECT DISTINCT
?description
?description ?descriptionUrl
?value ?valueLabel ?valueUrl
?source ?sourceLabel ?sourceUrl
WHERE {
BIND(wd:{{ l }}-{{ s }} AS ?sense)
?lexeme ontolex:sense ?sense ;
Expand Down Expand Up @@ -123,6 +124,21 @@
?value ^ontolex:sense / wikibase:lemma ?valueLabel
}
UNION
{
BIND(15 AS ?order)
BIND("False friend" AS ?description)
BIND("../property/P5976" AS ?descriptionUrl)
?sense p:P5976 ?value_statement .
?value_statement ps:P5976 ?value .
?value ^ontolex:sense / wikibase:lemma ?valueLabel
OPTIONAL {
?value_statement prov:wasDerivedFrom / pr:P248 ?source_ .
?source_ rdfs:label ?source .
FILTER (LANG(?source) = 'en')
BIND(CONCAT("reference/", SUBSTR(STR(?source_), 32)) AS ?sourceUrl)
}
}
UNION
{
BIND(20 AS ?order)
BIND("Usage example" AS ?description)
Expand Down
33 changes: 33 additions & 0 deletions ordia/app/templates/property.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,32 @@
`


senseSparql = `
SELECT
?lexeme ?lexemeLabel
?sense ?senseUrl
?language ?languageLabel
?value ?valueUrl
WHERE {
?lexeme wikibase:lemma ?lexemeLabel .
?lexeme ontolex:sense ?sense_ .
BIND(SUBSTR(STR(?sense_), 32) AS ?sense)
BIND(CONCAT("../", ?sense) AS ?senseUrl)
?sense_ wdt:{{ p }} ?value_ .
BIND(SUBSTR(STR(?value_), 32) AS ?value)
BIND(CONCAT("../", ?value) AS ?valueUrl)
?lexeme dct:language ?language
OPTIONAL {
?language rdfs:label ?languageLabel .
FILTER (LANG(?languageLabel) = 'en')
}
}
LIMIT 10000
`




$(document).ready(function() {
sparqlToDataTable(valuesForLexemesByValueSparql, "#values-for-lexemes-by-value", {
Expand All @@ -107,8 +133,15 @@
form: '../',
language: '../language/',
value: '../'}});
sparqlToDataTable(senseSparql, "#senses", {
linkPrefixes: {
lexeme: '../',
form: '../',
language: '../language/',
value: '../'}});
});


</script>

{% endblock %}
Expand Down

0 comments on commit ccf0cbe

Please sign in to comment.