Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quizzdoc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Boucher Thomas
quizzdoc
Merge requests
!8
push quizz bonnoron diers wacylk
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
push quizz bonnoron diers wacylk
sculpture_bonnoron_diers_wacyk
into
master
Overview
0
Commits
1
Changes
2
Merged
push quizz bonnoron diers wacylk
Diers Nicolas
requested to merge
sculpture_bonnoron_diers_wacyk
into
master
Apr 16, 2018
Overview
0
Commits
1
Changes
2
Push de Bonnoron Diers et Wacyk
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
ad955653
1 commit,
Apr 16, 2018
2 files
+
128
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
src/fr/insarouen/asi/document/quizz/webSemantique/QuestionReponsesSculpteurs.java
0 → 100644
+
95
−
0
View file @ ad955653
Edit in single-file editor
Open in Web IDE
package
fr.insarouen.asi.document.quizz.webSemantique
;
import
fr.insarouen.asi.document.quizz.QuestionReponses
;
import
fr.insarouen.asi.document.quizz.Aleatoire
;
import
java.net.URL
;
import
java.net.MalformedURLException
;
import
com.hp.hpl.jena.query.QuerySolution
;
import
com.hp.hpl.jena.rdf.model.RDFNode
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
QuestionReponsesSculpteurs
extends
QuestionReponsesFrDbpedia
{
String
uriSculpture
;
private
static
String
getURISculpteur
(
String
uriSculpture
)
{
String
res
=
""
;
RDFNode
rdfName
;
String
request
=
"select ?uri where{<"
+
uriSculpture
+
"> <http://dbpedia.org/ontology/author> ?uri}"
;
for
(
QuerySolution
solution
:
Outils
.
SPARQLQuerySolutions
(
getEntreeSparql
(),
getPrefixSparql
(),
request
))
{
rdfName
=
solution
.
get
(
"uri"
);
res
=
rdfName
.
toString
();
}
return
res
;
}
private
static
List
<
String
>
getURIAutresSculpteurs
(
String
uriSculpture
)
{
List
<
String
>
res
=
new
ArrayList
<
String
>();
RDFNode
rdfName
;
String
request
=
"select distinct ?autreSculpteurs where{\n"
;
request
=
request
+
"<"
+
uriSculpture
+
"> <http://dbpedia.org/ontology/author> ?sculpteur.\n"
;
request
=
request
+
"?Sculptures rdf:type <http://dbpedia.org/ontology/Sculpture>.\n"
;
request
=
request
+
"?Sculptures <http://dbpedia.org/ontology/author> ?autreSculpteurs.\n"
;
request
=
request
+
"filter (?autreSculpteurs != ?sculpteur && isiri(?autreSculpteurs))}\n"
;
for
(
QuerySolution
solution
:
Outils
.
SPARQLQuerySolutions
(
getEntreeSparql
(),
getPrefixSparql
(),
request
))
{
rdfName
=
solution
.
get
(
"?autreSculpteurs"
);
res
.
add
(
rdfName
.
toString
());
}
return
res
;
}
private
static
List
<
String
>
choisirSculpteur
(
List
<
String
>
ls
,
int
nb
)
{
int
pos
;
System
.
out
.
println
(
ls
.
size
());
List
<
String
>
res
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
nb
;
i
++)
{
pos
=
Aleatoire
.
entierAleatoire
(
0
,
ls
.
size
());
res
.
add
(
ls
.
remove
(
pos
));
}
return
res
;
}
private
static
String
getNomSculpteurOuOeuvre
(
String
uri
)
{
String
res
=
""
;
RDFNode
rdfName
;
String
request
=
"select ?nom where{<"
+
uri
+
"> rdfs:label ?nom."
;
request
=
request
+
"filter(langmatches(lang(?nom), 'fr'))}"
;
for
(
QuerySolution
solution
:
Outils
.
SPARQLQuerySolutions
(
getEntreeSparql
(),
getPrefixSparql
(),
request
))
{
rdfName
=
solution
.
get
(
"nom"
);
res
=
langStringToString
(
rdfName
.
toString
());
}
return
res
;
}
private
static
List
<
String
>
getNomSculpteur
(
List
<
String
>
uris
)
{
List
<
String
>
res
=
new
ArrayList
<
String
>();
for
(
String
uri
:
uris
)
res
.
add
(
getNomSculpteurOuOeuvre
(
uri
));
return
res
;
}
private
static
String
[]
getQuestions
(
String
_uriSculpteur
)
{
String
[]
res
=
new
String
[
4
];
List
<
String
>
autres
=
getURIAutresSculpteurs
(
_uriSculpteur
);
autres
=
choisirSculpteur
(
autres
,
3
);
res
[
0
]
=
getNomSculpteurOuOeuvre
(
getURISculpteur
(
_uriSculpteur
));
for
(
int
i
=
0
;
i
<
autres
.
size
();
i
++)
res
[
1
+
i
]
=
getNomSculpteurOuOeuvre
(
autres
.
get
(
i
));
return
res
;
}
public
QuestionReponsesSculpteurs
(
String
_uriSculpteur
)
{
super
(
getQuestions
(
_uriSculpteur
),
0
);
uriSculpture
=
_uriSculpteur
;
}
public
String
getDomaine
()
{
return
"Sculpture"
;
}
public
String
getQuestion
()
{
return
"Quel sculpteur a sculpté "
+
getNomSculpteurOuOeuvre
(
uriSculpture
)+
" ?"
;
}
}
Loading