def __init__(
     self, n_min: int = 1, n_max: int = 5, split_tokens: Collection[str] = [], types: Optional[str] = None
 ) -> None:
     """Initialize MentionNgrams."""
     MentionNgrams.__init__(self, n_min=n_min, n_max=n_max, split_tokens=split_tokens)
     if types is not None:
         self.types = [t.strip().lower() for t in types]
     else:
         self.types = None
Exemplo n.º 2
0
    def __init__(self,
                 parts_by_doc=None,
                 n_max=3,
                 expand=True,
                 split_tokens=None):
        """MentionNgrams specifically for transistor parts.

        :param parts_by_doc: a dictionary d where d[document_name.upper()] =
            [partA, partB, ...]
        """
        MentionNgrams.__init__(self, n_max=n_max, split_tokens=None)
        self.parts_by_doc = parts_by_doc
        self.expander = expand_part_range if expand else (lambda x: [x])