Re: converting text and spans to an ElementTree

2007-05-24 Thread Neil Cerutti
On 2007-05-24, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-05-23, Steven Bethard <[EMAIL PROTECTED]> wrote: > You mean... I left out the hard part? Shucks. I had really > hoped it didn't matter. > >> * the recursive (or stack) part assigns children to parents >> * the non-recursive part assi

Re: converting text and spans to an ElementTree

2007-05-24 Thread Neil Cerutti
On 2007-05-23, Steven Bethard <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2007-05-22, Steven Bethard <[EMAIL PROTECTED]> wrote: >>> Thanks a lot! This put me on the right track (though the >>> devil's definitely in the details). It's working now:: >>> >>> >> tree = xmltools.text_and_

Re: converting text and spans to an ElementTree

2007-05-23 Thread Steven Bethard
Neil Cerutti wrote: > On 2007-05-22, Steven Bethard <[EMAIL PROTECTED]> wrote: >> Thanks a lot! This put me on the right track (though the >> devil's definitely in the details). It's working now:: >> >> > tree = xmltools.text_and_spans_to_etree('aaa aaa aaaccc cccaaa', [ >> ... (etree.Eleme

Re: converting text and spans to an ElementTree

2007-05-23 Thread Neil Cerutti
On 2007-05-22, Steven Bethard <[EMAIL PROTECTED]> wrote: > Thanks a lot! This put me on the right track (though the > devil's definitely in the details). It's working now:: > > > >>> tree = xmltools.text_and_spans_to_etree('aaa aaa aaaccc cccaaa', [ > ... (etree.Element('a'), 0, 21), > ...

Re: converting text and spans to an ElementTree

2007-05-22 Thread Steven Bethard
Gabriel Genellina wrote: > the idea would be as follows: > > - For each span generate two tuples: (start_offset, 1, end_offset, > element) and (end_offset, 0, -start_offset, element). If start==end use > (start_offset, -1, start_offset, element). > - Collect all tuples in a list, and sort them.

Re: converting text and spans to an ElementTree

2007-05-22 Thread attn . steven . kuo
On May 21, 11:02 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > I have some text and a list of Element objects and their offsets, e.g.:: > > >>> text = 'aaa aaa aaabbb bbbaaa' > >>> spans = [ > ... (etree.Element('a'), 0, 21), > ... (etree.Element('b'), 11, 18), >

Re: converting text and spans to an ElementTree

2007-05-22 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > On May 21, 11:02 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: >> I have some text and a list of Element objects and their offsets, e.g.:: >> >> >>> text = 'aaa aaa aaabbb bbbaaa' >> >>> spans = [ >> ... (etree.Element('a'), 0, 21), >> ... (etr

Re: converting text and spans to an ElementTree

2007-05-22 Thread attn . steven . kuo
On May 21, 11:02 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > I have some text and a list of Element objects and their offsets, e.g.:: > > >>> text = 'aaa aaa aaabbb bbbaaa' > >>> spans = [ > ... (etree.Element('a'), 0, 21), > ... (etree.Element('b'), 11, 18), >

Re: converting text and spans to an ElementTree

2007-05-22 Thread Gabriel Genellina
En Tue, 22 May 2007 03:02:34 -0300, Steven Bethard <[EMAIL PROTECTED]> escribió: > I have some text and a list of Element objects and their offsets, e.g.:: > > >>> text = 'aaa aaa aaabbb bbbaaa' > >>> spans = [ > ... (etree.Element('a'), 0, 21), > ... (etree.Element('

converting text and spans to an ElementTree

2007-05-21 Thread Steven Bethard
I have some text and a list of Element objects and their offsets, e.g.:: >>> text = 'aaa aaa aaabbb bbbaaa' >>> spans = [ ... (etree.Element('a'), 0, 21), ... (etree.Element('b'), 11, 18), ... (etree.Element('c'), 18, 18), ... ] I'd like to produce the co