How to query individuals in DL Manchester OWL Syntax? - uri

I know this sounds like a very stupid question, but I've been trying to figure this out and I can't find anything on this, though it seems obvious that this should be doable.
I'm developing something that queries an OWL file through its API using the Manchester OWL Syntax and a HermiT reasoner. I alternatively also run queries on the DL Query tab in Protege 4 to check my query results on that file. The file is basically the Friend Of A Friend (FOAF) ontology with added data instances.
The problem: I can't find a way to query an instance by its unique identifier.
It's supposed to be the URI so e.g. for a Person object with URI http://xmlns.com/foaf/0.1/Andrew_Kuchling, I tried to run the following queries:
Person and URI value "http://xmlns.com/foaf/0.1/Andrew_Kuchling"
Person value "http://xmlns.com/foaf/0.1/Andrew_Kuchling"
Person and URI value "Andrew_Kuchling"
Person that "Andrew_Kuchling"
none of these work. (The URI is constructed by prefixing http://xmlns.com/foaf/0.1/ to whatever string you enter and URI is not actually identified in the ontology as a property).
In FOAF, mbox_sha1sum is the sha1sum of a mailbox. Mailboxes are uniquely connected to individuals. So I tried the following query:
Person and mbox_sha1sum value "mbox_sha1sum-property-value-here"
However, it doesn't even execute this query because it feels the query is incorrect. The mbox_sha1sum value is the same that I've added for this Person. It exists in Individuals.
It does execute this query:
Person and firstName value "Andrew"
All data properties are not specialised data types. Treated as literals by default.
I really don't know what I'm doing wrong. Can someone please please help?

I know this question has been posted more than a year ago, but I recently asked me the same question and found the following solution:
Just put the name of the individual/member you want to query for in curly brackets:
{MyIndividualEntityName}
This way you can even query for more than one individual at a time:
{IndividualName1,IndividualName2}
Please note that these queries form class expressions of so called enumarated classes. This means, that the result of this query will not simply be a list of all super or sub classes of all the individuals you have named in your query. Instead it refers to an anonymous class that consists of exactly the individuals you have listed.
An anonymous class is a class that isn't available from outside of your ontology, because there is no referrable owl entity for this class (no IRI to refer to).
You can find more information on the OWL Manchester Syntax in the offcial W3C specification.

Related

XML for Analysis (XML/A) format of member names?

I have two different XML/A providers, Mondrian and icCube. The tuples for a time dimension contain the unique name for the member, but the format of the member name is different:
Mondrian:
<UName>[Time].[2004].[QTR2].[Apr]</UName>
<Caption>Apr</Caption>
[Time] is the name of the hierarchy
[2004] is the name of the ancestor at the Year level
[QTR2] is the name of the ancestor at the Quarter level
[Apr] is the local name of the member at the Month level
icCube:
<UName>[Time].[Calendar].[Month].&[Jun 2010]</UName>
<Caption>Jun 2010</Caption>
[Time] is the name of the dimension
[Calendar] is the the name of the
hierarchy
[Month] is the name of the level
[Jun 2010] is the name of
the month member.
(I don't know why the ampersands are there)
My question is, is there any recommended, preferably standard way to figure out how the member names are formatted?
The reason I want to know this is when I render the result in a Pivot table, the captions for the members will usually end up as labels on the headers of the pivot table. But since the captions may not be unique, it is desirable to also produce labels of the "ancestor" members, because together they do identify the member uniquely.
In my example, I could use the parts of the member unique name to do this, but in ic cube not,since the member u name is structured differently.
I have 2 questions:
1) How can I tell beforehand what format the XML/A provider will use to identify the members?
2) What would be the recommended way in ic cube to produce the labels for the ancestor members?
UPDATE:
Luc Boudreau informed me that the ampersand indicates "key notation" - it designates the member key rather than its name. Thanks Luc!
The meaning of unique names in MDX is a string that guarantees that it defines a unique MDX entity when parsed. There is no possible collision with another MDX entity. The way to write it depends on the XMLA provider. Even though it's 'unique' there are multiple ways creating it, each server chooses its way.
Never mind, a query written in one server will work in another as both 'unique' names are correctly parsed.
& amp; stands for &
Our advise, the client code should not rely on the format of the unique names.
That being said, if you need parent "names", you should retrieve them explicitly using the "Parent" function and/or as a calculated measure retrieving the name/caption property.
Hope that helps.

Adding a new user to neo4j

