コード例 #1
0
ファイル: depta.py プロジェクト: BuGoNee/pydepta
    def build_extraction_tree(self, template, type_descriptor, trace=True):
        """Build a tree of region extractors corresponding to the
        template
        """
        attribute_map = type_descriptor.attribute_map if type_descriptor else None
        extractors = BasicTypeExtractor.create(template.annotations, attribute_map)
        if trace:
            extractors = TraceExtractor.apply(template, extractors)
        for cls in (DeptaExtractor,):
            extractors = cls.apply(template, extractors)
            if trace:
                extractors = TraceExtractor.apply(template, extractors)

        return TemplatePageExtractor(template, extractors)
コード例 #2
0
    def build_extraction_tree(self, template, type_descriptor, trace=True):
        """Build a tree of region extractors corresponding to the
        template
        """
        attribute_map = type_descriptor.attribute_map if type_descriptor else None
        extractors = BasicTypeExtractor.create(template.annotations,
                                               attribute_map)
        if trace:
            extractors = TraceExtractor.apply(template, extractors)
        for cls in (DeptaExtractor, ):
            extractors = cls.apply(template, extractors)
            if trace:
                extractors = TraceExtractor.apply(template, extractors)

        return TemplatePageExtractor(template, extractors)
コード例 #3
0
 def build_extraction_tree(self,
                           template,
                           type_descriptor=None,
                           trace=False,
                           legacy=False):
     """Build a tree of region extractors corresponding to the template."""
     basic_extractors = BaseExtractor.create(template.annotations)
     if trace:
         basic_extractors = TraceExtractor.apply(template, basic_extractors)
     basic_extractors = ContainerExtractor.apply(template,
                                                 basic_extractors,
                                                 legacy=legacy)
     item_containers, extractors = [], []
     for extractor in basic_extractors:
         if (isinstance(extractor, BaseContainerExtractor)
                 and not extractor.annotation.metadata.get('field')):
             item_containers.append(extractor)
         else:
             extractors.append(extractor)
     if not extractors:
         return TemplatePageMultiItemExtractor(template, item_containers)
     outer_container = ContainerExtractor(
         extractors,
         template,
         legacy=True,
         required_fields=template.extra_required_attrs)
     extractors = [outer_container]
     extractors.extend(item_containers)
     return TemplatePageMultiItemExtractor(template, extractors)
コード例 #4
0
ファイル: extraction.py プロジェクト: TimoC1982/portia
 def build_extraction_tree(self, template, type_descriptor=None,
                           trace=False):
     """Build a tree of region extractors corresponding to the template."""
     basic_extractors = BaseExtractor.create(template.annotations)
     if trace:
         basic_extractors = TraceExtractor.apply(template, basic_extractors)
     basic_extractors = ContainerExtractor.apply(template, basic_extractors)
     item_containers, extractors = [], []
     for extractor in basic_extractors:
         if (isinstance(extractor, BaseContainerExtractor) and
                 not extractor.annotation.metadata.get('field')):
             item_containers.append(extractor)
         else:
             extractors.append(extractor)
     if not extractors:
         return TemplatePageMultiItemExtractor(template, item_containers)
     outer_container = ContainerExtractor(
         extractors, template, legacy=True,
         required_fields=template.extra_required_attrs)
     extractors = [outer_container]
     extractors.extend(item_containers)
     return TemplatePageMultiItemExtractor(template, extractors)