Closed yuquanle closed 7 years ago
Dear yuquanle,
In order to generate the syntactic trees to be used with tree kernels, you need to: 1) Parse your text with a dependency parser (or a constituency one, in case you want constituency trees). For instance you can use the CoreNLP parser from Stanford or the OpenNLP parser from Apache. 2) Convert the dependency parse into a tree structure such as the one described in the KeLP website tutorials, or in this paper.
Anyway we plan to release some modules to support these activities. Stay tuned!
Best, Simone
Dear Simone, It's my honor to receive your reply. But I am still confused how to convert the dependency parse into a tree structure such as Dependency-based tree ,Dependency-phrase based tree or LOCT.etc in you paper. for example the sentence: who are you
1. I have use Stanford parser to parse sentence to dependency relation.like this:
dep(ROOT,who/WP,root)
dep(who/WP,are/VBP,cop)
dep(who/WP,you/PRP,nsubj)
or
root(ROOT-0, who-1)
cop(who-1, are-2)
nsubj(who-1, you-3)
2.But I have no idea to convert the dependency parse(relation) into a tree structure like the following picture by coding. or
Can I refer to your code implementation due to my recent research needs.
Best regards, yuquanle
@SimoneFilice I have the similar problem/confusion as @yuquanle. Given 2 sentences, A and B: How do I create dependency tree out of them so that I can do all the awesome Kernel tree comparisons? Sincerely appreciate if you can point to some or any simple example. I have downloaded the kelp-full repository from here: https://github.com/SAG-KeLP/kelp-full
But I do not see a simple example about how would I convert a pair of sentences to dependency tree and use the powerful tools provided by Kelp-full
Many many thanks in advance.
Anis
@SimoneFilice, essentially I am trying to measure the structural similarity between 2 sentences (say SentA and SentB) using KeLP. Eventually I will use this similarity score as one of the features for modeling.
@yuquanle and @azaman13 Right now KeLP does not include data generation functionalities, such as the one you need. However, we understood that generating the tree representation of a sentence is not trivial, therefore we are developing a new module to support such operation. We will release this new code in few days (hopefully this week).
Best, Simone
Awesome! Thank you so much for the prompt response. Looking forward to the new release! Is there a way we can get notified right away when you guys push the new feature?
I'll use this thread to notify the release.
The KeLP team is pleased to inform you that a new maven project has been released. It allows the generation of tree structures from text snippets. Check the beta version: kelp-input-generator. Feedback will be highly appreciated.
Best, The KeLP team
Thank you @SimoneFilice for the update. This update is very valuable!
One more question: Given these tree representations of 2 piece of texts (e.g. tree1 and tree2), can you point me to some source code or examples about comparing or measuring similarity between the two trees?
I mean I am looking in the kelp-full project and having a hard time finding the functions that will help me measure some kind of similarity between the trees.
Many Thanks in advance! cc'ed: @kamei86i
In particular, given A and B: the 2 tree TreeRepresentation, I was looking for some example or use case of the float kernelComputation(TreeRepresentation repA, TreeRepresentation repB)
function from the SubTreeKernel.java
. I could not find any example. An example will help clarify some of my questions.
@SimoneFilice and @kamei86i
Dear Anis,
here an example that should be helpful (that considers also the SubSetTreeKernel
and the PartialTreeKernel
.
Important: In the following example the $lambda$ and $mu$ parameters of the kernel functions have been set to 1. I think that you should parameterize them (usually a value of 0.4 is useful in many classification tasks. Anyway, they MUST be set 0 < $lambda$ <= 1 and 0 < $mu$ <= 1 ).
Could you confirm it solved your problem?
Best regards
Danilo
TreeRepresentation t1 = new TreeRepresentation();
t1.setDataFromText("(a (b) (c))");
TreeRepresentation t2 = new TreeRepresentation();
t2.setDataFromText("(a (b))");
SubSetTreeKernel subSetTreeKernel = new SubSetTreeKernel(1f, "tree");
SubTreeKernel subTreeKernel = new SubTreeKernel(1f, "tree");
PartialTreeKernel partialTreeKernel = new PartialTreeKernel(1f, 1f, 1, "tree");
System.out.println("SubSetTreeKernel res = " + subSetTreeKernel.kernelComputation(t1, t2));
System.out.println("SubTreeKernel res = " + subTreeKernel.kernelComputation(t1, t2));
System.out.println("PartialTreeKernel res = " + partialTreeKernel.kernelComputation(t1, t2));`
@crux82 It worked! Thank you so much Danilo, sincerely appreciate it. it will be nice if you can add this small snipped to the Kelp website in one of the getting started demo; incase people in the future have similar question!!
will you please help me on how to use kelp for finding syntactic similarity in python
will you please help me on how to use kelp for finding syntactic similarity in python
We actually don't have a python version of KeLP. You can try to take a look at methods for calling Java from python (e.g., https://stackoverflow.com/questions/3652554/calling-java-from-python). Unfortunately, I don't have experience with it to estimate how complex it would be.
Best, Simone
I have read a few of your papers, I do not know how to generate Dependency-based tree and Dependency-phrase based tree .I have try to use this tools but fails. Can you give me valuable help?