I want to combine the instance (results) associated with two different property types. I can combine them using SPARQL, but I would like to define it the model itself. I am not sure what is the best way to accomplish it. Let me provide you a concrete example.
I have two classes (:book, :tag), an objecttype property (:hasTag), and a datatype property (:hasDescription) with strings.
Instances are defined as:
:book1 a :book .
:semantics a :tag .
:book1 :hasTag :semantics .
:book1 :hasDescription "book about web technology" .
:book1 :hasDescription "good for all level of users" .
:book1 :hasDescription "has examples from biomedical industries" .
There are other classes and properties as well. I would like to get the tag results (semantics) and description results ("book about web technology", "good for all level of users", "has examples from biomedical industries") for book1. Can it be done be defining another property and somehow linking the new property to hasTag and hasDescription ? or is there another/better way?
Also, on a separate note, I am assuming that two instances to a datatype property (as I did in the example) is fine. Please let me know if there are any concerns in this case.
Related
I have an ontology that contains two classes (course,lesson) the course has a data properties called code of type string
How to get all individuals from specific class with specific data properties value
here is a screenshot
The general pattern is something like this:
SELECT ?individual
WHERE { ?individual a <uri-of-specific-class> ;
<uri-of-property> ?propertyValue .
FILTER(STR(?propertyValue) = "expected value")
}
You will need to adapt this with the details of your specific ontology (the URIs of your class names and properties), but it shows the general approach. I would also suggest that you try out a SPARQL tutorial, there's several good ones online for you to find.
I tried without success get this query:
https://www.wikidata.org/w/api.php?action=wbsearchentities&search=arturo&format=json&language=en&uselang=en&type=item
but only with elements from instance "human of", that means from P31 : Q5
Any help will be preciated because I can't find a way to set up those props.
This kind of query explodes in SPARQL but if someone has a relative answer to get the same result (search for all people with his name start with....) will be preciated too.
I'm really not sure that's possible with the Mediawiki API. It was not possible a few years ago and I don't think the feature has been implemented since then.
But Open Refine has a reconciliation service with Wikidata based on an API that can filter by type ("instance of") or property. Its developer has not yet advertised it explicitly as a standalone API, but this is in project. Here is an example of use: find in Wikidata the people called "arturo" instances of human (Q5) and whose occupation (P106) is actor (Q33999).
https://tools.wmflabs.org/openrefine-wikidata/en/api?query={
"query":"arturo",
"limit":6,
"type" : "Q5",
"properties" : [
{ "pid" : "P106" , "v" : "Q33999"}
]
}
Result.
The main problem with this query is it will only return Arturos which are explicitly an instance of Q5. This will be the case of this one, but not of those who are, for example, only instance of "film maker" (and it does not matter that film maker is himself a subclass of "human"). Sparql can handle class transitivity using the property paths (eg : wdt:P279*/wdt:P31*), but this API has not (yet) implemented them.
Hi i have made an ontology in protege 4.3 for users , suppose 1 of my ontology subclass of class user are:
1-"Interest" , and class "interest" have subclasses: "onlineGaming","onlineMovie","onlineshoping",... and every subclass has individual: everyday,onceAweek,onceAmonth)
and i have 3 datatype property for every user: (internetspeed,internetTraffic,Price)
data gathered based on a questionnaire
i just need to infer from this ontology how important this 3 datatype property factors is for internet users
i need to make some SWRL rules in protege to Infer user interest weight , for example if a user do onlineMovie everyday add a +3 to internetTraffic dataproperty.
user(?u) ^ hasOnlineMovieInterest(?u , everyday)-> add +3 to user(?u,InternetTraffic)
user(?u) ^ hasOnlineGamingInterest(?u , OnceAweek) and hasOnlineMovieInterest(?u , everyday)-> add +2 to user(?u,internetSpeed)
how should i write this properly in SWRL rules?
and my second question is how can i have the value of this 3 datatype property for every user in sparql and save the result?
Thanks for your help
First of all; it is not clear what you are doing / which technology using, etc., please consider clarifying your question. Moreover, the conceptual made you developed doesn't seem sound. Are you sure this is the best way to represent the information you want? For example, why would a UserInterest be a subClassOf User? I think you mean that UserInterest and UserInterestRate are ranges for an object property that connect User to them, i.e., hasInterest rdfs:domain User and hasInterest rdfs:range UserInterest.
Coming to your questions, do you use Protege? If you use it you can implement these SWRL rules using the SWRL tab in Protege.
After you have implemented this correctly, you can simply use some SPARQL query similar to:
select ?user ?r1 ?r2 ?r3 Where {
?user rdf:type yourNamespacePrefix:User.
?user yourNamespacePrefix:rate1 ?r1.
?user yourNamespacePrefix:rate2 ?r2.
?user yourNamespacePrefix:rate3 ?r3.
}
I have an ontology with different type of events.
Therefore I have three classes: A, B, C and a helper class Temp.
I want the reasoner to create a new individual as a subclass of C for every pair of individuals a (rdf:typeOf A) and b (rdf:typeOf B) found. This new Individuals should contain informations about a and b.
In the past I used a jena reasoner with an own rule file to get this result, but now I want to switch over to a standard OWL DL reasoner.
My initial idea is to link a und b such as:
a onto:hasB b
And ad give a the Type Temp with the following restriction for Temp:
hasbB some B
Now I want to create a new individual of type C with a restriction for Temp:
hasC some C
And over this new indivual I can access the informations of a and b.
My Problems are:
How can I get the reasoner to connect a and b?
I don't think the creation of C will work, since its a restriction for Temp, which will never be assigned as a type because of this restriction.
Or am I completly wrong with my approach?
Edit:
To clarify my goal with a better exmple:
I have an ontology with different type of events.
My goal is to connect certain individuals (events) which belong together by forming a new individual (event) describing this relation with the help of a reasoner.
E.g.:
I read an event (individual) which describes an "Alarm" (type) into the ontology.
I read an event (individual) which discribes a "PowerOutage" (type) into the ontology.
These Individuals aren't related at all at this moment.
Now I want a reasoner to create a new event (individual) with the type "PowerManipulation". In fact I want an individual with the type "PowerManipulation" created for every pair (which isn't connected, yet) of individuals with the type "PowerOutage" and "Alarm" found. These new individuals should have references (properties) to the individual which caused their creation (an "Alarm" and a "PowerOutage").
Ontology before the reasoning:
(alarm1 rdf:type "Alarm")
(out1 rdf:type "PowerOutage")
What I want the ontology to look like after the reasoning
(alarm1 rdf:type "Alarm")
(out1 rdf:type "PowerOutage")
(man1 rdf:type "PowerManipulation")
(man1 ont:hasRealtadInd alarm1)
(man1 ont:hasRealtedInd out1)
Priviously I used Jena rules and the Jena reasoner to accomplish this task.
But I want to switch over to a standard OWL DL reasoner.
Is it possible to accomplish this task with basic restrictions?
Or do I need SWRL rules, or SPIN (see Williams answer below)?
You can do this with SPIN constructors quite easily and SPIN inserts.
http://www.w3.org/Submission/2011/SUBM-spin-modeling-20110222/#spin-rules-construct
http://www.w3.org/Submission/2011/SUBM-spin-modeling-20110222/#spin-rules-update
SPIN and OWL can live happily together. Take a look at the groovy library that has extensions for both:
https://github.com/williamgreenly/lescot
Example below:
def model = new GroovyRdfModel()
model.add(""" some turtle data """)
model.add(""" some OWL rules """)
model.add(""" some SPIN rules """)
def inferredModelByOWLReasoning = model.owl()
def inferredModelBySPINRules = model.spin()
I'm trying to figure out how to make some queries through which I should get fashion related content, like an list of known cloth types, or cloth manufactures, or well known fashion designers.
I have spent the last few days trying to figure out to make such an query through DBpedia or Freebase, but I couldn't seem to figure it out. Examples that kinda match what I need I couldn't find...
Can someone help me with this, some short example on which I can start to work on or some tutorials that explain how can I achieve something like this?
Thank you
Later Edit
I have also found that DBpedia contains an ontology property "dressCode" and I've found these pages: http://en.wikipedia.org/wiki/Dress_code_(Western) and http://en.wikipedia.org/wiki/Dress_code which lists some basic dress codes, like "Formal", "Casual"...
Now my idea is to get properties from each one of these sub-categories (or what they are defined as on DBpedia, as I see they differ from one other).
Any suggestion on how to do this ?
Later Edit
I have managed to make some queries to display some information that could actually help me:
SPARQL - list of social events
SELECT DISTINCT (?label as ?sub)
WHERE {
{
?sub skos:broader <http://dbpedia.org/resource/Category:Social_events> .
?sub rdfs:label ?label.
OPTIONAL {?subsub dcterms:subject ?sub}
}
}
SPARQL - list of dress codes
SELECT DISTINCT (?label as ?dressCode)
WHERE {
{
?dressCode dcterms:subject <http://dbpedia.org/resource/Category:Dress_codes> .
?dressCode rdfs:label ?label.
filter(langMatches(lang(?label),"EN"))
}
}
Now I would like to retrieve the "subject of" for each dress code so that I can connect somehow the dress codes to the social events, but I'm having issues to do that.
Later Edit
I got to the conclusion that I can't find an ontology that actually matches my needs. Basically I need to get cloth properties based on event types so I can make cloth recommendations. Except the restrictions from the event types I also want to add other properties like the current fashion trend, the season in which the event will take place, geo-location (if possible), and other small details like these.
Now I'm trying to use existing ontologies and data that exists on DBpedia & Freebase, like: 'Dress code', 'Event type', 'Colors', 'Fashion designer', 'Fabric', 'Texture', 'Manufacturer', 'Size' and combine them into an ontology which I can actually use in my project to actually make cloth recommendations.
Can anyone help me with some guidelines on how I can do this ? I tried to use Protege to combine some ontologies and extend them after that, but finally I failed to do this.
May be one of the first places you can start with is the DBpedia ontology. When I search for keywords like Fashion, I can see that there are classes like FashionDesigner. So I can check about about the information about fashion designers in DPpedia with a simple SPARQL query like the following using the DPpedia public SPARQL endpoint.
(a) a list of fashion designers:
select distinct ?fashionDesigner
where {
?fashionDesigner a dbpedia-owl:FashionDesigner
}
LIMIT 100
(b) what are the information generally available about a fashion designer
select distinct ?property
where {
?fashionDesigner a dbpedia-owl:FashionDesigner;
?property ?value .
}
I can also select one of the results of query (a) such as Donna Karan take a look what kind of information she has.
So now, my task is to see who the well-known fashion designers. I don't know much about fashion but I see some of them have awards. So I can query for the fashion designers who have won awards.
(c) Fashion designers who have won awards
select distinct ?fashionDesigner ?award
where {
?fashionDesigner a dbpedia-owl:FashionDesigner;
dbpprop:awards ?award .
}
I was only using very basic SPARQL queries but you can use more complex queries when you get to know more about the fashion related concepts and properties in the data.
You can follow a similar approach for classes such as LineOfFashion, Clothing, etc.
For example
(d) a list of clothing manufactures
select distinct ?company where {
?company dbpedia-owl:product dbpedia:Clothing;
dcterms:subject category:Clothing_brands .
} LIMIT 100
The more you explore, you can build better queries. I hope this will help you to get started.
Here's a query that returns award winning fashion designers from Freebase: https://www.googleapis.com/freebase/v1/search?limit=10&scoring=entity&filter=(all+type%3A%2Faward%2Faward_winner+notable%3A%22fashion+designer%22)&lang=en&indent=true
There's a little on-line utility that you can use to experiment with this and check out some of the other items that you were interested in:
http://freebase-search.freebaseapps.com/?filter=(all+type%3A%2Faward%2Faward_winner+notable%3A%22fashion+designer%22)&limit=10&scoring=entity&lang=en