WIKIDATA property and value inheritance in "instance of" relation - wikidata

If X is instance of Y can I say that the properties=value of Y are also properties of X and assign X also the properties=value of the subclasses of Y?
For example, I know that "Futbol Club Barcelona" is instance of "association football club" but I don't know which sport "Barcelona" plays while this is declared among the properties of "association football club" (sport=football). So can I associate the properties/values of "association football club" with "Futbol Club Barcelona" and say that "Futbol Club Barcelona" sport=football?

Yes, generally properties are implied for an instance (P31) or subclass (P279). But there might be properties that are specific to the parent-items (like IDs or something like "has list": "list of association football clubs") that are not that usefull for a child-item. Also, although it's implied, query languages like SPARQL don't respect these inheritances.

Related

How to capture the multiple values of one entity in IBM watson assistant after asking slot?

In my Watson Assistant app, I want to capture the multiple entities in the context and also have a slot to ask a question to user. Here is an example:
User: I want to fly from Toronto to Boston
And the Watson correctly detects:
intent: 'booking', #city:'Toronto', #city:'Boston'
Now I have a slot which asks for booking class:
Watson(Slot): Which class would you like?
User: Economy
At this point, the context only have first value for the #city entity i.e. Toronto. I understand from my googling that I can access #city[0] and #city1. And I tried to capture it in the context by doing the following but the value I'm getting is None.
How can I correctly capture both cities #city:Toronto, #city:Boston and at the same time entity #class:economy ?
The slots are smart - when there are multiple entities of the same type and more slots that match the entity of the same type then when a slot matches the first entity it will be "eaten" and not available for other slot - hence the next slot matching the same entity type will match any other entity of the same type. To achieve what you want to do simply define the slots in a following way (so both of them match simply the #city entity).
Revisiting this as there has been changes to Watson Assistant to make this easier.
1. Create two Entities. #fromCity and toCity.
2. Fill each entity with the same values. Names of locations.
3. Create your intent with questions like below.
I want to fly from Toronto to Boston
I have to get to Boston from Toronto ASAP.
I want to get a flight to New York
I'm in Texas and need to fly to San Diego
4. On the intents page select each city and flag them as either the #fromCity or #toCity. This creates contextual entities.
Now when it trains it will understand the entities in the context of the sentence. It will also understand locations you have not trained it on.
More detailed example here.
I'm replying here not only for you, but also for myself, since I have had this question a couple times. This is how I've handled it.
You can use SPEL, the expression language for watson to map all the literal values that match an entity and put them into a context variable like so inside the json configuration:
"context": {
"ReferenceNumber": "#ReferenceNumber.literal",
"ReferenceNumbersRunAdd": "<?$ReferenceNumbersMultiple.addAll(entities['ReferenceNumber'].![literal]) ?>"
}

How do I read the association between Vehicle and Owner in this uml diagram?

Is this saying "A Vehicle is associated with 1 Owner" - OR - does it say "A vehicle is associated with many Owners"?
Exactly. The multiplicity and roles are located to the opposite of the class. So it's "a vehicle has one owner and an owner can have multiple vehicles".

How to classify Wikidata items?

I am trying to classify items into the main categories supported by Wikidata:
Generic, Person, Organization, Events, Works, Terms, Place, Others.
These categories are listed here:
https://www.wikidata.org/wiki/Wikidata:List_of_properties
I could not find a property that specifies the main category. I looked into
the P31 "instance of" property and P279 "subclass of" but they are not what I need.
For example for "IBM" the P31 returns "public company" and "software house" and for "Swiss International Air Lines" it returns "airline".
So I cannot tell that they are both organizations.
Is there a way to do this?
One option would be to check the properties of an item, so
if an item has the P21 "sex or gender" then it's a human (or animal).
But I don't think that is stable since no property is mandatory.
I'm using the Wikidata Toolkit for my queries.
Wikidata used to have a main type property but it was deleted in favour of instance of and a more flexible schema.
You can see lots of archived discussion about the main type at https://www.wikidata.org/wiki/Property_talk:P107
You probably want to take a look at the SPARQL endpoint at http://query.wikidata.org
Q4830453 is business enterprise / company.
To find all items that are a company or a subclass of company just do:
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT DISTINCT ?item
WHERE {
?item wdt:P31/wdt:P279* wd:Q4830453
}
The query takes a little time, there are currently 150k results.

How to do Exclusion Queries in OrientDB

I'm wondering if it's possible to use a sub-selection as an exclusion query in orient db (v2.0). Or if it's necessary to export separate queries and process in Java/PHP/etc.
For instance, say we have the following graph for Hogwarts.
Vertices
People, Houses, Classes
Edges
is_at (subclasses is_student, is_faculty), was_at (alumni), is_taking, is_teaching, belongs_to
How would we find all the alumni who aren't also faculty? Is it possible to do so as a single query or using LET somehow?
How would we find all the faculty who are teaching a course on, say, time travel, that have no students who belong to the house gryffindor?
Thanks,
Lindsay
The .size() operator should work: http://orientdb.com/docs/2.0/orientdb.wiki/SQL-Methods.html#size
select from People where out('is_faculty').size() = 0
Use out('...') or in('...') based on your graph.
How would we find all the faculty you are teaching a course on, say, time travel, that have no students who belong to the house gryffindor?
I don't have much information on your graph and classes, but that could be something like:
select from Classes where ClassName='time travel' and in('is_teaching')[Id=yourId] and in('is_taking').out('belongs_to')[Name='gryffindor'].size() = 0
Again, use in() or out() accordingly to your graph.

How to extract Companies per country from Freebase

I am new to Freebase. I am trying to extract all companies per country (The Head Quarter's country). The simplest approach I thought was to list them all and filter by country such as this test
[{
"name": null,
"type": "/organization/organization",
"/location/location/containedby": "Japan",
"limit": 4
}]
The problem is that I get schools as well. It is not very clear unlike DBpedia that has a class called "Company", how one can find distinguish the companies in Freebase while there is no clear type for it? I thought the organization/organization domain will do but it is too general also there is Business domain.
Why not use /business/business_operation or /business/consumer_company or some other more appropriate type if /organization/organization is too broad?
A bigger issue with your query is that it is only going to find entities contained directly in Japan, not those contained in all locations contained by Japan (e.g. prefectures, cities, etc). You may want to investigate using the Freebase Search API instead of MQL since I think it will compute the closure for you (or do radius searches). Alternatively, you'll probably need to run a few variations of you query with different levels of location nesting.
Here are some example search queries/filters:
https://developers.google.com/freebase/v1/search-output
restaurants near SF Ferry building - filter=(all type:restaurant (within radius:1000ft lon:-122.39 lat:37.7955))
https://developers.google.com/freebase/v1/search-cookbook
Japanese volcanos - filter: (all category:volcano (any part_of:japan))

Resources