Skip to content

Commit 29f5390

Browse files
committed
Better parm names, avoid "type" as variable name here
1 parent 3846b17 commit 29f5390

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

gatenlp/pam/pampac/actions.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ class RemoveAnnAll:
435435
"""
436436

437437
def __init__(self,
438-
name: Union[str, List[str]] = None,
439-
type: Union[str, List[str]] = None,
438+
names: Union[str, List[str]] = None,
439+
types: Union[str, List[str]] = None,
440440
annset_name: str = None,
441441
silent_fail: bool = True):
442442
"""
@@ -445,33 +445,33 @@ def __init__(self,
445445
(if specified). If not match name and/or no type name is specified, the removal action is not restricted.
446446
447447
Args:
448-
name: the name, or list of names, of a match(es) from which to get the annotation to remove.
449-
type: the annotation type, or list of types, of annotation within the whole matched pattern to remove
448+
names: the name, or list of names, of a match(es) from which to get the annotation to remove.
449+
types: the annotation type, or list of types, of annotation within the whole matched pattern to remove
450450
annset_name: the name of the annotation set to remove the annotation from. If this is the same set
451451
as used for matching it may influence the matching result if the annotation is removed before
452452
the remaining matching is done.
453453
If this is not specified, the annotation set of the (first) input annotation is used.
454454
silent_fail: if True, silently ignore the error of no annotation to get removed
455455
"""
456-
self.name = name
457-
self.ann_type = type
458-
if self is not None:
459-
if isinstance(self, list):
460-
assert all(isinstance(c, str) for c in self), \
461-
f"name must be a string or list of strings but is {name}"
456+
self.names = names
457+
self.types = types
458+
if names is not None:
459+
if isinstance(names, list):
460+
assert all(isinstance(c, str) for c in names), \
461+
f"names must be a string or list of strings but is {names}"
462462
else:
463-
assert isinstance(name, str), \
464-
f"name must be a string or list of strings but is {name}"
465-
self.name = [name]
466-
467-
if type is not None:
468-
if isinstance(type, list):
469-
assert all(isinstance(c, str) for c in type), \
470-
f"type must be a string or list of strings but is {type}"
463+
assert isinstance(names, str), \
464+
f"names must be a string or list of strings but is {names}"
465+
self.names = [names]
466+
467+
if types is not None:
468+
if isinstance(types, list):
469+
assert all(isinstance(c, str) for c in types), \
470+
f"type must be a string or list of strings but is {types}"
471471
else:
472-
assert isinstance(type, str), \
473-
f"type must be a string or list of strings but is {type}"
474-
self.type = [type]
472+
assert isinstance(types, str), \
473+
f"types must be a string or list of strings but is {types}"
474+
self.types = [types]
475475

476476
assert annset_name is None or isinstance(annset_name, str), \
477477
f"annset_name must be a string or None but is {annset_name}"
@@ -489,11 +489,11 @@ def __call__(self, succ, context=None, location=None, annset=None):
489489
ann = match.get("ann")
490490
if not ann:
491491
continue
492-
if self.name is not None:
493-
if match.get("name") not in self.name:
492+
if self.names is not None:
493+
if match.get("name") not in self.names:
494494
continue
495-
if self.type is not None:
496-
if ann.type not in self.type:
495+
if self.types is not None:
496+
if ann.type not in self.types:
497497
continue
498498
anns_to_remove.add(ann)
499499

@@ -502,7 +502,7 @@ def __call__(self, succ, context=None, location=None, annset=None):
502502
return
503503
else:
504504
raise Exception(
505-
f"Could not find annotations of type: {self.type} and / or of name: {self.name}"
505+
f"Could not find annotations of type: {self.types} and / or of name: {self.names}"
506506
)
507507

508508
if self.annset_name is not None:

0 commit comments

Comments
 (0)