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)
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)
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)
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)