diff --git a/parseratorvariable/__init__.py b/parseratorvariable/__init__.py index 8c63d1d..cd73363 100644 --- a/parseratorvariable/__init__.py +++ b/parseratorvariable/__init__.py @@ -40,16 +40,6 @@ def __init__( else: self._string_comparison = affineGap - # setting up some information for pickling this variable - self._definition = { - "field": field, - "tagger": tagger, - "block_parts": block_parts, - "crf": crf, - "log_file": log_file, - } - self._definition.update(**kwargs) - self.variable_types, self.variable_parts = comparisons(self.components) self.n_type_indicators = len(self.variable_types) - 1 @@ -62,8 +52,7 @@ def __init__( fields = self.fields(field) self.higher_vars = [ - DerivedType(variable, field_type) - for variable, field_type in fields + DerivedType(variable, field_type) for variable, field_type in fields ] self.log_file = log_file @@ -100,12 +89,6 @@ def tag(self, field, *args): return result - def __getstate__(self): - return self._definition.copy() - - def __setstate__(self, d): - self.__init__(**d) - def comparator(self, field_1, field_2): distances = numpy.zeros(self.expanded_size) i = 0 @@ -167,7 +150,8 @@ def fields(self, field): fields += [(part, "Derived") for part in self.variable_parts] fields += [ - ("%s: Not Missing" % (part,), "Not Missing") for part in self.variable_parts + ("{}: Not Missing".format(part), "Not Missing") + for part in self.variable_parts ] fields += [("full string", "String")] diff --git a/parseratorvariable/predicates.py b/parseratorvariable/predicates.py index 3ecbddd..e3ebbee 100644 --- a/parseratorvariable/predicates.py +++ b/parseratorvariable/predicates.py @@ -2,12 +2,12 @@ from probableparsing import RepeatedLabelError -class PartialIndex(object): +class PartialIndex: def __init__(self, *args, **kwargs): self.part = kwargs.pop("part") self.tag = kwargs.pop("tag") - super(PartialIndex, self).__init__(*args, **kwargs) - self.__name__ = "(%s, %s, %s)" % (self.threshold, self.field, self.part) + super().__init__(*args, **kwargs) + self.__name__ = "({}, {}, {})".format(self.threshold, self.field, self.part) def preprocess(self, doc): try: @@ -16,7 +16,7 @@ def preprocess(self, doc): part = "" else: part = tags.get(self.part, "") - return super(PartialIndex, self).preprocess(part) + return super().preprocess(part) class PLCPredicate(PartialIndex, predicates.LevenshteinCanopyPredicate): @@ -48,7 +48,7 @@ class PartialString(predicates.StringPredicate): def __init__(self, func, field, part, tag): self.func = func - self.__name__ = "(%s, %s, %s)" % (func.__name__, field, part) + self.__name__ = "({}, {}, {})".format(func.__name__, field, part) self.field = field self.part = part self.tag = tag @@ -65,4 +65,4 @@ def __call__(self, record, **kwargs): else: part = tags.get(self.part, "") - return super(PartialString, self).__call__({self.field: part}) + return super().__call__({self.field: part})