A totally neo4j noob is talking here,
I like to create a graph to store a set of users, a typical user is as follows:
CREATE
(node_1 {FullName:"Peter Parker",FirstName:"peter",FamilyName:"parker"}),
(node_2 {Address:"Newyork",CountryCode:"US"}),
(node_3 {Location:"Hidden"}),
(node_4 {phoneNumber:11111}),
(node_5 {InternetEmailAddress:"peter#peterland.com")
now the problem is,
Every time I execute this I add 5 more nodes.
I know I need to use a unique key, but all example I saw can use a unique key for a specific node. So how can I make sure a user doesn't get added if it already exists(I can use email address as unique key).
how do I update the nodes if some changes occur. for example, after a week I want to update the graph to contain the following instead of the previous one.(no duplicates)
CREATE(node_1 {FullName:"Peter Parker",FirstName:"peter",FamilyName:"parker"}),(node_2 {Address:"Newyork",CountryCode:"US"}),(node_3 {Location:"public"}),(node_4 {phoneNumber:11111}),(node_5 {InternetEmailAddress:"peter#peterland.com"),(node_6 {status:"Jailed"})
(NOTE the new update changed location to "public" and added a new node for peter
Seeing as you had a load of nodes anyway.
Some of the data you have modelled as Nodes are probably properties as the other answer suggests, some are possibly correctly modelled as Nodes and one could probably form the or a part of the relationship.
Location public/hidden can be modelled in one of three ways, as a property on the Person, as a property between the Person and the Location or as the relationship type. To understand that first you need to have a relationship.
Your address at the moment is another Node, I think this is correct, but possibly you would want two nodes, related something like this:
(s:State)-[:IN_COUNTRY]-(c:Country)
YMMV and clearly that a US centric model, but you can extend it easilly enough.
Now you could create Peter with a LIVES_IN relationship:
CREATE (p:Person{fullName:"Peter Parker"}), (s:State{name:"New York"}), (c:Country{code:"US"}),
(p)-[:LIVES_IN]->(s), (s)-[:IN_COUNTRY]->(c)
For speed you are better off modelling two relationships which could be LIVES_IN_PUBLIC and LIVES_IN_HIDDEN which means to perform that update that you want above then you have to delete the one and create the other. However, if speed is not of the essence, it is common also to use properties on the relationship.
CREATE (p:Person{fullName:"Peter Parker"}), (s:State{name:"New York"}), (c:Country{code:"US"}),
(p)-[:LIVES_IN{public:false}]->(s), (s)-[:IN_COUNTRY]->(c)
So your complete Q&A:
CREATE (p:Person {fullName:"Peter Parker",firstName:"peter",familyName:"parker", phoneNumber:1111, internetEmailAddress:"peter#peterland.com"}),
(s:State {name:"New York"}), (c:Country {code:"US"}),
(p)-[:LIVES_IN{public:false}]->(s), (s)-[:IN_COUNTRY]-(c)
MATCH (p:Person {internetEmailAddress:"peter#peterland.com"})-[li:LIVES_IN]->()
SET li.public = true, p.status = "jailed"
When adding other People you probably do not want to recreate States and Countries, rather you want to match them, and possibly Merge them, but we'll stick to Create.
MATCH (s:State{name:"New York"})
CREATE (p:Person{name:"John Smith", internetEmailAddress:"john#google.com"})-[:LIVES_IN{public:false}]->(s)
John Smith now implicitly lives in the US too as you can follow the relationship through the State Node.
Treatise complete.
I think you're modeling your data incorrectly here - you're setting up each property of the person as a separate node, which is not a good idea. You don't have any linkages between those nodes, so with this data pattern, later on you won't be able to tell what Peter Parker's address is. You're also not using node labels, which I think could really help here.
The quick question to your answer about updating nodes is that you have to MATCH them, then use SET to modify a property. So if you had a person, you might do this:
MATCH (p:Person { FullName: "Peter Parker" })
SET p.Address = "123 Fake Street"
RETURN p;
But notice I'm making assumptions about the way your data is structured. I'll take that same data you provided, this might be a better way of creating it:
CREATE (node_1:Person {FullName:"Peter Parker",
FirstName:"peter",
FamilyName:"parker",
Address:"Newyork",CountryCode:"US",
Location:"Hidden",
phoneNumber:11111,
InternetEmailAddress:"peter#peterland.com"});
The difference with this suggestion is that I'm putting all the properties into a single node (instead of one property per node) and I'm applying the Person label to the node.
If you structured the data like this, then the update query I provided would work. Structuring the data like you have it, it's not possible to update Peter Parker's address, because there's no relationship between your node_1 and node_2

pro asp.net 4.5 in c# book by adam freeman sportstore

just wondering did anybody complete the sport store application in this book, i am having a problem with the data binding in the orders page for the admin, i want to pull in the product id from the order lines table but i keep getting errors, it working correctly for the quantity but i can seem to get the product id to bind. i have tried the following code but this is not working for me at the moment
**<td><%# Item.OrderLines.Product_ProductID %></td>**
it says i am missing a definition in the orderline
First of all, OrderLines is of type List most likely. So the list doesn't have a definition of Product_ProductID. You should rather make a loop for Item.OrderLines and then you can access each order line of the order with its product. At second, take a look at your OrderLine model. Does it contain Product_ProductID? Most likely it has Product property
references to Product model which contains ProductID. So after all, your code would look like:
**<td><%# Item.OrderLines[i].Product.ProductID %></td>**

DBpedia : Get list of Chinese universities and their adresses to populate google map?

I'm trying to get list of Chinese universities and their adresses. The minimum being the City/Town name. I will use these addresses to populate a googlemap, fiddle here.
I saw interesting code such as:
SELECT ?resource ?value
WHERE {
?resource a <http://dbpedia.org/class/yago/CitiesAndTownsInDenmark> .
?resource <http://dbpedia.org/property/populationTotal> ?value .
FILTER (?value > 100000)
}
ORDER BY ?resource ?value
Since CitiesAndTownsInChina doesn't work,
1. Where to find the exact name of the class I'am targeting ? and
2. Where to find dbpedia's operators manual ?
Note: I'am a very active user on Wikipedia, I'am well aware of all the data available there, but the dbpedia ontology/syntaxe/keywords is quite hard to get.
Personal note: queries on http://dbpedia.org/snorql/ , http://dbpedia.org/sparql/ , http://querybuilder.dbpedia.org/
(Expanding on my reply to How to find cities with more than X population in a certain country)
CitiesAndTownsInDenmark exists because people use the category http://en.wikipedia.org/wiki/Category:Cities_and_towns_in_Denmark in wikipedia. Wikipedia categories are pretty loose and as a result there's a lot of variation in style, so even if a useful category exists the name may not be guessable.
In addition categories are maintained manually, and may not be consistently applied.
A good place to start is looking at the data. Visiting http://dbpedia.org/page/Beijing I see yago:MetropolitanAreasOfChina which seems promising, but if you follow that link you'll see it's not well populated.
As a consequence avoid relying on the existence of such categories and directly querying for populated places in a country. This information comes from wikipedia infoboxes, and they're much more consistent than categories. Taking Beijing as an exemplar again I found:
select ?s {
?s a <http://dbpedia.org/ontology/PopulatedPlace> ;
<http://dbpedia.org/ontology/country> <http://dbpedia.org/resource/China>
}
(The relevant properties and values for my query were found by copying link location in the Beijing page)
with the result:
"http://dbpedia.org/resource/Hulunbuir"
"http://dbpedia.org/resource/Guangzhou"
"http://dbpedia.org/resource/Chongqing"
"http://dbpedia.org/resource/Kuqa_County"
"http://dbpedia.org/resource/Changzhou"
... nearly 3000 results ...
You'll notice that position is encoded multiple times (geo:lat and long, georss:point, various dbpprop:latd longd things), and there seem to be two values excitingly. You can either simply deal with the multiple values in whichever format you prefer, or try picking just one using GROUP BY and SAMPLE.
As for a manual, almost everything I know of are academic papers, and not very useful. However the data is reasonably self documenting.
for your first question:
you can see possible classes by querying one member of your intended set of entities (ex: Shanghai).
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?type WHERE {
<http://dbpedia.org/resource/Shanghai> rdf:type ?type.
FILTER regex(str(?type), ".*China", "i").
} LIMIT 100
which gives this result:
dbpedia:class/yago/MetropolitanAreasOfChina [http]
dbpedia:class/yago/PortCitiesAndTownsInChina [http]
dbpedia:class/yago/MunicipalitiesOfThePeople'sRepuBlicOfChina [http]
dbpedia:class/yago/PopulatedCoastalPlacesInChina [http]
they are CamelCase versions of the categories that you will find at the bottom of wikipedia pages. I was fooled for a while by the erroneous capitalization of RepuBlic and finally saw that it contains only 4 cities, so it is of limited use for you.
so I would propose to go with #user205512 answer and get the cities by linking 2 properties.
for your second question:
I would advice you to search/ask on http://answers.semanticweb.com

Using / in query strings

I am trying to use query strings in ASP.NET. I have a requirement of the following format
http://localhost/website/1/?callback=?
Here 1 denotes the ID of the profile. This means some info from id=1 will be fetched through the string
If this would have been website/2/?callback=? , then the id would be 2. My questions is to how do I use this /id/ as a query string so it can be used to fetch the profile ID. This was my first preference to use /id/ format otherwise I could look into fetching using two ?'s
If the id =1, I want to fetch ID=1 particulars from DB on this page. http://localhost/website/1/?callback=?
In your case the ID is in the PATH, not the query string. You can access the path via Request.Path in an ASPX page. From there you would need to do some string parsing to get at the portion of the path where you expect the ID to be.
In your case I would probably use something like int.Parse(Request.Path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries)[1]), but please note that I've made that line pretty dense for brevity's sake. For starters, you should use int.TryParse() instead of int.Parse(). This code assumes that the ID will always be in the same place in the url. For example, it will work for "/website/2/" and "/user/2/", but not for "/website/somethingelse/2/".
UriTemplate might be a good choice for that sort of parsing. Not to mention, probably a bit more clear and explicit about what's happening.
Check out: http://msdn.microsoft.com/en-us/library/system.uritemplate(v=VS.90).aspx

Resources