You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by emri mbiemri <em...@gmail.com> on 2021/06/01 16:59:23 UTC

Implementing 2-grams with SPARQL

Dears, 

I have a query like this:
-----------
SELECT DISTINCT ?o
WHERE {
		?s ?p "Notebook".
		?s <http://www.w3.org/TR/html4/Class1> |
		<http://www.w3.org/TR/html4/Class2> ?o .}
-----------

This way I can query all classes related to class "Notebook". e.g, Notebook - Teacher, Notebook - Student, etc.

And, when I run the same query with "Teacher" I get all the classes related to class "Teacher", e.g Teacher-Notebook, Teacher-Evaluation, etc.

My question here is if I can query in a form of 2-grams here, I mean how can I get all the classes that comes after Teacher - Notebook - *, or for example Evaluation - Teacher - * .

I am trying to use 2-grams in order to get domain-relevant classes, because when querying related classes only with one class returns not relevant classes as well, for instance, Notebook - Accountant, Evaluation - Movie (classes that are not relevant to education in this case), etc. So I want to use -grams here to get domain-relevant classes.

Thank you for your support. 


Re: Implementing 2-grams with SPARQL

Posted by emri mbiemri <em...@gmail.com>.
Hello Lorenze,

I understand, it is also not that easy to explain.

One of the files I am working on is that one(I cannot simply them):
https://github.com/iliriani/Test/blob/main/Notebook.rdf

Regardless of the number of classes included in this model, they are
specified either as "class1" or "class2". For instance, if we have within
our models these classes conducted in this way Evaluation - Notebook -
Teacher, it means that in the relation "Evaluation - Notebook" class
Evaluation is class1 and class Notebook is class2, then in the relation
"Notebook-Teacher" it means that Notebook is class1 and Teacher is class2,
and it continues regardless the number of the classes on the model, they
might be defined either class1 or class2. In my understanding, all this is
defined within the <Association> node.

So far, with the above query, I can find all the related classes to one
class, e.g. student- Teacher, Student-Notebook, etc. But my problem here is
how to find the connected class (in a line) after a relation of two and
three classes, for instance, which class(or classes) is connected after
relation: "student-notebook" - *?* or "student- notebook-evaluation" - *?,*
 "student-notebook-teacher"-*? *etc.

For example, if I query to get the connected classes for relationship
"teacher-evaluation-notebook" I should get the output: Absence, Student.
See the attached figure.

Thanks for your help.



On Wed, Jun 2, 2021 at 4:11 PM Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:

> Honestly, not sure what you're asking. The main issue I have is that you
>
> a) did not provide the data
> b) you're using domain specific questions in combination with some
> non-RDf standard terms like "2-grams"
>
> My suggestion and that's in my opinion the only way to get useful help
> here:
>
> a) provide a minimal sample of the data, and please not in RDF/XML but
> Turtle or N-Triples
> b) state what things exactly you're interested in, also be as precise as
> possible how they are related to the given terms in your working SPARQL
> query
>
>
> Thank's
>
> On 01.06.21 18:59, emri mbiemri wrote:
> > Dears,
> >
> > I have a query like this:
> > -----------
> > SELECT DISTINCT ?o
> > WHERE {
> >               ?s ?p "Notebook".
> >               ?s <http://www.w3.org/TR/html4/Class1> |
> >               <http://www.w3.org/TR/html4/Class2> ?o .}
> > -----------
> >
> > This way I can query all classes related to class "Notebook". e.g,
> Notebook - Teacher, Notebook - Student, etc.
> >
> > And, when I run the same query with "Teacher" I get all the classes
> related to class "Teacher", e.g Teacher-Notebook, Teacher-Evaluation, etc.
> >
> > My question here is if I can query in a form of 2-grams here, I mean how
> can I get all the classes that comes after Teacher - Notebook - *, or for
> example Evaluation - Teacher - * .
> >
> > I am trying to use 2-grams in order to get domain-relevant classes,
> because when querying related classes only with one class returns not
> relevant classes as well, for instance, Notebook - Accountant, Evaluation -
> Movie (classes that are not relevant to education in this case), etc. So I
> want to use -grams here to get domain-relevant classes.
> >
> > Thank you for your support.
> >
>

Re: Implementing 2-grams with SPARQL

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Honestly, not sure what you're asking. The main issue I have is that you

a) did not provide the data
b) you're using domain specific questions in combination with some 
non-RDf standard terms like "2-grams"

My suggestion and that's in my opinion the only way to get useful help here:

a) provide a minimal sample of the data, and please not in RDF/XML but 
Turtle or N-Triples
b) state what things exactly you're interested in, also be as precise as 
possible how they are related to the given terms in your working SPARQL 
query


Thank's

On 01.06.21 18:59, emri mbiemri wrote:
> Dears,
>
> I have a query like this:
> -----------
> SELECT DISTINCT ?o
> WHERE {
> 		?s ?p "Notebook".
> 		?s <http://www.w3.org/TR/html4/Class1> |
> 		<http://www.w3.org/TR/html4/Class2> ?o .}
> -----------
>
> This way I can query all classes related to class "Notebook". e.g, Notebook - Teacher, Notebook - Student, etc.
>
> And, when I run the same query with "Teacher" I get all the classes related to class "Teacher", e.g Teacher-Notebook, Teacher-Evaluation, etc.
>
> My question here is if I can query in a form of 2-grams here, I mean how can I get all the classes that comes after Teacher - Notebook - *, or for example Evaluation - Teacher - * .
>
> I am trying to use 2-grams in order to get domain-relevant classes, because when querying related classes only with one class returns not relevant classes as well, for instance, Notebook - Accountant, Evaluation - Movie (classes that are not relevant to education in this case), etc. So I want to use -grams here to get domain-relevant classes.
>
> Thank you for your support.
>