Précédent   Forum du club des développeurs et IT Pro > Webmasters - Développement Web > Web sémantique > SPARQL
SPARQL Forum d'entraide sur SPARQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 10/10/2012, 12h42   #1
helabah
Invité régulier
 
Femme
Étudiant
Inscription : mai 2012
Messages : 31
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : mai 2012
Messages : 31
Points : 6
Points : 6
Par défaut Différence entre la valeur d'une instance et une autre valeur

J'ai créé une interface pour l'évaluation où il existe un bouton valider. Ce bouton permet de calculer la différence entre l'ancienne valeur et la valeur 20 . J'essaie de sélectionner une instance avec SPARQL et je voudrais évaluer une instance en soustrayant 20 à l'ancienne valeur.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
	valider.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				Model m=ModelFactory.createMemModelMaker().createModel(null);
				FileManager.get().readModel( m, owlFile );
				String myOntologyName = "ProjetHela";
				String uri="file:///C:/Project/Krs1.owl";
				// Définition de prefixe pour simplifier l'utilisation de SPARQL
				String reuses = "maj: <"+RDF.getURI()+">" ;
				// String myOntologyPrefix = "PREFIX "+myOntologyName+": <"+myOntologyNS+">" ;
				String myOntologyPrefix = "PREFIX "+myOntologyName+": <"+uri+">" ;
				// if (liste.getSelectedItem().toString().equals("GMP: Puissance=60352 Watt,limite supérieure= 73500 Watt")) {
				String queryString= 
					"PREFIX maj: <http://www.owl-ontologies.com/reuses.owl#>"
					+ "SELECT ?hasnameevaluated"
					+ " WHERE "
					+ "{"
					+ "?Besoin maj:hasnameevaluated ?hasnameevaluated "
					+"FILTER (?hasnameevaluated - 20)  "
					+ " } ";
				Query query = QueryFactory.create(queryString) ;
 
				QueryExecution qexec = QueryExecutionFactory.create(query, m) ;
				try  {
					ResultSet rs = qexec.execSelect() ;
 
					// Affichage des resultats
					for ( ; rs.hasNext() ; ){
					//System.out.print("");
				    QuerySolution rb = rs.nextSolution() ;
					String y = rb.getLiteral("hasnameevaluated").getString();
					System.out.println( " " + y);
					}}	finally {
						qexec.close() ;
 
						}
					}	
				}
 
 
		);
Ma requête n'a donné aucun résultat.

Merci
helabah est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/10/2012, 16h50   #2
CesarR
Membre habitué
 
Homme
Inscription : juillet 2005
Messages : 82
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Etats-Unis

Informations forums :
Inscription : juillet 2005
Messages : 82
Points : 105
Points : 105
Envoyer un message via MSN à CesarR
Tu veux faire quoi avec cette ligne?
Code :
FILTER (?hasnameevaluated - 20)
Dans FILTER tu dois mettre une contrainte.
CesarR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/10/2012, 12h19   #3
helabah
Invité régulier
 
Femme
Étudiant
Inscription : mai 2012
Messages : 31
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : mai 2012
Messages : 31
Points : 6
Points : 6
Bonjour,
désolé si mon message était incompréhensible . Bref je voulais tout simplement prendre l'ancienne valeur de l'instance et la soustraire avec une autre valeur par exemple
Code :
 nouvelle valeur= ?hasnameevaluated- 20
helabah est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/10/2012, 16h40   #4
CesarR
Membre habitué
 
Homme
Inscription : juillet 2005
Messages : 82
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Etats-Unis

Informations forums :
Inscription : juillet 2005
Messages : 82
Points : 105
Points : 105
Envoyer un message via MSN à CesarR
oui bah c'est pas du tout le role de FILTER. Il faut lire la documentation.

La reponse a ta question est ici http://www.w3.org/TR/sparql11-query/#assignment
CesarR est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/10/2012, 12h45   #5
helabah
Invité régulier
 
Femme
Étudiant
Inscription : mai 2012
Messages : 31
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : mai 2012
Messages : 31
Points : 6
Points : 6
Merci CesarR pour la réponse, j'ai essayé d'écrire la requête mais il existe une erreur
Code :
1
2
3
4
5
6
7
"PREFIX maj: <http://www.owl-ontologies.com/reuses.owl#>"
					+ "SELECT  ?hasnameevaluated "
					+"{"
					+" ?x maj:hasnameevaluated ?p. "
					+" BIND (?p- 20) AS ?hasnameevaluared "
					+"?x maj:Besoin ?hasnameevaluated ."
					+"}";
l'erreur est
Citation:
Exception in thread "AWT-EventQueue-0" com.hp.hpl.jena.query.QueryParseException: Lexical error at line 1, column 117. Encountered: " " (32), after : "BIND"
at com.hp.hpl.jena.sparql.lang.ParserSPARQL.perform(ParserSPARQL.java:99)
at com.hp.hpl.jena.sparql.lang.ParserSPARQL.parse(ParserSPARQL.java:38)
at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:125)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:72)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:43)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:31)
at exple.modfifen$3.actionPerformed(modfifen.java:199)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
helabah est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 12h54.


 
 
 
 
Partenaires

Hébergement Web