Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore the chains of properties and classes in a given graph of RDF?(It's another way of exploring the ontology.) #88

Closed
candlecao opened this issue Jul 19, 2024 · 4 comments
Assignees

Comments

@candlecao
Copy link
Contributor

(For instance, our MusicBrainz RDF sample.)

The chains of properties and classes in a given graph can be taken as a "primitive ontology" or an inherent schema. We can feed this as context to LLM to facilitate "natural language to SPARQL".

@candlecao
Copy link
Contributor Author

I figured out a simple way. For example, you want to check the latent schema of the graph http://sample/musicbrainz/reconciled, just do this query:

SELECT DISTINCT ?classOfDomain ?property ?classOfRange
FROM <http://sample/musicbrainz/reconciled>
WHERE {
  ?subject a ?classOfDomain.
  ?subject ?property ?object .
  ?object a ?classOfRange.
}

@candlecao
Copy link
Contributor Author

Also, knowing the chains will help us to ask more well-designed or complicated questions (just to ask questions with a more professional perspective) for LLM2SPARQL.

@candlecao
Copy link
Contributor Author

candlecao commented Jul 24, 2024

I figured out a simple way. For example, you want to check the latent schema of the graph http://sample/musicbrainz/reconciled, just do this query:

SELECT DISTINCT ?classOfDomain ?property ?classOfRange
FROM <http://sample/musicbrainz/reconciled>
WHERE {
  ?subject a ?classOfDomain.
  ?subject ?property ?object .
  ?object a ?classOfRange.
}

--That is not perfect.
A better and more intact query could be:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?classOfDomain ?property ?classOfRange
FROM <http://sample/musicbrainz/reconciled>
WHERE {
  {?subject a ?classOfDomain.
  ?subject ?property ?object1 .
  FILTER (?property != rdf:type)
  }
  union
  {?subject a ?classOfDomain.
  ?subject ?property ?object1 .
  ?object1 a ?classOfRange.}
}

@candlecao candlecao reopened this Jul 24, 2024
@candlecao
Copy link
Contributor Author

Then you can use prompt engineering to get an ontology.
I tried and made it; But when the schema is more sophisticated, it may be tough to use prompt.
So I may turn to other method in the future. See #86.

@candlecao candlecao changed the title Explore the chains of properties and classes in a given graph of RDF? Explore the chains of properties and classes in a given graph of RDF?(It's another way of exploring the ontology.) Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant