tsvector term positions and character offset - Mailing list pgsql-hackers

From Yoann Moreau
Subject tsvector term positions and character offset
Date
Msg-id 4ECE5E02.2010207@univ-avignon.fr
Whole thread Raw
List pgsql-hackers
Hello, I'm working on text data, actually some tsvectors of the text. 
The tsvector provides terms and positions for each term, I would need to 
map these positions to the character offsets of the terms in the 
original text.

'This is an example text for example'
tsvector -> 'an':3 'exampl':4,7 'for':6 'is':2 'text':5 'this':1
What I need would be for the first term 'This' : 0, or the term 
'example' : 11,28.

I've searched for anything able to do that without success (also asked 
on general pg list).
As the offset positions seem to be not stored or used at any time in the 
fulltext functions, the only way I figured out would be to parse the 
text again counting terms AND characters read. I coded this function as 
a very very dirty external C function, with many tsearch code copied 
because it can't be used outside of the source file.

My questions
1) Is there any other way to achieve what I need ?
2) Could my need be part of future more general functionality of the 
tsearch module ?
If not, any suggestion about the way to code it as clean and robust as 
possible ?

Regards,
Yoann Moreau


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Notes on implementing URI syntax for libpq
Next
From: Heikki Linnakangas
Date:
Subject: Re: PL/Python SQL error code pass-through