コード例 #1
0
ファイル: catalog.py プロジェクト: seantis/seantis.people
    def setup_lexicons(self):
        # setup the lexicons as some Plone-Catalog internal code depends on it
        # we wouldn't relly have to be so thorough as we don't actually want
        # to support full text searches on the people catalog, but setting
        # up the people catalog as close as possible to the portal catalog
        # ensures that there are no surprises
        lexicons = {
            'plone_lexicon': [
                ('Unicode Whitespace splitter', 'Word Splitter'),
                ('Unicode Ignoring Accents Case Normalizer',
                    'Case Normalizer'),
            ],
            'plaintext_lexicon': [
                ('HTML aware splitter', 'Word Splitter'),
                ('Case Normalizer', 'Case Normalizer'),
                ('Remove listed stop words only', 'Stop Words')
            ],
            'htmltext_lexicon': [
                ('HTML aware splitter', 'Word Splitter'),
                ('Case Normalizer', 'Case Normalizer'),
                ('Remove listed stop words only', 'Stop Words')
            ]
        }

        for lexicon, elements in lexicons.items():
            pipeline = []

            for element in elements:
                element = element_factory.instantiate(element[1], element[0])
                pipeline.append(element)

            plexicon = PLexicon(lexicon)
            plexicon._pipeline = pipeline
            self._setObject(lexicon, plexicon)