# Not able to fetch path

**URL:** <https://community.stardog.com/t/not-able-to-fetch-path/1037>\
**Category:** Support\
**Created:** [May 14, 2018, 4:41am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037 "2018-05-14T04:41:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![navratan22jan](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@navratan22jan](https://community.stardog.com/u/navratan22jan)\
**Post date:** [May 14, 2018, 4:41am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/1 "2018-05-14T04:41:37Z")

</div>

Hi,

I have made a stardog db with opennlp and with entity extraction for persons. Then i loaded a text document in the doc store of the db.

stardog-admin db create -o docs.opennlp.models.path=D:\Setups\Stardog\stardog-5.2.3\opennlp -n testDB1

stardog doc put --rdf-extractors tika,entities testDB1 D:\Sample\article1.txt

The text file has the following data:

Navratan knows Mukesh as both are colleagues in ABC. They also have lunch together and are working on the same project for cleint.

Now I am trying to check the path between the entities, but I am not getting any path as the output.

stardog query -f text testDB1 “PATHS START ?x = :Navratan END ?y VIA ?p”

±------±------±------+  
| x | p | y |  
±------±------±------+  
±------±------±------+

Any idea?

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [May 14, 2018, 11:32am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/2 "2018-05-14T11:32:30Z")

</div>

Hi Navratan,

Before we dig in into the actual paths query, let’s debug which entities are being extracted from the text. Two questions:

- what is the content of the `D:\Setups\Stardog\stardog-5.2.3\opennlp` folder?
- what is the output of the following query `select * where { graph ?g { ?s ?p ?o }}`?

-pedro

---

<div class="post-metadata">

**Author:** ![navratan22jan](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@navratan22jan](https://community.stardog.com/u/navratan22jan)\
**Post date:** [May 15, 2018, 3:30am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/3 "2018-05-15T03:30:14Z")

</div>

Hi pedro,

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

Kindly suggest

Thanks  
Navratan

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [May 15, 2018, 11:51am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/4 "2018-05-15T11:51:37Z")

</div>

Hi Navratan,

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](https://complexible.jfrog.io/complexible/stardog-nlp/ner/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.

-pedro

---

<div class="post-metadata">

**Author:** ![navratan22jan](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@navratan22jan](https://community.stardog.com/u/navratan22jan)\
**Post date:** [May 16, 2018, 5:28am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/5 "2018-05-16T05:28:33Z")

</div>

Hey Pedro,

I changed the content of the file and the executed the select \* query again, now it has detected the person names as per the nlp model:

g  
Sort  
s  
Sort  
p  
Sort  
o  
Sort  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt stardog:docs:hasEntity stardog:docs:entity:f06574bbbfa1a5b474f276714e769027  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt stardog:docs:hasEntity stardog:docs:entity:679a56e43cd3beace9e4ba690824b055  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt [DCMI: Format](http://purl.org/dc/elements/1.1/format) text/plain; charset=ISO-8859-1  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt stardog:docs:fileSize 132  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt [DCMI: Identifier](http://purl.org/dc/elements/1.1/identifier) article1.txt  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt rdfs:label article1.txt  
stardog:docs:pathdb:article1.txt stardog:docs:entity:f06574bbbfa1a5b474f276714e769027 rdfs:label Nick  
stardog:docs:pathdb:article1.txt stardog:docs:entity:679a56e43cd3beace9e4ba690824b055 rdfs:label Mike  
stardog:docs:pathdb:article1.txt stardog:docs:entity:f06574bbbfa1a5b474f276714e769027 rdf:type stardog:docs:ner:person  
stardog:docs:pathdb:article1.txt stardog:docs:entity:679a56e43cd3beace9e4ba690824b055 rdf:type stardog:docs:ner:person  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt rdf:type [FOAF Vocabulary Specification](http://xmlns.com/foaf/0.1/Document)  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt rdf:type stardog:docs:Document  
stardog:docs:pathdb:article1.txt stardog:docs:pathdb:article1.txt rdf:type owl:Thing  
stardog:docs:pathdb:article1.txt stardog:docs:entity:f06574bbbfa1a5b474f276714e769027 rdf:type owl:Thing  
stardog:docs:pathdb:article1.txt stardog:docs:entity:679a56e43cd3beace9e4ba690824b055 rdf:type owl:Thing

Now, i ran the path query again, stardog query -f text pathdb "PATHS START ?x = :Navratan END ?y VIA ?p"

but its returning 0 paths.

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [May 16, 2018, 9:07am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/6 "2018-05-16T09:07:08Z")

</div>

Hi Navratan,

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:

```auto
select * where {
    graph ?doc {
        ?doc stardog:docs:hasEntity [rdfs:label ?label].
    }
}

```

---

<div class="post-metadata">

**Author:** ![navratan22jan](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@navratan22jan](https://community.stardog.com/u/navratan22jan)\
**Post date:** [May 16, 2018, 9:38am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/7 "2018-05-16T09:38:09Z")

</div>

Pedro,

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?

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [May 16, 2018, 10:19am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/8 "2018-05-16T10:19:14Z")

</div>

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](https://arxiv.org/abs/1712.05191), and is something that we don't support at the moment.  
Your only option here would be to implement a [custom extractor](https://www.stardog.com/docs/#_custom_extractors) with the logic to extract such relationships.

---

<div class="post-metadata">

**Author:** ![navratan22jan](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@navratan22jan](https://community.stardog.com/u/navratan22jan)\
**Post date:** [May 16, 2018, 10:52am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/9 "2018-05-16T10:52:43Z")

</div>

Ok Pedro, understood for unstructured data.  
Is it the same for the structured data as well which is saved in Stardog db in triples format?

---

<div class="post-metadata">

**Author:** ![pedro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pedro/32/108_2.png) [@pedro](https://community.stardog.com/u/pedro)\
**Post date:** [May 16, 2018, 11:04am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/10 "2018-05-16T11:04:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![navratan22jan](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@navratan22jan](https://community.stardog.com/u/navratan22jan)\
**Post date:** [May 16, 2018, 11:07am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/11 "2018-05-16T11:07:44Z")

</div>

Ok

Below is the link of a ttl file which i have used to save in stardog db.

[https://raw.githubusercontent.com/stardog-union/stardog-examples/develop/examples/docs/blog/person\_movie.ttl](https://raw.githubusercontent.com/stardog-union/stardog-examples/develop/examples/docs/blog/person_movie.ttl)

now i want to find relationship between entities extracted from this file. Please guide what should be the query for that.

Thanks

---

<div class="post-metadata">

**Author:** ![lorenz\_b](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lorenz\_b](https://community.stardog.com/u/lorenz_b)\
**Post date:** [May 17, 2018, 6:55am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/12 "2018-05-17T06:55:51Z")

</div>

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

```
select ?mention ?entity where {
  graph <tag:stardog:api:docs:movies:article.txt> {
    ?s rdfs:label ?mention ;
    ?s <http://purl.org/dc/terms/references> ?entity .
  }
}

```

and finally could wrap this is a combined query.

---

<div class="post-metadata">

**Author:** ![Mukesh](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mukesh](https://community.stardog.com/u/Mukesh)\
**Post date:** [May 17, 2018, 7:50am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/13 "2018-05-17T07:50:37Z")

</div>

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 -

[https://raw.githubusercontent.com/stardog-union/stardog-examples/develop/examples/docs/blog/person\_movie.ttl](https://raw.githubusercontent.com/stardog-union/stardog-examples/develop/examples/docs/blog/person_movie.ttl)

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

[https://raw.githubusercontent.com/stardog-union/stardog-examples/develop/examples/docs/blog/article.txt](https://raw.githubusercontent.com/stardog-union/stardog-examples/develop/examples/docs/blog/article.txt)

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.

Thanks,  
Mukesh Gupta

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [May 17, 2018, 3:59pm UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/14 "2018-05-17T15:59:30Z")

</div>

Hi Mukesh,

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:

```auto
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:

```auto
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:

```auto
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:

```auto
select ?type ?label { 
  graph <tag:stardog:api:docs:rtfm:article.txt> { 
  ?s <tag:stardog:api:docs:hasEntity> [rdf:type ?type; rdfs:label ?label] 
  }
}

+---------------------------------------+------------------+
| type | label |
+---------------------------------------+------------------+
| tag:stardog:api:docs:ner:organization | "Watergate" |
| tag:stardog:api:docs:ner:person | "George Clooney" |
| tag:stardog:api:docs:ner:date | "last year" |
| tag:stardog:api:docs:ner:person | "Grant Heslov" |
| tag:stardog:api:docs:ner:person | "Matt Charman" |
+---------------------------------------+------------------+

```

---

<div class="post-metadata">

**Author:** ![lorenz\_b](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lorenz\_b](https://community.stardog.com/u/lorenz_b)\
**Post date:** [May 18, 2018, 6:57am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/15 "2018-05-18T06:57:22Z")

</div>

As far as I understood, the use-case is to have

- Turtle file which contains entities with triples about them and
- a text file which might contain mentions of those entities.

This needs two steps:

- the entity extraction which finds parts in the text which mention entities
- entity linking, i.e. map those entities mentions to the RDF entities in the loaded KB

Once both steps are done, a SPARQL query could be used to get relationships between entities mentioned in the given text.

---

<div class="post-metadata">

**Author:** ![Mukesh](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mukesh](https://community.stardog.com/u/Mukesh)\
**Post date:** [May 21, 2018, 10:57am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/16 "2018-05-21T10:57:19Z")

</div>

Hi Stephen,

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 -

 ![](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/8ed175cb021961056bbc921024c9cd5e638f2a4f.png)

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 -

1. Can we create custom extractor other than in JAVA?

2. 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 -

> <https://github.com/stardog-union/stardog-examples/blob/develop/examples/docs/test/src/com/complexible/stardog/examples/docs/WordCountExtractorTest.java>

Thanks,  
Mukesh Gupta

---

<div class="post-metadata">

**Author:** ![mike](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/mike/32/14_2.png) [@mike](https://community.stardog.com/u/mike)\
**Post date:** [May 21, 2018, 7:25pm UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/17 "2018-05-21T19:25:19Z")

</div>

Mukesh,

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.

---

<div class="post-metadata">

**Author:** ![navratan22jan](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@navratan22jan](https://community.stardog.com/u/navratan22jan)\
**Post date:** [May 22, 2018, 4:54am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/18 "2018-05-22T04:54:47Z")

</div>

Hi Mike,

For the example, will I have to first run the build.gradle file and then the java code?

I am trying to run the build file from gradle, but getting the following error:

D:\Setups\gradle\gradle-4.7\bin\>gradle -q

FAILURE: Build failed with an exception.

- Where:  
Build file 'D:\Setups\gradle\gradle-4.7\bin\build.gradle' line: 4

- 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?

Thanks  
Navratan

---

<div class="post-metadata">

**Author:** ![Mukesh](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Mukesh](https://community.stardog.com/u/Mukesh)\
**Post date:** [May 22, 2018, 7:00am UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/19 "2018-05-22T07:00:42Z")

</div>

Hey Mike,

We are trying to find out the relationships within following file (saved in Stardog DB) -

[http://www.learningsparql.com/2ndeditionexamples/ex069.ttl](http://www.learningsparql.com/2ndeditionexamples/ex069.ttl)

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 -

> **[Home](https://docs.stardog.com/)**
>
> Documentation for Stardog, the world’s leading Knowledge Graph Platform for the Enterprise

Can you please share the TTL file of this example, so that we can co-relate with this example?

Thanks,  
Mukesh Gupta

---

<div class="post-metadata">

**Author:** ![mike](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/mike/32/14_2.png) [@mike](https://community.stardog.com/u/mike)\
**Post date:** [May 22, 2018, 2:24pm UTC](https://community.stardog.com/t/not-able-to-fetch-path/1037/20 "2018-05-22T14:24:15Z")

</div>

@navratan22jan

You should be running `gradle` from the checkout of the `stardog-examples` repo, _not_ from the gradle installation directory.

@Mukesh

Here’s the snippet of data from the example:

```auto
@prefix : <http://api.stardog.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix stardog: <tag:stardog:api:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix paths: <urn:paths:> .

<urn:paths:Alice> <urn:paths:knows> <urn:paths:Bob> .

<urn:paths:Bob> <urn:paths:knows> <urn:paths:David> ;
    <urn:paths:worksWith> <urn:paths:Charlie> .

<urn:paths:Charlie> <urn:paths:parentOf> <urn:paths:Eve> .

<urn:paths:Eve> <urn:paths:knows> <urn:paths:David> .

```

[Next page](https://community.stardog.com/t/not-able-to-fetch-path/1037.md?page=2)
