Download live DBPedia on “is [property] of”? - dbpedia

I want to download all the properties of an entity in the http://pl.dbpedia.org/page/, but when I choose the RDF (N-triple) to download the raw data about an entity, I found that the "is [property] of" properties missing, so how can I get all the properties including the "is [property] of"? Thanks!
For Example, I want to get the raw data(N-triple) of http://pl.dbpedia.org/page/Robin_Wright. How can I get the "is starring of" property?

"is [property] of" is a presentation of inverse relationships.
{ <http://pl.dbpedia.org/resource/Robin_Wright> is ?property of ?subject }
-- corresponds to --
{ ?subject ?property <http://pl.dbpedia.org/resource/Robin_Wright> }
You can get these with SPARQL queries like this, which will include all triples with that entity as object --
SELECT ?s ?p
WHERE
{ ?s ?p <http://pl.dbpedia.org/resource/Robin_Wright> }
-- or this, which will include all triples with that entity as subject and as object --
DESCRIBE <http://pl.dbpedia.org/resource/Robin_Wright>

Related

ArangoDB populate relation as field over graph query

I recently started using Arango since I want to make use of the advantages of graph databases. However, I'm not yet sure what's the most elegant and efficient approach to query an item from a document collection and applying fields to it that are part of a relation.
I'm used to make use of population or joins in SQL and NoSQL databases, but I'm not sure how it works here.
I created a document collection called posts. For example, this is a post:
{
"title": "Foo",
"content": "Bar"
}
And I also have a document collection called tags. A post can have any amount of tags, and my goal is to fetch either all or specific posts, but with their tags included, so for example this as my returning query result:
{
"title": "Foo",
"content": "Bar",
"tags": ["tag1", "tag2"]
}
I tried creating those two document collections and an edge collection post-tags-relation where I added an item for each tag from the post to the tag. I also created a graph, although I'm not yet sure what the vertex field is used for.
My query looked like this
FOR v, e, p IN 1..2 OUTBOUND 'posts/testPost' GRAPH post-tags-relation RETURN v
And it did give me the tag, but my goal is to fetch a post and include the tags in the same document...The path vertices do contain all tags and the post, but in separate arrays, which is not nice and easy to use (and probably not the right way). I'm probably missing something important here. Hopefully someone can help.
You're really close - it looks like your query to get the tags is correct. Now, just add a bit to return the source document:
FOR post IN posts
FILTER post._key == 'testPost'
LET tags = (
FOR v IN 1..2 OUTBOUND post
GRAPH post-tags-relation
RETURN v.value
)
RETURN MERGE(
post,
{ tags }
)
Or, if you want to skip the FOR/FILTER process:
LET post = DOCUMENT('posts/testPost')
LET tags = (
FOR v IN 1..2 OUTBOUND post
GRAPH post-tags-relation
RETURN v.value
)
RETURN MERGE(
post,
{ tags }
)
As for graph definition, there are three required fields:
edge definitions (an edge collection)
from collections (where your edges come from)
to collections (where your edges point to)
The non-obvious vertex collections field is there to allow you to include a set of vertex-only documents in your graph. When these documents are searched and how they're filtered remains a mystery to me. Personally, I've never used this feature (my data has always been connected) so I can't say when it would be valuable, but someone thought it was important to include.

Retrieve OptionSet from Dynamics Web API MetaData

I'm trying to retrieve the option set values (localized labels and integer Ids) for a specific field on a specific entity. Below is the code that I am using, but every time I execute it, it brings back ALL optionsets that are currently in my system (about 800+) and I don't want to do that.
EntityDefinitions(LogicalName='#MY_ENTITY#')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$filter=LogicalName eq '#MY_ENTITY_ATTRIBUTE#'&$expand=OptionSet
maybe this can help,
/api/data/v9.1/ENTITY(guid OR Filter)?$select=ATTRIBUTE1,ATTRIBUTE2
include header:
{
"Prefer": "odata.include-annotations=OData.Community.Display.V1.FormattedValue"
}
this gives us a response like this:
{
"ATTRIBUTE1#OData.Community.Display.V1.FormattedValue": "Person",
"ATTRIBUTE1": 1,
"ATTRIBUTE2#OData.Community.Display.V1.FormattedValue": "Company",
"ATTRIBUTE2": 2
}
I'm using the stringmap entity to retrieve the optionsets.
This represents the optionsets as a simple table on which you can filter in the query
For example by calling:
/stringmaps?$filter=(objecttypecode eq 'contacts')
you get only the optionsets which are use in the contact entity. You can also filter on attribute name, the option value (field value) or option id (field attributevalue).

How to set two parameters in one input-view file

I want to set two parameters in one capsule's inuput-view file. What should I do?
In my capsule, there has a function which need two parameters and these two parameters is required. When user say one case, if this case doesn't including these two parameters, bixby will hints user input these two parameters. In the previous version I created two input-view file and one input-view file including one parameter, but now I want to set these two parameters in one input-view file, so what should I do?
In action file:
input-group(ContactAndText){
requred(OneOrMoreOf)
collect{
input(contact){
type(Contact)
min(required)
max(one)
}
input(text){
type(Text)
min(required)
max(one)
}
}
}
In input-view file: I do not know what should I do?
In action file I set a input-group(ContactAndText), this input-group including these two parameters(contact and text), but I do not know what should I do in input-view file.
I don't think having an input view for two separate objects/structures will work, however having an input view for your input-group might work. I believe can use the match pattern match: [action name]~[input-group name] (match: action~ContactAndText) to match the input-group specifically.
If this doesn't work, I would recommend either using two separate input views, one for contact and one for text, or you could create a new structure ContactAndText: make it extend Contact and make it have a text property. Then, you can have the input view match the ContactAndText structure.
An easier solution:
Add a new structure
structure (ContactAndName) {
description (a structure to hold both)
property (contact) {
type (Contact)
min (Required) max (One)
}
property (text) {
type (Text)
min (Required) max (One)
}
}
In action model
input(contactAndText) {
type (ContactAndText)
min(Required) max(One)
}
You can then implement a view with match: ContactAndName

loopback relational database hasManyThrough pivot table

I seem to be stuck on a classic ORM issue and don't know really how to handle it, so at this point any help is welcome.
Is there a way to get the pivot table on a hasManyThrough query? Better yet, apply some filter or sort to it. A typical example
Table products
id,title
Table categories
id,title
table products_categories
productsId, categoriesId, orderBy, main
So, in the above scenario, say you want to get all categories of product X that are (main = true) or you want to sort the the product categories by orderBy.
What happens now is a first SELECT on products to get the product data, a second SELECT on products_categories to get the categoriesId and a final SELECT on categories to get the actual categories. Ideally, filters and sort should be applied to the 2nd SELECT like
SELECT `id`,`productsId`,`categoriesId`,`orderBy`,`main` FROM `products_categories` WHERE `productsId` IN (180) WHERE main = 1 ORDER BY `orderBy` DESC
Another typical example would be wanting to order the product images based on the order the user wants them to
so you would have a products_images table
id,image,productsID,orderBy
and you would want to
SELECT from products_images WHERE productsId In (180) ORDER BY orderBy ASC
Is that even possible?
EDIT : Here is the relationship needed for an intermediate table to get what I need based on my schema.
Products.hasMany(Images,
{
as: "Images",
"foreignKey": "productsId",
"through": ProductsImagesItems,
scope: function (inst, filter) {
return {active: 1};
}
});
Thing is the scope function is giving me access to the final result and not to the intermediate table.
I am not sure to fully understand your problem(s), but for sure you need to move away from the table concept and express your problem in terms of Models and Relations.
The way I see it, you have two models Product(properties: title) and Category (properties: main).
Then, you can have relations between the two, potentially
Product belongsTo Category
Category hasMany Product
This means a product will belong to a single category, while a category may contain many products. There are other relations available
Then, using the generated REST API, you can filter GET requests to get items in function of their properties (like main in your case), or use custom GET requests (automatically generated when you add relations) to get for instance all products belonging to a specific category.
Does this helps ?
Based on what you have here I'd probably recommend using the scope option when defining the relationship. The LoopBack docs show a very similar example of the "product - category" scenario:
Product.hasMany(Category, {
as: 'categories',
scope: function(instance, filter) {
return { type: instance.type };
}
});
In the example above, instance is a category that is being matched, and each product would have a new categories property that would contain the matching Category entities for that Product. Note that this does not follow your exact data scheme, so you may need to play around with it. Also, I think your API query would have to specify that you want the categories related data loaded (those are not included by default):
/api/Products/13?filter{"include":["categories"]}
I suggest you define a custom / remote method in Product.js that does the work for you.
Product.getCategories(_productId){
// if you are taking product title as param instead of _productId,
// you will first need to find product ID
// then execute a find query on products_categories with
// 1. where filter to get only main categoris and productId = _productId
// 2. include filter to include product and category objects
// 3. orderBy filter to sort items based on orderBy column
// now you will get an array of products_categories.
// Each item / object in the array will have nested objects of Product and Category.
}

How do you query OWL Annotations

I am searching for the method/tool/syntax to query annotations in an RDF/OWL ontology.
The query engines I have found search classes, properties, individuals, but I have not found one that will search based on the value for example DC:Description
With SPARQL, you should be able to query annotations via the properties you're interested in, for example:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?x ?desc {
?x dc:description ?desc .
}
This method could also be used to retrieve all instances with a particular annotation value, such as:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?x {
?x dc:description "some description string" .
}
Or, you could even try to match based on some REGEX:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?x {
?x dc:description ?desc .
FILTER REGEX(STR(?desc), "^Some regex") .
}
If you are after a programmtic tool and the ontology is OWL you can use the Manchester OWL API:
OWLClass classA = factory.getOWLClass(IRI.create("http://your/url/here#ClassA"));
OWLAnnotationProperty dcProperty = factory.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/description"));
for (OWLAnnotation annotation : classA.getAnnotations(ontology, dcProperty)) {
OWLLiteral literal = (OWLLiteral) annotation.getValue();
String literalString = literal.getLiteral()
}
That will get you the value of that particular property. "factory" here is an instance of OWLDataFactory.
Hope that helps a little!

Resources