def from_search_path(search_path: SearchPath) -> 'SingleAnalysis':
        morphemes: List['SingleAnalysis.MorphemeData'] = []
        derivation_count = 0

        for transition in search_path.transitions:
            if transition.is_derivative():
                derivation_count += 1

            morpheme = transition.get_morpheme()
            if morpheme != TurkishMorphotactics.nom and morpheme != TurkishMorphotactics.pnon:
                if len(transition.surface) == 0:
                    morpheme_data = SingleAnalysis.empty_morpheme_cache.get(morpheme)
                    if morpheme_data is None:
                        morpheme_data = SingleAnalysis.MorphemeData(morpheme, "")
                        SingleAnalysis.empty_morpheme_cache[morpheme] = morpheme_data

                    morphemes.append(morpheme_data)
                else:
                    morpheme_data = SingleAnalysis.MorphemeData(morpheme, transition.surface)
                    morphemes.append(morpheme_data)

        group_boundaries: np.ndarray = np.zeros(derivation_count + 1, dtype=np.int32)
        morpheme_counter = 0
        derivation_counter = 1

        for morpheme_data in morphemes:
            if morpheme_data.morpheme.derivational_:
                group_boundaries[derivation_counter] = morpheme_counter
                derivation_counter += 1

            morpheme_counter += 1

        item = search_path.get_dictionary_item()
        if item.has_attribute(RootAttribute.Dummy):
            item = item.reference_item

        return SingleAnalysis(item, morphemes, group_boundaries)
Пример #2
0
 def accept_(self, visitor: SearchPath) -> bool:
     return visitor.get_dictionary_item().secondary_pos == self.pos
Пример #3
0
 def accept_(self, visitor: SearchPath) -> bool:
     return visitor.get_dictionary_item() not in self.items
Пример #4
0
 def accept_(self, visitor: SearchPath) -> bool:
     return visitor.get_dictionary_item().has_attribute(self.attribute)