D:\Setups\Stardog\stardog-5.2.3\opennlp folder has the following nlp models:
en-ner-person.bin
en-sent.bin
en-token.bin
Following is the output of the the query “select * where { graph ?g { ?s ?p ?o }}” when run on database testDB1:
g
Sort
s
Sort
p
Sort
o
Sort
stardog:docs:testDB1:article1.txt stardog:docs:testDB1:article1.txt rdf:type stardog:docs:Document
stardog:docs:testDB1:article1.txt stardog:docs:testDB1:article1.txt rdf:type owl:Thing
That last query returns all the data in the database and, as you can see, there is nothing there besides simple metadata about the document itself.
The issue here is that the en-ner-person model doesn't recognise any of the two names in your example (it's specialized in english names). We provide other more general person-identification models, e.g., built from dbpedia, but can't guarantee that they will work with most non-english names, since they are trained with english language texts.
Models for other languages and domains are easy to learn, and I can provide some pointers if needed.
I would recommend changing the content of your example for now, and execute that select * query again, you'll get an idea on what kind of information is being extracted.
As you can see in the results of the select * query, there is no :Navratan object in the database, therefore the PATHS query won’t be able to return any results.
I’m not sure what are you trying to achieve with the paths query, specifically because entities are leaf nodes in the graph. If you want to simply find which entities are present in the same document, a select query like this will work:
I want to see the relationships between various entities in my data, so that’s why was trying to do that with the help of path query. Can you suggest how can I check relationship between entities extracted from my text?
The only relationship you can extract is that two entities are in the same document, which is what the query I previously shared does.
If you wanted to automatically extract semantic relationships from your text, such as A knows B and A works at ABC, that task is called relation extraction, and is something that we don't support at the moment.
Your only option here would be to implement a custom extractor with the logic to extract such relationships.
If your data is structured as triples, you have a graph, and therefore can write all kinds of queries to find relationships between entities, including path queries.
Not sure if I understand correctly, but shouldn’t you do entity linking before you can use the mentioned entities in the knowledge graph? Entity extraction is just finding parts of the text that denote entities like persons, places, etc.
Once you did this, a SPARQL like
SELECT ?e1 ?p ?e2 {
?e1 ?p ?e2 .
}
is all you need, clearly you have to might need to get the entities itself from a particular graph
Basically we are looking to find relationship like A knows B and B works for organization XYZ within both structured and unstructured data. So for ex - if we have added only following ttl file within Stardog DB and want to find the above mentioned relationship then what will be query for same -
and also, if we have uploaded only following Article file and want to find out relationship between George Clooney and Matt Charman. Please provide complete example query and example for same
We are stuck on these points, So, if you can provide complete example and queries to achieve same for both structured and unstructured data then it will be really helpful.
To retrieve relationships from person_movie.ttl you will first have to describe the relationships you’re looking to find. If you’re looking for explicit relationships such as :actor, :author, :director, you can just write a SPARQL query:
SELECT ?title WHERE {
?tom a :Person ;
rdfs:label "Tom Hanks" .
?movie :actor ?tom ;
rdfs:label ?title
}
ORDER BY ?title
If, however, you’re looking to infer a relationship, you need to define it so the reasoner can find them. For example if I wanted to define :20sActor as an actor who starred in a 1920’s movie, I can do that with a rule:
IF {
?movie :actor ?actor ;
:copyrightYear ?year .
FILTER(?year >= 1920 && ?year < 1930)
}
THEN {
?actor a :20sActor
}
Once that rule was inserted into the DB, I can query (with reasoning) to find instances of :20sActors without that data needing to be stored explicitly in my DB:
SELECT ?name WHERE {
?actor a :20sActor ;
rdfs:label ?name
}
ORDER BY ?name
As for the unstructured data, you will need to do as Pedro suggested and get/use/create extractors that can retrieve the data you’re looking for. For example, I loaded article.txt with the English tika,entity extractors, and can now query over what it found:
Thanks for sharing your input - Can you please suggest, In order to find the relationship between entities like A and B works for XYZ organization and both lives in same location - basically we want to get the links between nodes like in the following diagram -
If we have structured data (saved in triples format in Stardog DB) - then to achieve same should we used - PATH queries OR GRAPHQL OR any other? And, Please share complete example to find out relationships like in above image.
Also, for unstructured data, we are trying to create Custom Extractor. So, please suggest -
Can we create custom extractor other than in JAVA?
Please share steps to create Custom Extractor, we were following example and facing issues. So, it would be great, if you can share complete steps to implement the below example -
If you want the actual paths from one node to another, a PATHS query is most appropriate. GraphQL will only return you objects matching your specified criteria, so in effect, you’d hard code graph structure into your GraphQL template.
Regarding the extractor, you don’t have to use Java, but it would have to be a language that runs on the JVM, such as Kotlin. If you wanted to use something native, or a web service, you’d want a thin wrapper that calls out to the service.
Regarding the example, it’s hard to suggest solutions to whatever problems you’re facing without knowing what issues you’re running into. The example you reference is self-contained, so there’s nothing more to it than what is outlined there.
What went wrong:
A problem occurred evaluating root project 'bin'.
Could not find method compile() for arguments [com.complexible.stardog:server:
5.2.3] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.Defa
ultDependencyHandler.
Or is there any other step that I need to implement first? Am I missing out on something?
for ex - We want to know all the relationships of "Richard" (first name), then what should be Path Query for same, if we want to find out all paths and shortest path
Also, Within the following example, finding all the people Alice is connected to and how she is connected to them -
Can you please share the TTL file of this example, so that we can co-relate with this example?