def initialize(self, resources: Resources, configs: Config): super().initialize(resources, configs) if configs.column_format is None: raise ProcessorConfigError( "Configuration column_format not provided.") column_format = configs.column_format # Validate column format. seen_fields: Set[str] = set() # pylint: disable=attribute-defined-outside-init self._column_format: List[Optional[str]] = [] self._star_pos = None for idx, field in enumerate(column_format): if field is None: self._column_format.append(None) continue if field.startswith("*"): if self._star_pos is not None: raise ValueError("Only one field can begin with '*'") field = field[1:] if field not in self._STAR_FIELDS: raise ValueError(f"Field '{field}' cannot begin with '*'") self._star_pos = idx if field not in self.ParsedFields._fields: raise ValueError(f"Unsupported field type: '{field}'") if field in seen_fields: raise ValueError(f"Duplicate field type: '{field}'") seen_fields.add(field) self._column_format.append(field) # Sanity check: certain fields must be present in format. for field in self._REQUIRED_FIELDS: if field not in seen_fields: raise ValueError(f"'{field}' field is required")
def initialize(self, resources: Resources, configs: Config): super().initialize(resources, configs) if not self.configs.entry_type: raise ProcessorConfigError("Please specify an entity mention type!") self.entry_type = get_class(self.configs.entry_type) if not issubclass(self.entry_type, Annotation): raise AttributeError( f"The entry type to delete [{self.entry_type}] " f"is not a sub-class of " f"'forte.data.ontology.top.Annotation' class." )
def initialize(self, resources: Resources, configs: Config): super().initialize(resources, configs) if configs.qa_file_extension is None: raise ProcessorConfigError( "Configuration qa_file_extension not provided.")