# 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
# (at your option) any later version.

# SeSQL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with SeSQL.  If not, see <http://www.gnu.org/licenses/>.


def highlight(text, words, index = None):
    """
    Give the position of words in a text, cleaning everything as sesql does
    That can be used to highlight the words, for example
    The index will be use to lemmatize, if none, it'll use the default one
    """
    if not text:
        return []
    
    if index is None:
        index = fieldmap.primary

    if index is None:
        raise ValueError, "Not index given and no primary one"

    size = len(text)
    letters = set(string.ascii_letters)
    
    # Lemmatize the words

# 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

# (at your option) any later version.

# SeSQL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with SeSQL.  If not, see <http://www.gnu.org/licenses/>.


def highlight(text, words, index = None):
    """
    Give the position of words in a text, cleaning everything as sesql does
    That can be used to highlight the words, for example
    The index will be use to lemmatize, if none, it'll use the default one
    """
    if not text:
        return []
    
    if index is None:
        index = fieldmap.primary

    if index is None:
        raise ValueError, "Not index given and no primary one"

    size = len(text)
    letters = set(string.ascii_letters)
    
    # Lemmatize the words

    lems = lemmatize(words, index)