# Path: sesql/lemmatize.py
# def lemmatize(words, index = None):
#     """
#     Give a lemmatized version of those words
# 
#     Use the configuration for the given index, or the default one if
#     index is None
#     """
#     if index is None:
#         index = fieldmap.primary
# 
#     if index is None:
#         raise ValueError, "Not index given and no primary one"
# 
#     words = [ index.marshall(word) for word in words ]
# 
#     index = fieldmap.get_field(index)
#     return lemmatize_for(words, index.dictionnary)
# 
# Path: sesql/fieldmap.py
# class FieldMap(object):
#     def __init__(self):
#     def all_fields(self):
#     def get_field(self, field):
#     def get_primary(self):


from sesql.lemmatize import lemmatize
from sesql.fieldmap import fieldmap
import string

    # Now find the lemmatized words inside the text
    found = []
    foundwords = set()
    for i, lem in enumerate(lems):
        if not lem:
            continue
        wordsize = len(lem)
        pos = 0
        while True:
            begin = text.find(lem, pos)
            if begin < 0:
                break
            end = begin + wordsize

            # We found something, ensure it's a normal word
            if begin and text[begin - 1] in letters:
                pos = end
                continue

            # Now find the end of the word
            while end < size and text[end] in letters:
                end += 1

            found.append((begin, end, i))
            foundwords.add(text[begin:end])
            pos = end

    # Lemmatize all found words
    foundwords = list(foundwords)

# Path: sesql/lemmatize.py
# def lemmatize(words, index = None):
#     """
#     Give a lemmatized version of those words
# 
#     Use the configuration for the given index, or the default one if
#     index is None
#     """
#     if index is None:
#         index = fieldmap.primary
# 
#     if index is None:
#         raise ValueError, "Not index given and no primary one"
# 
#     words = [ index.marshall(word) for word in words ]
# 
#     index = fieldmap.get_field(index)
#     return lemmatize_for(words, index.dictionnary)
# 
# Path: sesql/fieldmap.py
# class FieldMap(object):
#     def __init__(self):
#     def all_fields(self):
#     def get_field(self, field):
#     def get_primary(self):


# Path: sesql/highlight.py
from sesql.lemmatize import lemmatize
from sesql.fieldmap import fieldmap
import string


    # Now find the lemmatized words inside the text
    found = []
    foundwords = set()
    for i, lem in enumerate(lems):
        if not lem:
            continue
        wordsize = len(lem)
        pos = 0
        while True:
            begin = text.find(lem, pos)
            if begin < 0:
                break
            end = begin + wordsize

            # We found something, ensure it's a normal word
            if begin and text[begin - 1] in letters:
                pos = end
                continue

            # Now find the end of the word
            while end < size and text[end] in letters:
                end += 1

            found.append((begin, end, i))
            foundwords.add(text[begin:end])
            pos = end

    # Lemmatize all found words
    foundwords = list(foundwords)

    foundlems = lemmatize(foundwords, index)