[Haskell-cafe] Libraries to compare trees?
dokondr at gmail.com
Fri Oct 28 10:58:31 CEST 2011
On Fri, Oct 28, 2011 at 2:31 AM, Ivan Lazar Miljenovic <
ivan.miljenovic at gmail.com> wrote:
> Well, for arbitrary directed graphs, FGL is probably your best bet, or
> _But_ you'll need to write the parser yourself using something like
> trifecta, uu-parsinglib, polyparse, parsec, etc.
> It would help if you described the structure of these graphs and what
> kind of support you'd want in a data structure.
Thanks for the feedback!
As I wrote in first message I need to compare both structure and node
contents of two graphs, find similar sub-graphs, and need some metric to
measure distance between two graphs. These graphs are produced by POS (part
of speech) sentence tagging. POS tagging is done by Standford statistical
For example in the graph G1:
(NP (DT The) (NN voice) (NN quality))
(VP (VBD was)
(ADJP (JJ clear) (RB too)))
G1 has an NP node (lets call this sub-graph SG1) which has three child leaf
nodes: (DT The) (NN voice) (NN quality), where
DT, NN - nodes names, and
"The", "voice", "quality" - corresponding leaf values of these nodes.
I need to compare this graph with graph G2:
(SBAR (IN Although)
(NP (DT the) (NN battery) (NN life))
(VP (VBD was) (RB not)
(ADJP (JJ long)))))
(NP (DT that))
(VP (VBZ is)
(VP (VBN ok)
(PP (IN for)
(NP (PRP me)))))
G2 also has the NP node (let's call it sub-graph SG2) which also has three
child leaf nodes: (DT the) (NN battery) (NN life))
I need to find that G1 and G2 has sub-graphs SG1 and SG2 with the similar
structure, but with different values of the leaf nodes.
I also need to devise some general metric that will allow me to estimate
distance between any two graphs. This distance should account both for
structural and leaf-node values similarity.
It would be easier to measure distance between vectors then graphs. So I am
thinking how to convert directed graph (that results from POS tagging) into
vector. Any ideas, links here?
On 28 October 2011 00:27, dokondr <dokondr at gmail.com> wrote:
> My mistake: need advice on libraries and data types not for trees but for
> directed graphs.
> On Thu, Oct 27, 2011 at 4:49 PM, dokondr <dokondr at gmail.com> wrote:
>> Please advise on Haskell libraries to compare trees in textual
>> I need to compare both structure and node contents of two trees, find
>> similar sub-trees, and need some metric to measure distance between two
>> Also need advice on simple parser to convert textual tree representation
>> into a data type convenient for tree manipulation (comparison, matching,
>> etc.) What data type to use for trees with arbitrary structure?
>> Example trees:
>> *** Tree 1:
>> (NP (DT The) (NN voice) (NN quality))
>> (VP (VBD was)
>> (ADJP (JJ clear) (RB too)))
>> (. .)))
>> *** Tree 2:
>> (SBAR (IN Although)
>> (NP (DT the) (NN battery) (NN life))
>> (VP (VBD was) (RB not)
>> (ADJP (JJ long)))))
>> (, ,)
>> (NP (DT that))
>> (VP (VBZ is)
>> (VP (VBN ok)
>> (PP (IN for)
>> (NP (PRP me)))))
>> (. .)))
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> Ivan Lazar Miljenovic
> Ivan.Miljenovic at gmail.com
All the best,
Dmitri O. Kondratiev
"This is what keeps me going: discovery"
dokondr at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe