[Zope-CVS] CVS: Products/ZCTextIndex - ISplitter.py:1.1.2.1 Splitter.py:1.1.2.1

Barry Warsaw barry@wooz.org
Wed, 1 May 2002 12:36:10 -0400


Update of /cvs-repository/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv4457

Added Files:
      Tag: TextIndexDS9-branch
	ISplitter.py Splitter.py 
Log Message:
An interface and implementation for splitters (but all the fun is in
the constructors).

Modify the tests to use the ISplitter interface.


=== Added File Products/ZCTextIndex/ISplitter.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information:
$Id: ISplitter.py,v 1.1.2.1 2002/05/01 16:36:09 bwarsaw Exp $
"""

from Interface import Base as Interface

class ISplitter(Interface):
    """A splitter."""

    def __call__(text):
        """Run the splitter over the input text, returning a list of terms."""


=== Added File Products/ZCTextIndex/Splitter.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

Revision information:
$Id: Splitter.py,v 1.1.2.1 2002/05/01 16:36:09 bwarsaw Exp $
"""

class Splitter:
    def __init__(self, splitterclass, synstop=None, encoding='latin1',
                 singlechar=0, index_numbers=0, maxlen=64, casefolding=1):
        self.__class = splitterclass
        self.__synstop = synstop
        self.__encoding = encoding
        self.__singlechar = singlechar
        self.__index_numbers = index_numbers
        self.__maxlen = maxlen
        self.__casefolding = casefolding

    def __call__(self, text):
        return self.__class(text,
                            self.__synstop, self.__encoding, self.__singlechar,
                            self.__index_numbers, self.__maxlen,
                            self.__casefolding)