diff options
Diffstat (limited to 'ishtar_common/utils.py')
| -rw-r--r-- | ishtar_common/utils.py | 11 | 
1 files changed, 9 insertions, 2 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 340fb9ee0..1219dd454 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -934,6 +934,9 @@ def num2col(n):      return string +RE_TSVECTOR = re.compile(r"('[^']+':\d+(?:,\d+)*)") + +  def merge_tsvectors(vectors):      """      Parse tsvector to merge them in one string @@ -952,16 +955,20 @@ def merge_tsvectors(vectors):                  if max_position > current_position:                      current_position = max_position -        for dct_member in vector.split(" "): +        for dct_member in RE_TSVECTOR.findall(vector):              splitted = dct_member.split(":")              key = ":".join(splitted[:-1]) -            positions = splitted[-1]              key = key[1:-1]  # remove quotes +            result_dict[key] = [1] +            """ +            # position is not used today - simplify +            positions = splitted[-1]              positions = [int(pos) + current_position for pos in positions.split(",")]              if key in result_dict:                  result_dict[key] += positions              else:                  result_dict[key] = positions +            """      # {'lamelie': [1, 42, 5]} => {'lamelie': "1,42,5"}      result_dict = {  | 
