SYMBOL INDEX (3347 symbols across 265 files) FILE: hanlp/__init__.py function load (line 13) | def load(save_dir: str, verbose=None, **kwargs) -> hanlp.common.componen... function pipeline (line 46) | def pipeline(*pipes) -> hanlp.components.pipeline.Pipeline: FILE: hanlp/callbacks/fine_csv_logger.py class StreamTableFormatter (line 12) | class StreamTableFormatter(object): method __init__ (line 14) | def __init__(self) -> None: method format_row (line 18) | def format_row(self, cells) -> List[str]: method format_cell (line 27) | def format_cell(self, cell: str, min_width) -> str: class FineCSVLogger (line 33) | class FineCSVLogger(tf.keras.callbacks.History): method __init__ (line 35) | def __init__(self, filename, separator=',', append=False): method on_train_begin (line 44) | def on_train_begin(self, logs=None): method on_train_end (line 48) | def on_train_end(self, logs=None): method on_epoch_end (line 51) | def on_epoch_end(self, epoch, logs=None): FILE: hanlp/common/component.py class Component (line 11) | class Component(Configurable, ABC): method predict (line 13) | def predict(self, *args, **kwargs): method __call__ (line 25) | def __call__(self, *args, **kwargs): FILE: hanlp/common/dataset.py class Transformable (line 30) | class Transformable(ABC): method __init__ (line 31) | def __init__(self, transform: Union[Callable, List] = None) -> None: method append_transform (line 43) | def append_transform(self, transform: Callable): method insert_transform (line 64) | def insert_transform(self, index: int, transform: Callable): method transform_sample (line 87) | def transform_sample(self, sample: dict, inplace=False) -> dict: class TransformableDataset (line 109) | class TransformableDataset(Transformable, Dataset, ABC): method __init__ (line 111) | def __init__(self, method load_data (line 139) | def load_data(self, data, generate_idx=False): method should_load_file (line 166) | def should_load_file(self, data) -> bool: method load_file (line 178) | def load_file(self, filepath: str): method __getitem__ (line 186) | def __getitem__(self, index: Union[int, slice]) -> Union[dict, List[di... method __len__ (line 212) | def __len__(self) -> int: method __repr__ (line 215) | def __repr__(self) -> str: method purge_cache (line 218) | def purge_cache(self): method split (line 223) | def split(self, *ratios): method k_fold (line 250) | def k_fold(self, k, i): method subset (line 265) | def subset(self, indices): method shuffle (line 280) | def shuffle(self): method prune (line 290) | def prune(self, criterion: Callable, logger: Logger = None): class TransformSequentialDataset (line 314) | class TransformSequentialDataset(Transformable, IterableDataset, ABC): class DeviceDataLoader (line 318) | class DeviceDataLoader(DataLoader): method __init__ (line 319) | def __init__(self, dataset, batch_size=32, shuffle=False, sampler=None, method __iter__ (line 341) | def __iter__(self): method collate_fn (line 350) | def collate_fn(self, samples): class PadSequenceDataLoader (line 354) | class PadSequenceDataLoader(DataLoader): method __init__ (line 356) | def __init__(self, dataset, batch_size=32, shuffle=False, sampler=None, method __iter__ (line 429) | def __iter__(self): method tensorize (line 434) | def tensorize(raw_batch: Dict[str, Any], vocabs: VocabDict, pad_dict: ... method pad_data (line 468) | def pad_data(data: Union[torch.Tensor, Iterable], pad, dtype=None, dev... method collate_fn (line 510) | def collate_fn(self, samples): class CachedDataLoader (line 514) | class CachedDataLoader(object): method __init__ (line 515) | def __init__(self, dataloader: torch.utils.data.DataLoader, filename=N... method _build_cache (line 522) | def _build_cache(self, dataset, verbose=HANLP_VERBOSE): method close (line 530) | def close(self): method __iter__ (line 534) | def __iter__(self): method __len__ (line 540) | def __len__(self): function _prefetch_generator (line 544) | def _prefetch_generator(dataloader, queue, batchify=None): class PrefetchDataLoader (line 552) | class PrefetchDataLoader(DataLoader): method __init__ (line 553) | def __init__(self, dataloader: torch.utils.data.DataLoader, prefetch: ... method _fire_process (line 583) | def _fire_process(self, dataloader, prefetch): method __iter__ (line 588) | def __iter__(self): method close (line 601) | def close(self): method batchify (line 610) | def batchify(self): method batchify (line 614) | def batchify(self, batchify): class BucketSampler (line 622) | class BucketSampler(Sampler): method __init__ (line 624) | def __init__(self, buckets: Dict[float, List[int]], batch_max_tokens, ... method __iter__ (line 651) | def __iter__(self): method __len__ (line 660) | def __len__(self): class KMeansSampler (line 664) | class KMeansSampler(BucketSampler): method __init__ (line 665) | def __init__(self, lengths, batch_max_tokens, batch_size=None, shuffle... class SortingSampler (line 684) | class SortingSampler(Sampler): method __init__ (line 686) | def __init__(self, lengths: List[int], batch_size=None, batch_max_toke... method __iter__ (line 728) | def __iter__(self): method __len__ (line 734) | def __len__(self) -> int: class SamplerBuilder (line 738) | class SamplerBuilder(AutoConfigurable, ABC): method build (line 740) | def build(self, lengths: List[int], shuffle=False, gradient_accumulati... method __call__ (line 751) | def __call__(self, lengths: List[int], shuffle=False, **kwargs) -> Sam... method scale (line 754) | def scale(self, gradient_accumulation): class SortingSamplerBuilder (line 774) | class SortingSamplerBuilder(SortingSampler, SamplerBuilder): method __init__ (line 776) | def __init__(self, batch_size=None, batch_max_tokens=None, use_effecti... method build (line 788) | def build(self, lengths: List[int], shuffle=False, gradient_accumulati... method __len__ (line 792) | def __len__(self) -> int: class KMeansSamplerBuilder (line 796) | class KMeansSamplerBuilder(KMeansSampler, SamplerBuilder): method __init__ (line 798) | def __init__(self, batch_max_tokens, batch_size=None, n_buckets=1): method build (line 810) | def build(self, lengths: List[int], shuffle=False, gradient_accumulati... method __len__ (line 814) | def __len__(self) -> int: class TableDataset (line 818) | class TableDataset(TransformableDataset): method __init__ (line 819) | def __init__(self, method load_file (line 831) | def load_file(self, filepath: str): FILE: hanlp/common/keras_component.py class KerasComponent (line 33) | class KerasComponent(Component, ABC): method __init__ (line 34) | def __init__(self, transform: Transform) -> None: method evaluate (line 49) | def evaluate(self, input_path: str, save_dir=None, output=False, batch... method num_samples_in (line 102) | def num_samples_in(self, dataset): method evaluate_dataset (line 105) | def evaluate_dataset(self, tst_data, callbacks, output, num_batches, *... method evaluate_output (line 109) | def evaluate_output(self, tst_data, out, num_batches, metrics: List[tf... method evaluate_output_to_file (line 121) | def evaluate_output_to_file(self, batch, outputs, out): method _capture_config (line 127) | def _capture_config(self, config: Dict, method save_meta (line 149) | def save_meta(self, save_dir, filename='meta.json', **kwargs): method load_meta (line 154) | def load_meta(self, save_dir, filename='meta.json'): method save_config (line 160) | def save_config(self, save_dir, filename='config.json'): method load_config (line 163) | def load_config(self, save_dir, filename='config.json'): method save_weights (line 167) | def save_weights(self, save_dir, filename='model.h5'): method load_weights (line 170) | def load_weights(self, save_dir, filename='model.h5', **kwargs): method save_vocabs (line 176) | def save_vocabs(self, save_dir, filename='vocabs.json'): method load_vocabs (line 183) | def load_vocabs(self, save_dir, filename='vocabs.json'): method load_transform (line 192) | def load_transform(self, save_dir) -> Transform: method save (line 205) | def save(self, save_dir: str, **kwargs): method load (line 210) | def load(self, save_dir: str, logger=hanlp.utils.log_util.logger, **kw... method input_shape (line 220) | def input_shape(self) -> List: method build (line 223) | def build(self, logger, **kwargs): method compile_model (line 252) | def compile_model(self, optimizer, loss, metrics): method build_optimizer (line 260) | def build_optimizer(self, optimizer, **kwargs) -> tf.keras.optimizers.... method build_loss (line 273) | def build_loss(self, loss, **kwargs): method build_transform (line 284) | def build_transform(self, **kwargs): method build_vocab (line 287) | def build_vocab(self, trn_data, logger): method build_metrics (line 292) | def build_metrics(self, metrics, logger: logging.Logger, **kwargs): method build_model (line 297) | def build_model(self, **kwargs) -> tf.keras.Model: method fit (line 300) | def fit(self, trn_data, dev_data, save_dir, batch_size, epochs, run_ea... method train_loop (line 369) | def train_loop(self, trn_data, dev_data, epochs, num_examples, train_s... method build_valid_dataset (line 379) | def build_valid_dataset(self, dev_data, batch_size): method build_train_dataset (line 383) | def build_train_dataset(self, trn_data, batch_size, num_examples): method build_callbacks (line 389) | def build_callbacks(self, save_dir, logger, **kwargs): method on_train_begin (line 425) | def on_train_begin(self): method predict (line 431) | def predict(self, data: Any, batch_size=None, **kwargs): method predict_batch (line 460) | def predict_batch(self, batch, inputs=None, **kwargs): method sample_data (line 467) | def sample_data(self): method from_meta (line 471) | def from_meta(meta: dict, **kwargs): method export_model_for_serving (line 490) | def export_model_for_serving(self, export_dir=None, version=1, overwri... method serve (line 508) | def serve(self, export_dir=None, grpc_port=8500, rest_api_port=0, over... FILE: hanlp/common/structure.py class ConfigTracker (line 11) | class ConfigTracker(Configurable): method __init__ (line 13) | def __init__(self, locals_: Dict, exclude=('kwargs', 'self', '__class_... class History (line 37) | class History(object): method __init__ (line 38) | def __init__(self): method step (line 45) | def step(self, gradient_accumulation): method num_training_steps (line 57) | def num_training_steps(self, num_batches, gradient_accumulation): FILE: hanlp/common/torch_component.py class TorchComponent (line 29) | class TorchComponent(Component, ABC): method __init__ (line 30) | def __init__(self, **kwargs) -> None: method _capture_config (line 43) | def _capture_config(self, locals_: Dict, method save_weights (line 72) | def save_weights(self, save_dir, filename='model.pt', trainable_only=T... method load_weights (line 89) | def load_weights(self, save_dir, filename='model.pt', **kwargs): method save_config (line 106) | def save_config(self, save_dir, filename='config.json'): method load_config (line 115) | def load_config(self, save_dir, filename='config.json', **kwargs): method save_vocabs (line 131) | def save_vocabs(self, save_dir, filename='vocabs.json'): method load_vocabs (line 141) | def load_vocabs(self, save_dir, filename='vocabs.json'): method save (line 152) | def save(self, save_dir: str, **kwargs): method load (line 163) | def load(self, save_dir: str, devices=None, verbose=HANLP_VERBOSE, **k... method fit (line 189) | def fit(self, method build_logger (line 301) | def build_logger(self, name, save_dir): method build_dataloader (line 315) | def build_dataloader(self, data, batch_size, shuffle=False, device=Non... method build_vocabs (line 330) | def build_vocabs(self, trn: torch.utils.data.Dataset, logger: logging.... method _savable_config (line 340) | def _savable_config(self): method build_optimizer (line 360) | def build_optimizer(self, **kwargs): method build_criterion (line 369) | def build_criterion(self, **kwargs): method build_metric (line 378) | def build_metric(self, **kwargs): method execute_training_loop (line 387) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 408) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 422) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method build_model (line 435) | def build_model(self, training=True, **kwargs) -> torch.nn.Module: method evaluate (line 444) | def evaluate(self, tst_data, save_dir=None, logger: logging.Logger = N... method generate_prediction_filename (line 505) | def generate_prediction_filename(self, tst_data, save_dir): method to (line 512) | def to(self, method parallelize (line 570) | def parallelize(self, devices: List[Union[int, torch.device]]): method devices (line 574) | def devices(self): method device (line 586) | def device(self): method on_config_ready (line 594) | def on_config_ready(self, **kwargs): method model_ (line 604) | def model_(self) -> nn.Module: method predict (line 617) | def predict(self, *args, **kwargs): method _create_dummy_placeholder_on (line 628) | def _create_dummy_placeholder_on(device): method __call__ (line 634) | def __call__(self, *args, **kwargs): FILE: hanlp/common/transform.py class ToIndex (line 19) | class ToIndex(ABC): method __init__ (line 21) | def __init__(self, vocab: Vocab = None) -> None: method __call__ (line 28) | def __call__(self, sample): method save_vocab (line 31) | def save_vocab(self, save_dir, filename='vocab.json'): method load_vocab (line 36) | def load_vocab(self, save_dir, filename='vocab.json'): class FieldToIndex (line 43) | class FieldToIndex(ToIndex): method __init__ (line 45) | def __init__(self, src, vocab: Vocab, dst=None) -> None: method __call__ (line 52) | def __call__(self, sample: dict): method save_vocab (line 56) | def save_vocab(self, save_dir, filename=None): method load_vocab (line 61) | def load_vocab(self, save_dir, filename=None): class VocabList (line 67) | class VocabList(list): method __init__ (line 69) | def __init__(self, *fields) -> None: method append (line 74) | def append(self, item: Union[str, Tuple[str, Vocab], Tuple[str, str, V... method save_vocab (line 90) | def save_vocab(self, save_dir): method load_vocab (line 94) | def load_vocab(self, save_dir): class VocabDict (line 99) | class VocabDict(SerializableDict): method __init__ (line 101) | def __init__(self, *args, **kwargs) -> None: method save_vocabs (line 114) | def save_vocabs(self, save_dir, filename='vocabs.json'): method load_vocabs (line 127) | def load_vocabs(self, save_dir, filename='vocabs.json', vocab_cls=Vocab): method _load_vocabs (line 140) | def _load_vocabs(vd, vocabs: dict, vocab_cls=Vocab): method lock (line 163) | def lock(self): method unlock (line 171) | def unlock(self): method mutable (line 180) | def mutable(self): method __call__ (line 184) | def __call__(self, sample: dict): method __getattr__ (line 192) | def __getattr__(self, key): method __setattr__ (line 197) | def __setattr__(self, key, value): method __getitem__ (line 200) | def __getitem__(self, k: str) -> Vocab: method __setitem__ (line 203) | def __setitem__(self, k: str, v: Vocab) -> None: method summary (line 206) | def summary(self, logger: logging.Logger = None): method put (line 220) | def put(self, **kwargs): class NamedTransform (line 230) | class NamedTransform(ABC): method __init__ (line 231) | def __init__(self, src: str, dst: str = None) -> None: method __call__ (line 238) | def __call__(self, sample: dict) -> dict: class ConfigurableTransform (line 242) | class ConfigurableTransform(Configurable, ABC): method config (line 244) | def config(self): method from_config (line 249) | def from_config(cls, config: dict): class ConfigurableNamedTransform (line 269) | class ConfigurableNamedTransform(NamedTransform, ConfigurableTransform, ... class EmbeddingNamedTransform (line 273) | class EmbeddingNamedTransform(ConfigurableNamedTransform, ABC): method __init__ (line 275) | def __init__(self, output_dim: int, src: str, dst: str) -> None: class RenameField (line 280) | class RenameField(NamedTransform): method __call__ (line 282) | def __call__(self, sample: dict): class CopyField (line 287) | class CopyField(object): method __init__ (line 288) | def __init__(self, src, dst) -> None: method __call__ (line 292) | def __call__(self, sample: dict) -> dict: class FilterField (line 297) | class FilterField(object): method __init__ (line 298) | def __init__(self, *keys) -> None: method __call__ (line 301) | def __call__(self, sample: dict): class TransformList (line 306) | class TransformList(list): method __init__ (line 321) | def __init__(self, *transforms) -> None: method __call__ (line 325) | def __call__(self, sample): method index_by_type (line 330) | def index_by_type(self, t): class LowerCase (line 336) | class LowerCase(object): method __init__ (line 337) | def __init__(self, src, dst=None) -> None: method __call__ (line 343) | def __call__(self, sample: dict) -> dict: class LowerCase3D (line 352) | class LowerCase3D(LowerCase): method __call__ (line 354) | def __call__(self, sample: dict) -> dict: class ToChar (line 360) | class ToChar(object): method __init__ (line 361) | def __init__(self, src, dst='char', max_word_length=None, min_word_len... method __call__ (line 370) | def __call__(self, sample: dict) -> dict: method to_chars (line 378) | def to_chars(self, word: str): class AppendEOS (line 387) | class AppendEOS(NamedTransform): method __init__ (line 389) | def __init__(self, src: str, dst: str = None, eos=EOS) -> None: method __call__ (line 393) | def __call__(self, sample: dict) -> dict: class WhitespaceTokenizer (line 398) | class WhitespaceTokenizer(NamedTransform): method __call__ (line 400) | def __call__(self, sample: dict) -> dict: method tokenize (line 409) | def tokenize(text: str): class NormalizeDigit (line 413) | class NormalizeDigit(object): method __init__ (line 414) | def __init__(self, src, dst=None) -> None: method transform (line 421) | def transform(word: str): method __call__ (line 430) | def __call__(self, sample: dict) -> dict: class Bigram (line 439) | class Bigram(NamedTransform): method __init__ (line 441) | def __init__(self, src: str, dst: str = None) -> None: method __call__ (line 446) | def __call__(self, sample: dict) -> dict: class FieldLength (line 454) | class FieldLength(NamedTransform): method __init__ (line 456) | def __init__(self, src: str, dst: str = None, delta=0) -> None: method __call__ (line 462) | def __call__(self, sample: dict) -> dict: class BMESOtoIOBES (line 467) | class BMESOtoIOBES(object): method __init__ (line 468) | def __init__(self, field='tag') -> None: method __call__ (line 471) | def __call__(self, sample: dict) -> dict: method convert (line 476) | def convert(y: str): class NormalizeToken (line 482) | class NormalizeToken(ConfigurableNamedTransform): method __init__ (line 484) | def __init__(self, mapper: Union[str, dict], src: str, dst: str = None... method __call__ (line 496) | def __call__(self, sample: dict) -> dict: method convert (line 507) | def convert(self, token) -> str: class PunctuationMask (line 511) | class PunctuationMask(ConfigurableNamedTransform): method __init__ (line 512) | def __init__(self, src: str, dst: str = None) -> None: method __call__ (line 526) | def __call__(self, sample: dict) -> dict: class NormalizeCharacter (line 536) | class NormalizeCharacter(NormalizeToken): method convert (line 537) | def convert(self, token) -> str: FILE: hanlp/common/transform_tf.py class Transform (line 16) | class Transform(ABC): method __init__ (line 18) | def __init__(self, config: SerializableDict = None, map_x=True, map_y=... method fit (line 35) | def fit(self, trn_path: str, **kwargs) -> int: method build_config (line 51) | def build_config(self): method create_types_shapes_values (line 68) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method file_to_inputs (line 75) | def file_to_inputs(self, filepath: str, gold=True): method inputs_to_samples (line 87) | def inputs_to_samples(self, inputs, gold=False): method file_to_samples (line 94) | def file_to_samples(self, filepath: str, gold=True): method file_to_dataset (line 106) | def file_to_dataset(self, filepath: str, gold=True, map_x=None, map_y=... method inputs_to_dataset (line 148) | def inputs_to_dataset(self, inputs, gold=False, map_x=None, map_y=None... method samples_to_dataset (line 162) | def samples_to_dataset(self, samples: Generator, map_x=None, map_y=Non... method x_to_idx (line 210) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: method y_to_idx (line 214) | def y_to_idx(self, y) -> tf.Tensor: method lock_vocabs (line 217) | def lock_vocabs(self): method summarize_vocabs (line 222) | def summarize_vocabs(self, logger=None, header='Vocab summary:'): method generator_to_callable (line 238) | def generator_to_callable(generator: Generator): method str_to_idx (line 241) | def str_to_idx(self, X, Y) -> Tuple[Union[tf.Tensor, Tuple], tf.Tensor]: method X_to_inputs (line 244) | def X_to_inputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]]) -> Iterable: method Y_to_outputs (line 247) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... method XY_to_inputs_outputs (line 251) | def XY_to_inputs_outputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]], method input_is_single_sample (line 269) | def input_is_single_sample(self, input: Any) -> bool: method input_to_inputs (line 272) | def input_to_inputs(self, input: Any) -> Tuple[Any, bool]: method input_truth_output_to_str (line 291) | def input_truth_output_to_str(self, input, truth, output): method cleanup (line 307) | def cleanup(self): FILE: hanlp/common/vocab.py class Vocab (line 12) | class Vocab(Serializable): method __init__ (line 13) | def __init__(self, idx_to_token: List[str] = None, token_to_idx: Dict ... method __setitem__ (line 42) | def __setitem__(self, token: str, idx: int): method __getitem__ (line 46) | def __getitem__(self, key: Union[str, int, List]) -> Union[int, str, L... method __contains__ (line 67) | def __contains__(self, key: Union[str, int]): method add (line 75) | def add(self, token: str) -> int: method update (line 95) | def update(self, tokens: Iterable[str]) -> None: method get_idx (line 105) | def get_idx(self, token: str) -> int: method get_idx_without_add (line 126) | def get_idx_without_add(self, token: str) -> int: method get_token (line 132) | def get_token(self, idx: int) -> str: method has_key (line 149) | def has_key(self, token): method __len__ (line 152) | def __len__(self): method lock (line 155) | def lock(self): method build_idx_to_token (line 168) | def build_idx_to_token(self): method unlock (line 174) | def unlock(self): method locked (line 188) | def locked(self): method unk_idx (line 195) | def unk_idx(self): method pad_idx (line 205) | def pad_idx(self): method tokens (line 215) | def tokens(self): method __str__ (line 221) | def __str__(self) -> str: method summary (line 224) | def summary(self, verbose=True) -> str: method __call__ (line 244) | def __call__(self, some_token: Union[str, Iterable[str]]) -> Union[int... method to_dict (line 260) | def to_dict(self) -> dict: method copy_from (line 275) | def copy_from(self, item: dict): method lower (line 290) | def lower(self): method first_token (line 305) | def first_token(self): method merge (line 314) | def merge(self, other): method safe_pad_token (line 324) | def safe_pad_token(self) -> str: method safe_pad_token_idx (line 335) | def safe_pad_token_idx(self) -> int: method safe_unk_token (line 342) | def safe_unk_token(self) -> str: method __repr__ (line 352) | def __repr__(self) -> str: method extend (line 357) | def extend(self, tokens: Iterable[str]): method reload_idx_to_token (line 361) | def reload_idx_to_token(self, idx_to_token: List[str], pad_idx=0, unk_... method set_unk_as_safe_unk (line 369) | def set_unk_as_safe_unk(self): method clear (line 374) | def clear(self): class CustomVocab (line 379) | class CustomVocab(Vocab): method to_dict (line 380) | def to_dict(self) -> dict: class LowercaseVocab (line 386) | class LowercaseVocab(CustomVocab): method get_idx (line 387) | def get_idx(self, token: str) -> int: class VocabWithNone (line 400) | class VocabWithNone(CustomVocab): method get_idx (line 401) | def get_idx(self, token: str) -> int: class VocabWithFrequency (line 407) | class VocabWithFrequency(CustomVocab): method __init__ (line 409) | def __init__(self, counter: Counter = None, min_occur_cnt=0, pad_token... method to_dict (line 423) | def to_dict(self) -> dict: method copy_from (line 428) | def copy_from(self, item: dict): method get_frequency (line 432) | def get_frequency(self, token): class VocabCounter (line 439) | class VocabCounter(CustomVocab): method __init__ (line 441) | def __init__(self, idx_to_token: List[str] = None, token_to_idx: Dict ... method get_idx (line 446) | def get_idx(self, token: str) -> int: method trim (line 451) | def trim(self, min_frequency): method copy_from (line 464) | def copy_from(self, item: dict): method to_dict (line 468) | def to_dict(self) -> dict: class Vocab3D (line 474) | class Vocab3D(CustomVocab): method __call__ (line 475) | def __call__(self, some_token: Union[str, Iterable[str], Iterable[Iter... function create_label_vocab (line 505) | def create_label_vocab() -> Vocab: FILE: hanlp/common/vocab_tf.py class VocabTF (line 12) | class VocabTF(Serializable): method __init__ (line 13) | def __init__(self, idx_to_token: List[str] = None, token_to_idx: Dict ... method __setitem__ (line 35) | def __setitem__(self, token: str, idx: int): method __getitem__ (line 39) | def __getitem__(self, key: Union[str, int, List]) -> Union[int, str, L... method __contains__ (line 52) | def __contains__(self, key: Union[str, int]): method add (line 60) | def add(self, token: str) -> int: method update (line 70) | def update(self, tokens: Iterable[str]) -> None: method get_idx (line 84) | def get_idx(self, token: str) -> int: method get_idx_without_add (line 94) | def get_idx_without_add(self, token: str) -> int: method get_token (line 100) | def get_token(self, idx: int) -> str: method has_key (line 109) | def has_key(self, token): method __len__ (line 112) | def __len__(self): method lock (line 115) | def lock(self): method build_idx_to_token (line 123) | def build_idx_to_token(self): method build_lookup_table (line 129) | def build_lookup_table(self): method unlock (line 135) | def unlock(self): method locked (line 145) | def locked(self): method unk_idx (line 149) | def unk_idx(self): method pad_idx (line 156) | def pad_idx(self): method tokens (line 163) | def tokens(self): method __str__ (line 166) | def __str__(self) -> str: method summary (line 169) | def summary(self, verbose=True) -> str: method __call__ (line 180) | def __call__(self, some_token: Union[str, List[str]]) -> Union[int, Li... method lookup (line 189) | def lookup(self, token_tensor: tf.Tensor) -> tf.Tensor: method to_dict (line 194) | def to_dict(self) -> dict: method copy_from (line 203) | def copy_from(self, item: dict): method lower (line 210) | def lower(self): method first_token (line 219) | def first_token(self): method merge (line 226) | def merge(self, other): method safe_pad_token (line 231) | def safe_pad_token(self) -> str: method safe_pad_token_idx (line 248) | def safe_pad_token_idx(self) -> int: method safe_unk_token (line 252) | def safe_unk_token(self) -> str: function create_label_vocab (line 269) | def create_label_vocab() -> VocabTF: FILE: hanlp/components/amr/amrbart/bart_amr_generation.py class BART_AMR_Generation (line 25) | class BART_AMR_Generation(TorchComponent): method __init__ (line 26) | def __init__(self, **kwargs) -> None: method build_dataloader (line 32) | def build_dataloader(self, data, batch_size=32, shuffle=False, device=... method build_optimizer (line 47) | def build_optimizer(self, **kwargs): method build_criterion (line 50) | def build_criterion(self, **kwargs): method build_metric (line 53) | def build_metric(self, **kwargs): method execute_training_loop (line 56) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 60) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 63) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method build_model (line 66) | def build_model(self, training=True, transformer=None, **kwargs) -> to... method input_is_flat (line 76) | def input_is_flat(self, data): method predict (line 79) | def predict( method predict_batch (line 105) | def predict_batch(self, batch, num_beams, max_length): method load_config (line 124) | def load_config(self, save_dir: str, filename='config.json', **kwargs): method load_vocabs (line 132) | def load_vocabs(self, save_dir, filename='vocabs.json'): method load_weights (line 138) | def load_weights(self, save_dir, filename='model.pt', **kwargs): FILE: hanlp/components/amr/amrbart/bart_amr_parser.py class BART_AMR_Parser (line 28) | class BART_AMR_Parser(TorchComponent): method __init__ (line 29) | def __init__(self, **kwargs) -> None: method build_dataloader (line 35) | def build_dataloader(self, data, batch_size=32, shuffle=False, device=... method build_optimizer (line 51) | def build_optimizer(self, **kwargs): method build_criterion (line 54) | def build_criterion(self, **kwargs): method build_metric (line 57) | def build_metric(self, **kwargs): method execute_training_loop (line 60) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 64) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method build_model (line 67) | def build_model(self, training=True, transformer=None, **kwargs) -> to... method input_is_flat (line 77) | def input_is_flat(self, data): method predict (line 80) | def predict( method predict_batch (line 106) | def predict_batch(self, batch, num_beams, max_length): method load_config (line 152) | def load_config(self, save_dir: str, filename='config.json', **kwargs): method load_vocabs (line 160) | def load_vocabs(self, save_dir, filename='vocabs.json'): method load_weights (line 166) | def load_weights(self, save_dir, filename='model.pt', **kwargs): method evaluate_dataloader (line 170) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method evaluate (line 207) | def evaluate(self, tst_data, save_dir=None, logger: logging.Logger = N... FILE: hanlp/components/amr/amrbart/common/penman_interface.py function _get_model (line 36) | def _get_model(dereify): function _remove_wiki (line 47) | def _remove_wiki(graph): function load (line 60) | def load(source, dereify=None, remove_wiki=False): function loads (line 69) | def loads(string, dereify=None, remove_wiki=False): function encode (line 78) | def encode(g, top=None, indent=-1, compact=False): FILE: hanlp/components/amr/amrbart/common/postprocessing.py function token_processing (line 39) | def token_processing(tok): function decode_into_node_and_backreferences (line 55) | def decode_into_node_and_backreferences(subtoken_ids, tokenizer): function index_of (line 233) | def index_of(element, iterable, default=None, start=None, end=None): function separate_edges_nodes (line 253) | def separate_edges_nodes(edges_nodes_slice, *other): function _split_name_ops (line 277) | def _split_name_ops(graph): function _reconstruct_graph_from_nodes (line 314) | def _reconstruct_graph_from_nodes(nodes, backreferences): function build_graph (line 440) | def build_graph(nodes, backreferences, restore_name_ops=False): class ParsedStatus (line 447) | class ParsedStatus(enum.Enum): function connect_graph_if_not_connected (line 453) | def connect_graph_if_not_connected(graph): function restore_backreferences_from_pointers (line 488) | def restore_backreferences_from_pointers(nodes): FILE: hanlp/components/amr/amrbart/data_interface/dataset.py class AMRParsingDataSet (line 24) | class AMRParsingDataSet(object): method tokenize (line 27) | def tokenize(sample: dict, tokenizer, max_src_length=400, max_tgt_leng... class AMR2TextDataSet (line 47) | class AMR2TextDataSet(object): method tokenize (line 50) | def tokenize(sample: dict, tokenizer, max_src_length=400, max_tgt_leng... FILE: hanlp/components/amr/amrbart/model_interface/modeling_bart.py function shift_tokens_right (line 75) | def shift_tokens_right(input_ids: torch.Tensor, pad_token_id: int, decod... function _make_causal_mask (line 91) | def _make_causal_mask(input_ids_shape: torch.Size, dtype: torch.dtype, p... function _expand_mask (line 106) | def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Option... class BartLearnedPositionalEmbedding (line 120) | class BartLearnedPositionalEmbedding(nn.Embedding): method __init__ (line 125) | def __init__(self, num_embeddings: int, embedding_dim: int): method forward (line 131) | def forward(self, input_ids_shape: torch.Size, past_key_values_length:... class BartAttention (line 140) | class BartAttention(nn.Module): method __init__ (line 143) | def __init__( method _shape (line 170) | def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int): method forward (line 173) | def forward( class BartEncoderLayer (line 287) | class BartEncoderLayer(nn.Module): method __init__ (line 288) | def __init__(self, config: BartConfig): method forward (line 304) | def forward( class BartDecoderLayer (line 355) | class BartDecoderLayer(nn.Module): method __init__ (line 356) | def __init__(self, config: BartConfig): method forward (line 382) | def forward( class BartClassificationHead (line 472) | class BartClassificationHead(nn.Module): method __init__ (line 475) | def __init__( method forward (line 487) | def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: class BartPretrainedModel (line 496) | class BartPretrainedModel(PreTrainedModel): method _init_weights (line 502) | def _init_weights(self, module): method _set_gradient_checkpointing (line 513) | def _set_gradient_checkpointing(self, module, value=False): method dummy_inputs (line 518) | def dummy_inputs(self): class PretrainedBartModel (line 528) | class PretrainedBartModel(BartPretrainedModel): method __init_subclass__ (line 529) | def __init_subclass__(self): class BartEncoder (line 692) | class BartEncoder(BartPretrainedModel): method __init__ (line 702) | def __init__(self, config: BartConfig, embed_tokens: Optional[nn.Embed... method get_input_embeddings (line 729) | def get_input_embeddings(self): method set_input_embeddings (line 732) | def set_input_embeddings(self, value): method forward (line 735) | def forward( class BartDecoder (line 868) | class BartDecoder(BartPretrainedModel): method __init__ (line 877) | def __init__(self, config: BartConfig, embed_tokens: Optional[nn.Embed... method get_input_embeddings (line 901) | def get_input_embeddings(self): method set_input_embeddings (line 904) | def set_input_embeddings(self, value): method _prepare_decoder_attention_mask (line 907) | def _prepare_decoder_attention_mask(self, attention_mask, input_shape,... method forward (line 925) | def forward( class BartModel (line 1146) | class BartModel(BartPretrainedModel): method __init__ (line 1147) | def __init__(self, config: BartConfig): method get_input_embeddings (line 1159) | def get_input_embeddings(self): method set_input_embeddings (line 1162) | def set_input_embeddings(self, value): method get_encoder (line 1167) | def get_encoder(self): method get_decoder (line 1170) | def get_decoder(self): method forward (line 1181) | def forward( class BartForConditionalGeneration (line 1273) | class BartForConditionalGeneration(BartPretrainedModel): method __init__ (line 1277) | def __init__(self, config: BartConfig): method get_encoder (line 1286) | def get_encoder(self): method get_decoder (line 1289) | def get_decoder(self): method resize_token_embeddings (line 1292) | def resize_token_embeddings(self, new_num_tokens: int) -> nn.Embedding: method _resize_final_logits_bias (line 1297) | def _resize_final_logits_bias(self, new_num_tokens: int) -> None: method get_output_embeddings (line 1306) | def get_output_embeddings(self): method set_output_embeddings (line 1309) | def set_output_embeddings(self, new_embeddings): method forward (line 1315) | def forward( method prepare_inputs_for_generation (line 1393) | def prepare_inputs_for_generation( method prepare_decoder_input_ids_from_labels (line 1421) | def prepare_decoder_input_ids_from_labels(self, labels: torch.Tensor): method _reorder_cache (line 1425) | def _reorder_cache(past, beam_idx): class BartForSequenceClassification (line 1442) | class BartForSequenceClassification(BartPretrainedModel): method __init__ (line 1443) | def __init__(self, config: BartConfig, **kwargs): method forward (line 1464) | def forward( class BartForQuestionAnswering (line 1569) | class BartForQuestionAnswering(BartPretrainedModel): method __init__ (line 1570) | def __init__(self, config): method forward (line 1590) | def forward( class BartDecoderWrapper (line 1685) | class BartDecoderWrapper(BartPretrainedModel): method __init__ (line 1691) | def __init__(self, config): method forward (line 1695) | def forward(self, *args, **kwargs): class BartForCausalLM (line 1699) | class BartForCausalLM(BartPretrainedModel): method __init__ (line 1700) | def __init__(self, config): method get_input_embeddings (line 1712) | def get_input_embeddings(self): method set_input_embeddings (line 1715) | def set_input_embeddings(self, value): method get_output_embeddings (line 1718) | def get_output_embeddings(self): method set_output_embeddings (line 1721) | def set_output_embeddings(self, new_embeddings): method set_decoder (line 1724) | def set_decoder(self, decoder): method get_decoder (line 1727) | def get_decoder(self): method forward (line 1731) | def forward( method prepare_inputs_for_generation (line 1874) | def prepare_inputs_for_generation(self, input_ids, past=None, attentio... method _reorder_cache (line 1890) | def _reorder_cache(past, beam_idx): FILE: hanlp/components/amr/amrbart/model_interface/tokenization_bart.py class AMRBartTokenizer (line 33) | class AMRBartTokenizer(BartTokenizer): method __init__ (line 36) | def __init__(self, vocab_file, merges_file, errors="replace", bos_toke... method from_pretrained (line 44) | def from_pretrained(cls, pretrained_model_path, *args, **kwargs): method init_amr_vocabulary (line 49) | def init_amr_vocabulary(self): method _tokenize (line 66) | def _tokenize(self, text): method _tok_bpe (line 83) | def _tok_bpe(self, token): method tokenize_amr (line 97) | def tokenize_amr(self, amr_tokens): method decode_amr (line 141) | def decode_amr(self, tokens, restore_name_ops=None): method _fix_and_make_graph (line 174) | def _fix_and_make_graph(self, nodes): method _classify (line 450) | def _classify(self, node): FILE: hanlp/components/amr/amrbart/preprocess/amr_io.py function read_raw_amr_data (line 31) | def read_raw_amr_data( FILE: hanlp/components/amr/amrbart/preprocess/penman_interface.py function _get_model (line 36) | def _get_model(dereify): function _remove_wiki (line 47) | def _remove_wiki(graph): function load (line 60) | def load(source, dereify=None, remove_wiki=False): function loads (line 69) | def loads(string, dereify=None, remove_wiki=False): function encode (line 78) | def encode(g, top=None, indent=-1, compact=False): FILE: hanlp/components/amr/amrbart/preprocess/read_and_process.py function _tokenize_encoded_graph (line 33) | def _tokenize_encoded_graph(encoded): function dfs_linearize (line 50) | def dfs_linearize(graph, remove_pars=False, use_pointer_tokens=True): function main (line 82) | def main(): FILE: hanlp/components/amr/seq2seq/dataset/IO.py function read_raw_amr_data (line 7) | def read_raw_amr_data( FILE: hanlp/components/amr/seq2seq/dataset/dataset.py class AMRDataset (line 17) | class AMRDataset(TransformableDataset): method __init__ (line 19) | def __init__(self, method load_file (line 32) | def load_file(self, filepath: str): method get_roles (line 38) | def get_roles(self): method get_frames (line 48) | def get_frames(self): class AMRPickleDataset (line 60) | class AMRPickleDataset(AMRDataset): method load_file (line 62) | def load_file(self, filepath: str): function dfs_linearize_tokenize (line 69) | def dfs_linearize_tokenize(sample: dict, tokenizer: PENMANBartTokenizer,... function dfs_linearize_levi (line 85) | def dfs_linearize_levi(sample: dict, tokenizer: PENMANBartTokenizer, rem... function dfs_linearize_rgcn (line 111) | def dfs_linearize_rgcn(sample: dict, tokenizer: PENMANBartTokenizer) -> ... function dfs_linearize_constituency (line 127) | def dfs_linearize_constituency(sample: dict, tokenizer: PENMANBartTokeni... function dfs_linearize_tokenize_with_linguistic_structures (line 171) | def dfs_linearize_tokenize_with_linguistic_structures(sample: dict, toke... function dep_to_levi (line 220) | def dep_to_levi(tok: List[str], dep: List[Tuple[int, str]]): function dfs (line 227) | def dfs(tok: List[str], dep: List[Tuple[int, str]], s, seq): FILE: hanlp/components/amr/seq2seq/dataset/linearization.py class SemanticGraph (line 12) | class SemanticGraph: method variables (line 36) | def variables(self) -> Set[str]: method resolved_nodes_var (line 42) | def resolved_nodes_var(self) -> List[str]: method nodes (line 47) | def nodes(self) -> List[str]: method resolved_nodes (line 52) | def resolved_nodes(self) -> List[str]: method src_occurrence (line 55) | def src_occurrence(self, var: str) -> int: class BaseLinearizer (line 59) | class BaseLinearizer(metaclass=abc.ABCMeta): method linearize (line 62) | def linearize(self, *args, **kwargs) -> SemanticGraph: class AMRTokens (line 66) | class AMRTokens: method is_node (line 98) | def is_node(cls, string: str) -> bool: method read_backr (line 106) | def read_backr(cls, string: str) -> Optional: function index_default (line 119) | def index_default( class AMRLinearizer (line 132) | class AMRLinearizer(BaseLinearizer): method __init__ (line 134) | def __init__( method _collapse_name_ops (line 143) | def _collapse_name_ops(self, amr): method linearize (line 170) | def linearize(self, amr: penman.Graph) -> SemanticGraph: method _linearize (line 179) | def _linearize(self, amr: penman.Graph) -> SemanticGraph: method _interleave (line 321) | def _interleave(self, graph: SemanticGraph) -> SemanticGraph: method _add_pointer_tokens (line 382) | def _add_pointer_tokens(self, graph: SemanticGraph) -> SemanticGraph: FILE: hanlp/components/amr/seq2seq/dataset/penman.py function _get_model (line 22) | def _get_model(dereify): function _remove_wiki (line 31) | def _remove_wiki(graph): function pm_load (line 44) | def pm_load(source, dereify=None, remove_wiki=False) -> List[penman.Graph]: function loads (line 63) | def loads(string, dereify=None, remove_wiki=False): function pm_encode (line 72) | def pm_encode(g, top=None, indent=-1, compact=False): function role_is_reverted (line 77) | def role_is_reverted(role: str): class AMRGraph (line 83) | class AMRGraph(penman.Graph): method __str__ (line 84) | def __str__(self): FILE: hanlp/components/amr/seq2seq/dataset/postprocessing.py function token_processing (line 15) | def token_processing(tok): function decode_into_node_and_backreferences (line 31) | def decode_into_node_and_backreferences(subtoken_ids, tokenizer): function decode_into_node_and_backreferences_without_space (line 191) | def decode_into_node_and_backreferences_without_space(subtoken_ids, toke... function index_of (line 360) | def index_of(element, iterable, default=None, start=None, end=None): function separate_edges_nodes (line 378) | def separate_edges_nodes(edges_nodes_slice, *other): function _split_name_ops (line 405) | def _split_name_ops(graph): function _reconstruct_graph_from_nodes (line 442) | def _reconstruct_graph_from_nodes(nodes, backreferences): function build_graph (line 563) | def build_graph(nodes, backreferences, restore_name_ops=False): class ParsedStatus (line 570) | class ParsedStatus(enum.Enum): function connect_graph_if_not_connected (line 576) | def connect_graph_if_not_connected(graph): function restore_backreferences_from_pointers (line 610) | def restore_backreferences_from_pointers(nodes): FILE: hanlp/components/amr/seq2seq/dataset/tokenization_bart.py class AMRBartTokenizer (line 15) | class AMRBartTokenizer(BartTokenizer): method __init__ (line 24) | def __init__(self, *args, use_pointer_tokens=False, collapse_name_ops=... method from_pretrained (line 36) | def from_pretrained(cls, pretrained_model_path, additional_tokens: Ite... method init_amr_vocabulary (line 43) | def init_amr_vocabulary(self, additions: Set[str] = None, recategoriza... method build_inputs_with_special_tokens (line 81) | def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=No... method _tokenize (line 87) | def _tokenize(self, text): method _tok_bpe (line 104) | def _tok_bpe(self, token, add_space=True): method _get_nodes_and_backreferences (line 120) | def _get_nodes_and_backreferences(self, graph): method tokenize_amr (line 125) | def tokenize_amr(self, graph): method batch_encode_sentences (line 181) | def batch_encode_sentences(self, sentences, device=torch.device('cpu')): method linearize (line 188) | def linearize(self, graph): method batch_encode_graphs (line 201) | def batch_encode_graphs(self, graphs, device=torch.device('cpu')): method batch_encode_graphs_from_linearized (line 205) | def batch_encode_graphs_from_linearized(self, linearized, extras=None,... method decode_amr (line 223) | def decode_amr(self, tokens, restore_name_ops=False): class PENMANBartTokenizer (line 257) | class PENMANBartTokenizer(AMRBartTokenizer): method __init__ (line 259) | def __init__(self, *args, raw_graph=False, **kwargs): method _tokenize_encoded_graph (line 265) | def _tokenize_encoded_graph(self, encoded): method tokenize_amr (line 282) | def tokenize_amr(self, graph): method _get_nodes_and_backreferences (line 295) | def _get_nodes_and_backreferences(self, graph): method _classify (line 327) | def _classify(self, node): method _fix_and_make_graph (line 354) | def _fix_and_make_graph(self, nodes): method decode_amr (line 635) | def decode_amr(self, tokens, restore_name_ops=None): FILE: hanlp/components/amr/seq2seq/dataset/tokenization_t5.py class AMRT5Tokenizer (line 16) | class AMRT5Tokenizer(T5TokenizerFast): method __init__ (line 25) | def __init__(self, *args, use_pointer_tokens=False, collapse_name_ops=... method from_pretrained (line 37) | def from_pretrained(cls, pretrained_model_path, additional_tokens: Ite... method init_amr_vocabulary (line 44) | def init_amr_vocabulary(self, additions: Set[str] = None, recategoriza... method build_inputs_with_special_tokens (line 73) | def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=No... method _tokenize (line 79) | def _tokenize(self, text): method _tok_bpe (line 96) | def _tok_bpe(self, token, add_space=True): method _get_nodes_and_backreferences (line 109) | def _get_nodes_and_backreferences(self, graph): method tokenize_amr (line 114) | def tokenize_amr(self, graph): method batch_encode_sentences (line 171) | def batch_encode_sentences(self, sentences, device=torch.device('cpu')): method linearize (line 178) | def linearize(self, graph): method batch_encode_graphs (line 191) | def batch_encode_graphs(self, graphs, device=torch.device('cpu')): method batch_encode_graphs_from_linearized (line 195) | def batch_encode_graphs_from_linearized(self, linearized, extras=None,... method decode_amr (line 213) | def decode_amr(self, tokens, restore_name_ops=False): class PENMANT5Tokenizer (line 248) | class PENMANT5Tokenizer(AMRT5Tokenizer): method __init__ (line 250) | def __init__(self, *args, raw_graph=False, **kwargs): method _tokenize_encoded_graph (line 256) | def _tokenize_encoded_graph(self, encoded): method tokenize_amr (line 275) | def tokenize_amr(self, graph): method _get_nodes_and_backreferences (line 288) | def _get_nodes_and_backreferences(self, graph): method _classify (line 320) | def _classify(self, node): method _fix_and_make_graph (line 347) | def _fix_and_make_graph(self, nodes): method decode_amr (line 630) | def decode_amr(self, tokens, restore_name_ops=None): method encoder (line 672) | def encoder(self) -> Dict[str, int]: FILE: hanlp/components/amr/seq2seq/evaluation.py function write_predictions (line 6) | def write_predictions(predictions_path, tokenizer, graphs): function compute_smatch (line 15) | def compute_smatch(pred, gold): function compute_bleu (line 22) | def compute_bleu(gold_sentences, pred_sentences): FILE: hanlp/components/amr/seq2seq/optim.py class RAdam (line 8) | class RAdam(Optimizer): method __init__ (line 10) | def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weig... method __setstate__ (line 29) | def __setstate__(self, state): method step (line 32) | def step(self, closure=None): FILE: hanlp/components/amr/seq2seq/seq2seq_amr_parser.py class Seq2seq_AMR_Parser (line 34) | class Seq2seq_AMR_Parser(TorchComponent): method __init__ (line 35) | def __init__(self, **kwargs): method build_dataloader (line 41) | def build_dataloader(self, data, batch_size, method _create_dataloader (line 73) | def _create_dataloader(self, dataset, batch_size, device, sampler, shu... method _get_pad_dict (line 77) | def _get_pad_dict(self): method finalize_dataset (line 81) | def finalize_dataset(self, dataset, logger: logging.Logger = None): method build_dataset (line 85) | def build_dataset(self, data, generate_idx): method collect_additional_tokens (line 89) | def collect_additional_tokens(self, additional_tokens, dataset): method build_tokenizer (line 99) | def build_tokenizer(self, additional_tokens) -> PENMANBartTokenizer: method build_optimizer (line 119) | def build_optimizer(self, trn, lr, epochs, gradient_accumulation, warm... method build_criterion (line 132) | def build_criterion(self, **kwargs): method build_metric (line 135) | def build_metric(self, **kwargs): method execute_training_loop (line 138) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 177) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method _step (line 198) | def _step(self, optimizer, scheduler): method report_metrics (line 206) | def report_metrics(self, loss): method feed_batch (line 209) | def feed_batch(self, batch): method evaluate_dataloader (line 221) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method predict_amrs (line 259) | def predict_amrs(self, batch, beam_size=1): method _model_generate (line 287) | def _model_generate(self, batch, beam_size): method build_model (line 299) | def build_model(self, training=True, **kwargs) -> torch.nn.Module: method _get_model_cls (line 315) | def _get_model_cls(self, transformer: str): method _init_new_embeddings (line 325) | def _init_new_embeddings(model, tokenizer): method input_is_flat (line 377) | def input_is_flat(self, data): method predict (line 380) | def predict(self, data: Union[str, List[str]], beautiful_amr_graph=Tru... method fit (line 399) | def fit(self, trn_data, dev_data, save_dir, batch_size=32, epochs=30, method on_config_ready (line 490) | def on_config_ready(self, **kwargs): method evaluate (line 501) | def evaluate(self, tst_data, save_dir=None, logger: logging.Logger = N... method build_vocabs (line 505) | def build_vocabs(self, trn: torch.utils.data.Dataset, logger: logging.... FILE: hanlp/components/classifiers/fasttext_classifier.py class FastTextClassifier (line 19) | class FastTextClassifier(Component): method __init__ (line 21) | def __init__(self) -> None: method load (line 29) | def load(self, save_dir, model_path=None, **kwargs): method predict (line 41) | def predict(self, text: Union[str, List[str]], topk=False, prob=False,... method labels (line 90) | def labels(self): method _strip_prefix (line 94) | def _strip_prefix(label: str): FILE: hanlp/components/classifiers/transformer_classifier.py class TransformerClassificationModel (line 28) | class TransformerClassificationModel(nn.Module): method __init__ (line 30) | def __init__(self, method forward (line 40) | def forward(self, input_ids, attention_mask, token_type_ids): class TransformerComponent (line 52) | class TransformerComponent(TorchComponent, ABC): method __init__ (line 53) | def __init__(self, **kwargs) -> None: method build_optimizer (line 63) | def build_optimizer(self, method fit (line 86) | def fit(self, trn_data, dev_data, save_dir, method on_config_ready (line 110) | def on_config_ready(self, **kwargs): method build_transformer (line 117) | def build_transformer(self, training=True): class TransformerClassifier (line 129) | class TransformerClassifier(TransformerComponent): method __init__ (line 131) | def __init__(self, **kwargs) -> None: method build_criterion (line 140) | def build_criterion(self, **kwargs): method build_metric (line 144) | def build_metric(self, **kwargs): method execute_training_loop (line 147) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method label_vocab (line 166) | def label_vocab(self): method fit_dataloader (line 169) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method update_metric (line 191) | def update_metric(self, metric, logits: torch.Tensor, target, output=N... method compute_loss (line 197) | def compute_loss(self, criterion, logits, target, batch): method feed_batch (line 201) | def feed_batch(self, batch) -> torch.LongTensor: method evaluate_dataloader (line 206) | def evaluate_dataloader(self, method build_model (line 249) | def build_model(self, transformer, training=True, **kwargs) -> torch.n... method build_dataloader (line 259) | def build_dataloader(self, data, batch_size, shuffle, device, text_a_k... method build_dataset (line 310) | def build_dataset(self, data) -> TransformableDataset: method predict (line 321) | def predict(self, data: Union[str, List[str]], batch_size: int = None,... method fit (line 356) | def fit(self, trn_data, dev_data, save_dir, method build_vocabs (line 378) | def build_vocabs(self, trn, logger, **kwargs): FILE: hanlp/components/classifiers/transformer_classifier_hf.py class TransformerClassifierHF (line 17) | class TransformerClassifierHF(TorchComponent): method __init__ (line 18) | def __init__(self, **kwargs) -> None: method build_dataloader (line 22) | def build_dataloader(self, data, sampler_builder=None, shuffle=False, ... method build_optimizer (line 38) | def build_optimizer(self, **kwargs): method build_criterion (line 41) | def build_criterion(self, **kwargs): method build_metric (line 44) | def build_metric(self, **kwargs): method execute_training_loop (line 47) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 51) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 54) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method load_vocabs (line 57) | def load_vocabs(self, save_dir, filename='vocabs.json'): method load_weights (line 60) | def load_weights(self, save_dir, filename='model.pt', **kwargs): method build_model (line 63) | def build_model(self, training=True, save_dir=None, **kwargs) -> torch... method predict (line 66) | def predict(self, text: Union[str, List[str]], topk=False, prob=False,... method labels (line 124) | def labels(self): FILE: hanlp/components/classifiers/transformer_classifier_tf.py class TransformerTextTransform (line 17) | class TransformerTextTransform(TableTransform): method __init__ (line 19) | def __init__(self, config: SerializableDict = None, map_x=False, map_y... method inputs_to_samples (line 24) | def inputs_to_samples(self, inputs, gold=False): method create_types_shapes_values (line 74) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method x_to_idx (line 81) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: method y_to_idx (line 85) | def y_to_idx(self, y) -> tf.Tensor: method Y_to_outputs (line 96) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... method input_is_single_sample (line 106) | def input_is_single_sample(self, input: Any) -> bool: class TransformerClassifierTF (line 110) | class TransformerClassifierTF(KerasComponent): method __init__ (line 112) | def __init__(self, bert_text_transform=None) -> None: method fit (line 120) | def fit(self, trn_data: Any, dev_data: Any, save_dir: str, transformer... method evaluate_output (line 125) | def evaluate_output(self, tst_data, out, num_batches, metric): method _y_id_to_str (line 144) | def _y_id_to_str(self, Y_pred) -> str: method build_loss (line 147) | def build_loss(self, loss, **kwargs): method build_optimizer (line 159) | def build_optimizer(self, optimizer, use_amp, train_steps, warmup_step... method build_model (line 177) | def build_model(self, transformer, max_length, **kwargs): method build_vocab (line 182) | def build_vocab(self, trn_data, logger): method build_metrics (line 188) | def build_metrics(self, metrics, logger, **kwargs): FILE: hanlp/components/classifiers/transformer_regression_hf.py class TransformerRegressionHF (line 17) | class TransformerRegressionHF(TorchComponent): method __init__ (line 18) | def __init__(self, **kwargs) -> None: method build_dataloader (line 22) | def build_dataloader(self, data, sampler_builder=None, shuffle=False, ... method build_optimizer (line 38) | def build_optimizer(self, **kwargs): method build_criterion (line 41) | def build_criterion(self, **kwargs): method build_metric (line 44) | def build_metric(self, **kwargs): method execute_training_loop (line 47) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 51) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 54) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method load_vocabs (line 57) | def load_vocabs(self, save_dir, filename='vocabs.json'): method load_weights (line 60) | def load_weights(self, save_dir, filename='model.pt', **kwargs): method build_model (line 63) | def build_model(self, training=True, save_dir=None, **kwargs) -> torch... method predict (line 66) | def predict(self, text: Union[str, List[str]], **kwargs): FILE: hanlp/components/distillation/distillable_component.py class DistillableComponent (line 15) | class DistillableComponent(TorchComponent, ABC): method build_teacher (line 18) | def build_teacher(self, teacher: str, devices) -> TorchComponent: method distill (line 21) | def distill(self, method _savable_config (line 50) | def _savable_config(self): FILE: hanlp/components/distillation/losses.py function kd_mse_loss (line 10) | def kd_mse_loss(logits_S, logits_T, temperature=1): function kd_ce_loss (line 26) | def kd_ce_loss(logits_S, logits_T, temperature=1): function att_mse_loss (line 43) | def att_mse_loss(attention_S, attention_T, mask=None): function att_mse_sum_loss (line 64) | def att_mse_sum_loss(attention_S, attention_T, mask=None): function att_ce_loss (line 89) | def att_ce_loss(attention_S, attention_T, mask=None): function att_ce_mean_loss (line 110) | def att_ce_mean_loss(attention_S, attention_T, mask=None): function hid_mse_loss (line 134) | def hid_mse_loss(state_S, state_T, mask=None): function cos_loss (line 153) | def cos_loss(state_S, state_T, mask=None): function pkd_loss (line 176) | def pkd_loss(state_S, state_T, mask=None): function fsp_loss (line 194) | def fsp_loss(state_S, state_T, mask=None): function mmd_loss (line 237) | def mmd_loss(state_S, state_T, mask=None): class KnowledgeDistillationLoss (line 276) | class KnowledgeDistillationLoss(AutoConfigurable): method __init__ (line 277) | def __init__(self, name) -> None: method __call__ (line 284) | def __call__(self, *args, **kwargs): FILE: hanlp/components/distillation/schedulers.py function linear_growth_weight_scheduler (line 11) | def linear_growth_weight_scheduler(x): function linear_decay_weight_scheduler (line 15) | def linear_decay_weight_scheduler(x): function constant_temperature_scheduler (line 19) | def constant_temperature_scheduler(logits_S, logits_T, base_temperature): function flsw_temperature_scheduler_builder (line 26) | def flsw_temperature_scheduler_builder(beta, gamma, eps=1e-4, *args): function cwsm_temperature_scheduler_builder (line 44) | def cwsm_temperature_scheduler_builder(beta, *args): class LinearTeacherAnnealingScheduler (line 61) | class LinearTeacherAnnealingScheduler(object): method __init__ (line 62) | def __init__(self, num_training_steps: int) -> None: method step (line 67) | def step(self): method __float__ (line 70) | def __float__(self): class TemperatureScheduler (line 74) | class TemperatureScheduler(ABC, AutoConfigurable): method __init__ (line 76) | def __init__(self, base_temperature) -> None: method __call__ (line 80) | def __call__(self, logits_S, logits_T): method forward (line 84) | def forward(self, logits_S, logits_T): method from_name (line 88) | def from_name(name): class FunctionalScheduler (line 98) | class FunctionalScheduler(TemperatureScheduler): method __init__ (line 100) | def __init__(self, scheduler_func, base_temperature) -> None: method forward (line 104) | def forward(self, logits_S, logits_T): class ConstantScheduler (line 108) | class ConstantScheduler(TemperatureScheduler): method forward (line 109) | def forward(self, logits_S, logits_T): class FlswScheduler (line 113) | class FlswScheduler(FunctionalScheduler): method __init__ (line 114) | def __init__(self, beta=1, gamma=1, eps=1e-4, base_temperature=8): class CwsmScheduler (line 121) | class CwsmScheduler(FunctionalScheduler): method __init__ (line 122) | def __init__(self, beta=1, base_temperature=8): FILE: hanlp/components/eos/ngram.py class NgramSentenceBoundaryDetectionModel (line 22) | class NgramSentenceBoundaryDetectionModel(nn.Module): method __init__ (line 24) | def __init__(self, method forward (line 58) | def forward(self, x: torch.Tensor): class NgramSentenceBoundaryDetector (line 69) | class NgramSentenceBoundaryDetector(TorchComponent): method __init__ (line 71) | def __init__(self, **kwargs) -> None: method build_optimizer (line 87) | def build_optimizer(self, **kwargs): method build_criterion (line 91) | def build_criterion(self, **kwargs): method build_metric (line 94) | def build_metric(self, **kwargs): method execute_training_loop (line 97) | def execute_training_loop(self, method fit_dataloader (line 124) | def fit_dataloader(self, method compute_loss (line 150) | def compute_loss(self, prediction, batch, criterion): method evaluate_dataloader (line 155) | def evaluate_dataloader(self, method build_model (line 178) | def build_model(self, training=True, **kwargs) -> torch.nn.Module: method build_dataloader (line 182) | def build_dataloader(self, data, batch_size, shuffle, device, logger: ... method predict (line 191) | def predict(self, data: Union[str, List[str]], batch_size: int = None,... method fit (line 245) | def fit(self, method build_vocabs (line 273) | def build_vocabs(self, dataset: SentenceBoundaryDetectionDataset, logg... method reset_metrics (line 297) | def reset_metrics(self, metrics): method report_metrics (line 300) | def report_metrics(self, loss, metrics): method update_metrics (line 303) | def update_metrics(self, batch: dict, prediction: torch.FloatTensor, m... method feed_batch (line 309) | def feed_batch(self, batch): FILE: hanlp/components/lambda_wrapper.py class LambdaComponent (line 10) | class LambdaComponent(Component): method __init__ (line 11) | def __init__(self, function: Callable) -> None: method predict (line 18) | def predict(self, data: Any, **kwargs): method from_config (line 25) | def from_config(meta: dict, **kwargs): FILE: hanlp/components/lemmatizer.py function add_lemma_rules_to_sample (line 11) | def add_lemma_rules_to_sample(sample: dict): class TransformerLemmatizer (line 20) | class TransformerLemmatizer(TransformerTagger): method __init__ (line 22) | def __init__(self, **kwargs) -> None: method build_dataset (line 30) | def build_dataset(self, data, transform=None, **kwargs): method prediction_to_human (line 36) | def prediction_to_human(self, pred, vocab: List[str], batch, token=None): FILE: hanlp/components/lm/mlm.py class MaskedLanguageModelDataset (line 22) | class MaskedLanguageModelDataset(TransformableDataset): method load_file (line 24) | def load_file(self, filepath: str): class MaskedLanguageModel (line 28) | class MaskedLanguageModel(TorchComponent): method __init__ (line 30) | def __init__(self, **kwargs) -> None: method build_dataloader (line 34) | def build_dataloader(self, data, batch_size, shuffle=False, device=Non... method build_optimizer (line 49) | def build_optimizer(self, **kwargs): method build_criterion (line 52) | def build_criterion(self, **kwargs): method build_metric (line 55) | def build_metric(self, **kwargs): method execute_training_loop (line 58) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 62) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 65) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method build_model (line 68) | def build_model(self, training=True, transformer=None, **kwargs) -> to... method input_is_flat (line 71) | def input_is_flat(self, masked_sents): method predict (line 74) | def predict(self, masked_sents: Union[str, List[str]], batch_size=32, ... method load_config (line 105) | def load_config(self, save_dir, filename='config.json', **kwargs): method load_vocabs (line 108) | def load_vocabs(self, save_dir, filename='vocabs.json'): method load_weights (line 111) | def load_weights(self, save_dir, filename='model.pt', **kwargs): FILE: hanlp/components/mtl/multi_task_learning.py class MultiTaskModel (line 38) | class MultiTaskModel(torch.nn.Module): method __init__ (line 40) | def __init__(self, class MultiTaskDataLoader (line 52) | class MultiTaskDataLoader(DataLoader): method __init__ (line 54) | def __init__(self, training=True, tau: float = 0.8, **dataloaders) -> ... method __len__ (line 62) | def __len__(self) -> int: method __iter__ (line 67) | def __iter__(self): method sampling_weights (line 81) | def sampling_weights(self): method sizes (line 89) | def sizes(self): class MultiTaskLearning (line 93) | class MultiTaskLearning(TorchComponent): method __init__ (line 95) | def __init__(self, **kwargs) -> None: method build_dataloader (line 114) | def build_dataloader(self, method build_transform (line 198) | def build_transform(self, task: Task) -> Tuple[TransformerSequenceToke... method build_optimizer (line 208) | def build_optimizer(self, method build_criterion (line 265) | def build_criterion(self, **kwargs): method build_metric (line 268) | def build_metric(self, **kwargs): method execute_training_loop (line 276) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method _close_dataloader (line 311) | def _close_dataloader(self, d): method fit_dataloader (line 323) | def fit_dataloader(self, method report_metrics (line 384) | def report_metrics(self, loss, metrics: MetricDict): method evaluate_dataloader (line 389) | def evaluate_dataloader(self, method build_model (line 438) | def build_model(self, training=False, **kwargs) -> torch.nn.Module: method predict (line 459) | def predict(self, method resolve_tasks (line 570) | def resolve_tasks(self, tasks, skip_tasks) -> List[Iterable[str]]: method predict_task (line 593) | def predict_task(self, task: Task, output_key, batch, results, output_... method _resolve_task_name (line 601) | def _resolve_task_name(self, dependencies): method fit (line 617) | def fit(self, method on_config_ready (line 650) | def on_config_ready(self, **kwargs): method reset_metrics (line 669) | def reset_metrics(metrics: Dict[str, Metric]): method feed_batch (line 673) | def feed_batch(self, method _encode (line 695) | def _encode(self, batch, task_name, output_dict=None, cls_is_bos=False... method decode_output (line 722) | def decode_output(self, output_dict, batch, task_name=None): method update_metrics (line 739) | def update_metrics(self, batch: Dict[str, Any], output_dict: Dict[str,... method compute_loss (line 748) | def compute_loss(self, method evaluate (line 755) | def evaluate(self, save_dir=None, logger: logging.Logger = None, batch... method save_vocabs (line 761) | def save_vocabs(self, save_dir, filename='vocabs.json'): method load_vocabs (line 765) | def load_vocabs(self, save_dir, filename='vocabs.json'): method parallelize (line 769) | def parallelize(self, devices: List[Union[int, torch.device]]): method __call__ (line 772) | def __call__(self, data, **kwargs) -> Document: method __getitem__ (line 775) | def __getitem__(self, task_name: str) -> Task: method __delitem__ (line 778) | def __delitem__(self, task_name: str): method __repr__ (line 798) | def __repr__(self): method items (line 801) | def items(self): method __setattr__ (line 804) | def __setattr__(self, key: str, value): FILE: hanlp/components/mtl/tasks/__init__.py class Task (line 27) | class Task(ConfigTracker, TorchComponent, ABC): method __init__ (line 29) | def __init__(self, method build_dataloader (line 78) | def build_dataloader(self, method build_optimizer (line 102) | def build_optimizer(self, decoder: torch.nn.Module, **kwargs): method build_batch_wise_scheduler (line 105) | def build_batch_wise_scheduler(self, decoder: torch.nn.Module, **kwargs): method compute_loss (line 109) | def compute_loss(self, method decode_output (line 117) | def decode_output(self, method update_metrics (line 124) | def update_metrics(self, method build_model (line 133) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 137) | def build_metric(self, **kwargs): method fit_dataloader (line 140) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 143) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, o... method execute_training_loop (line 146) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method compute_lens (line 151) | def compute_lens(self, data: Union[List[Dict[str, Any]], str], dataset... method feed_batch (line 175) | def feed_batch(self, method input_is_flat (line 182) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 194) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... method transform_batch (line 198) | def transform_batch(self, method _adjust_token (line 233) | def _adjust_token(self, batch, cls_is_bos, sep_is_eos, token_key): method build_samples (line 250) | def build_samples(self, inputs, cls_is_bos=False, sep_is_eos=False): method build_tokenizer (line 270) | def build_tokenizer(self, tokenizer: TransformerSequenceTokenizer): method finalize_document (line 287) | def finalize_document(self, doc: Document, task_name: str): FILE: hanlp/components/mtl/tasks/amr.py class GraphAbstractMeaningRepresentationParsing (line 31) | class GraphAbstractMeaningRepresentationParsing(Task, GraphAbstractMeani... method __init__ (line 33) | def __init__(self, method build_dataloader (line 70) | def build_dataloader(self, method compute_loss (line 94) | def compute_loss(self, method decode_output (line 104) | def decode_output(self, method update_metrics (line 111) | def update_metrics(self, method build_model (line 118) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 121) | def build_metric(self, **kwargs): method input_is_flat (line 124) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 127) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... method evaluate_dataloader (line 135) | def evaluate_dataloader(self, method feed_batch (line 150) | def feed_batch(self, method transform_batch (line 163) | def transform_batch(self, batch: Dict[str, Any], results: Dict[str, An... FILE: hanlp/components/mtl/tasks/constituency.py class CRFConstituencyParsing (line 27) | class CRFConstituencyParsing(Task, CRFConstituencyParser): method __init__ (line 28) | def __init__(self, method build_dataloader (line 78) | def build_dataloader(self, method feed_batch (line 101) | def feed_batch(self, method compute_loss (line 112) | def compute_loss(self, method decode_output (line 121) | def decode_output(self, method update_metrics (line 137) | def update_metrics(self, method build_model (line 143) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 146) | def build_metric(self, **kwargs): method input_is_flat (line 149) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 152) | def prediction_to_result(self, prediction: List, batch: Dict[str, Any]... method finalize_document (line 155) | def finalize_document(self, doc: Document, task_name: str): method build_samples (line 168) | def build_samples(self, inputs, cls_is_bos=False, sep_is_eos=False): FILE: hanlp/components/mtl/tasks/dep.py class BiaffineDependencyParsing (line 26) | class BiaffineDependencyParsing(Task, BiaffineDependencyParser): method __init__ (line 27) | def __init__(self, method update_metrics (line 84) | def update_metrics(self, batch: Dict[str, Any], method decode_output (line 90) | def decode_output(self, method compute_loss (line 98) | def compute_loss(self, batch: Dict[str, Any], method build_model (line 106) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 110) | def build_metric(self, **kwargs): method build_dataloader (line 113) | def build_dataloader(self, data, transform: TransformList = None, trai... method feed_batch (line 133) | def feed_batch(self, h: torch.FloatTensor, batch: Dict[str, torch.Tens... method build_optimizer (line 140) | def build_optimizer(self, decoder: torch.nn.Module, **kwargs): method input_is_flat (line 149) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 152) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... method build_samples (line 165) | def build_samples(self, inputs, cls_is_bos=False, sep_is_eos=False): FILE: hanlp/components/mtl/tasks/dep_2nd.py class BiaffineSecondaryDependencyDecoder (line 22) | class BiaffineSecondaryDependencyDecoder(torch.nn.Module): method __init__ (line 23) | def __init__(self, hidden_size, config) -> None: method forward (line 28) | def forward(self, contextualized_embeddings: torch.FloatTensor, batch:... class BiaffineSecondaryDependencyParsing (line 38) | class BiaffineSecondaryDependencyParsing(Task, BiaffineSecondaryParser): method __init__ (line 40) | def __init__(self, trn: str = None, dev: str = None, tst: str = None, ... method build_dataloader (line 59) | def build_dataloader(self, data, transform: Callable = None, training=... method update_metrics (line 72) | def update_metrics(self, batch: Dict[str, Any], method decode_output (line 79) | def decode_output(self, output: Dict[str, Any], batch: Dict[str, Any],... method compute_loss (line 83) | def compute_loss(self, batch: Dict[str, Any], method build_model (line 89) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 92) | def build_metric(self, **kwargs): method build_criterion (line 95) | def build_criterion(self, **kwargs): method build_optimizer (line 98) | def build_optimizer(self, decoder: torch.nn.Module, **kwargs): method input_is_flat (line 106) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 109) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... FILE: hanlp/components/mtl/tasks/lem.py class LinearDecoder (line 19) | class LinearDecoder(torch.nn.Module): method __init__ (line 20) | def __init__(self, method forward (line 26) | def forward(self, contextualized_embeddings: torch.FloatTensor, batch:... class TransformerLemmatization (line 30) | class TransformerLemmatization(Task, TransformerLemmatizer): method __init__ (line 32) | def __init__(self, method build_dataloader (line 76) | def build_dataloader(self, method compute_loss (line 97) | def compute_loss(self, method decode_output (line 103) | def decode_output(self, method update_metrics (line 111) | def update_metrics(self, method build_model (line 118) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 121) | def build_metric(self, **kwargs): method input_is_flat (line 124) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 127) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... FILE: hanlp/components/mtl/tasks/ner/biaffine_ner.py class BiaffineNamedEntityRecognition (line 23) | class BiaffineNamedEntityRecognition(Task, BiaffineNamedEntityRecognizer): method __init__ (line 25) | def __init__(self, trn: str = None, dev: str = None, tst: str = None, ... method update_metrics (line 56) | def update_metrics(self, batch: Dict[str, Any], method decode_output (line 61) | def decode_output(self, method compute_loss (line 69) | def compute_loss(self, batch: Dict[str, Any], method build_dataloader (line 74) | def build_dataloader(self, data, method build_model (line 93) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 97) | def build_metric(self, **kwargs): method input_is_flat (line 100) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 103) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... FILE: hanlp/components/mtl/tasks/ner/tag_ner.py class LinearCRFDecoder (line 22) | class LinearCRFDecoder(torch.nn.Module): method __init__ (line 23) | def __init__(self, method forward (line 33) | def forward(self, contextualized_embeddings: torch.FloatTensor, batch:... class TaggingNamedEntityRecognition (line 39) | class TaggingNamedEntityRecognition(Task, TransformerNamedEntityRecogniz... method __init__ (line 41) | def __init__(self, method build_dataloader (line 112) | def build_dataloader(self, method compute_loss (line 135) | def compute_loss(self, method decode_output (line 141) | def decode_output(self, method update_metrics (line 149) | def update_metrics(self, method build_model (line 157) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 160) | def build_metric(self, **kwargs): method input_is_flat (line 163) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 166) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... FILE: hanlp/components/mtl/tasks/pos.py class LinearCRFDecoder (line 22) | class LinearCRFDecoder(torch.nn.Module): method __init__ (line 23) | def __init__(self, method forward (line 38) | def forward(self, contextualized_embeddings: torch.FloatTensor, batch:... class TransformerTagging (line 54) | class TransformerTagging(Task, TransformerTagger): method __init__ (line 56) | def __init__(self, method build_dataloader (line 113) | def build_dataloader(self, method compute_loss (line 134) | def compute_loss(self, method decode_output (line 140) | def decode_output(self, method update_metrics (line 148) | def update_metrics(self, method build_model (line 155) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 158) | def build_metric(self, **kwargs): method input_is_flat (line 161) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 164) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... FILE: hanlp/components/mtl/tasks/sdp.py class BiaffineSemanticDependencyParsing (line 24) | class BiaffineSemanticDependencyParsing(Task, BiaffineSemanticDependency... method __init__ (line 25) | def __init__(self, method update_metrics (line 85) | def update_metrics(self, batch: Dict[str, Any], method decode_output (line 91) | def decode_output(self, method compute_loss (line 99) | def compute_loss(self, batch: Dict[str, Any], method build_model (line 107) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 111) | def build_metric(self, **kwargs): method build_dataloader (line 114) | def build_dataloader(self, data, transform: TransformList = None, trai... method feed_batch (line 130) | def feed_batch(self, h: torch.FloatTensor, batch: Dict[str, torch.Tens... method build_optimizer (line 140) | def build_optimizer(self, decoder: torch.nn.Module, **kwargs): method input_is_flat (line 149) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 152) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... method build_samples (line 169) | def build_samples(self, inputs, cls_is_bos=False, sep_is_eos=False): FILE: hanlp/components/mtl/tasks/srl/bio_srl.py class SpanBIOSemanticRoleLabeling (line 22) | class SpanBIOSemanticRoleLabeling(Task, SpanBIOSemanticRoleLabeler): method __init__ (line 24) | def __init__(self, method build_dataloader (line 67) | def build_dataloader(self, data, transform: Callable = None, training=... method compute_loss (line 79) | def compute_loss(self, batch: Dict[str, Any], method decode_output (line 85) | def decode_output(self, method update_metrics (line 93) | def update_metrics(self, batch: Dict[str, Any], method build_model (line 98) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method feed_batch (line 107) | def feed_batch(self, h: torch.FloatTensor, batch: Dict[str, torch.Tens... method build_metric (line 119) | def build_metric(self, **kwargs): method input_is_flat (line 122) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 125) | def prediction_to_result(self, prediction: List, batch: Dict[str, Any]... FILE: hanlp/components/mtl/tasks/srl/rank_srl.py class SpanRankingSemanticRoleLabeling (line 21) | class SpanRankingSemanticRoleLabeling(Task, SpanRankingSemanticRoleLabel... method __init__ (line 23) | def __init__(self, trn: str = None, dev: str = None, tst: str = None, ... method build_dataloader (line 75) | def build_dataloader(self, data, transform: Callable = None, training=... method update_metrics (line 85) | def update_metrics(self, batch: Dict[str, Any], method decode_output (line 91) | def decode_output(self, method compute_loss (line 98) | def compute_loss(self, batch: Dict[str, Any], method build_model (line 103) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 106) | def build_metric(self, **kwargs): method build_criterion (line 110) | def build_criterion(self, **kwargs): method input_is_flat (line 113) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 116) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... FILE: hanlp/components/mtl/tasks/tok/reg_tok.py function generate_token_span_tuple (line 23) | def generate_token_span_tuple(sample: dict): class RegressionTokenizingDecoder (line 37) | class RegressionTokenizingDecoder(torch.nn.Linear): method __init__ (line 39) | def __init__(self, in_features: int, out_features: int = 1, bias: bool... method forward (line 43) | def forward(self, input: Tensor, **kwargs) -> Tensor: class RegressionTokenization (line 47) | class RegressionTokenization(Task): method __init__ (line 49) | def __init__(self, trn: str = None, dev: str = None, tst: str = None, ... method build_criterion (line 55) | def build_criterion(self, **kwargs): method build_metric (line 58) | def build_metric(self, **kwargs): method build_model (line 62) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method predict (line 65) | def predict(self, data: Union[str, List[str]], batch_size: int = None,... method build_dataloader (line 68) | def build_dataloader(self, method decode_output (line 95) | def decode_output(self, method update_metrics (line 101) | def update_metrics(self, batch: Dict[str, Any], method compute_loss (line 106) | def compute_loss(self, batch: Dict[str, Any], FILE: hanlp/components/mtl/tasks/tok/tag_tok.py class LinearCRFDecoder (line 23) | class LinearCRFDecoder(torch.nn.Module): method __init__ (line 24) | def __init__(self, method forward (line 32) | def forward(self, contextualized_embeddings: torch.FloatTensor, batch:... class TaggingTokenization (line 36) | class TaggingTokenization(Task, TransformerTaggingTokenizer): method __init__ (line 38) | def __init__(self, method build_dataloader (line 95) | def build_dataloader(self, data, transform: TransformList = None, trai... method compute_loss (line 116) | def compute_loss(self, method decode_output (line 122) | def decode_output(self, output: Union[torch.Tensor, Dict[str, torch.Te... method update_metrics (line 126) | def update_metrics(self, batch: Dict[str, Any], method build_model (line 131) | def build_model(self, encoder_size, training=True, **kwargs) -> torch.... method build_metric (line 134) | def build_metric(self, **kwargs): method build_criterion (line 137) | def build_criterion(self, model=None, **kwargs): method input_is_flat (line 140) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 143) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... method build_tokenizer (line 146) | def build_tokenizer(self, tokenizer: TransformerSequenceTokenizer): method build_samples (line 164) | def build_samples(self, inputs, cls_is_bos=False, sep_is_eos=False): method dict_force (line 168) | def dict_force(self) -> DictInterface: method dict_force (line 172) | def dict_force(self, dictionary: Union[DictInterface, Union[Dict[str, ... method dict_combine (line 178) | def dict_combine(self) -> DictInterface: method dict_combine (line 182) | def dict_combine(self, dictionary: Union[DictInterface, Union[Dict[str... method transform_batch (line 186) | def transform_batch(self, batch: Dict[str, Any], results: Dict[str, An... FILE: hanlp/components/mtl/tasks/ud.py class UniversalDependenciesParsing (line 24) | class UniversalDependenciesParsing(Task, UniversalDependenciesParser): method __init__ (line 26) | def __init__(self, method build_dataloader (line 73) | def build_dataloader(self, data, transform: Callable = None, training=... method compute_loss (line 92) | def compute_loss(self, batch: Dict[str, Any], method decode_output (line 97) | def decode_output(self, output: Union[torch.Tensor, Dict[str, torch.Te... method update_metrics (line 102) | def update_metrics(self, batch: Dict[str, Any], method build_model (line 108) | def build_model(self, method build_metric (line 128) | def build_metric(self, **kwargs): method input_is_flat (line 131) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 134) | def prediction_to_result(self, prediction: Dict[str, Any], batch: Dict... method feed_batch (line 137) | def feed_batch(self, h: torch.FloatTensor, batch: Dict[str, torch.Tens... method finalize_document (line 146) | def finalize_document(self, doc: Document, task_name: str): FILE: hanlp/components/ner/biaffine_ner/biaffine_ner.py class BiaffineNamedEntityRecognizer (line 24) | class BiaffineNamedEntityRecognizer(TorchComponent): method __init__ (line 26) | def __init__(self, **kwargs) -> None: method build_optimizer (line 38) | def build_optimizer(self, method use_transformer (line 67) | def use_transformer(self): method _get_transformer (line 70) | def _get_transformer(self): method build_criterion (line 73) | def build_criterion(self, **kwargs): method build_metric (line 77) | def build_metric(self, **kwargs) -> F1: method execute_training_loop (line 80) | def execute_training_loop(self, method fit_dataloader (line 115) | def fit_dataloader(self, method evaluate_dataloader (line 151) | def evaluate_dataloader(self, method build_model (line 186) | def build_model(self, method build_dataloader (line 198) | def build_dataloader(self, data, batch_size, shuffle, device, logger: ... method build_dataset (line 223) | def build_dataset(self, data, vocabs, transform): method predict (line 232) | def predict(self, data: Union[List[str], List[List[str]]], batch_size:... method prediction_to_result (line 253) | def prediction_to_result(token, prediction, predictions: List, ret_tok... method input_is_flat (line 267) | def input_is_flat(data): method fit (line 271) | def fit(self, method build_vocabs (line 338) | def build_vocabs(self, dataset, logger, vocabs, lock=True, label_vocab... method reset_metrics (line 350) | def reset_metrics(self, metrics): method report_metrics (line 353) | def report_metrics(self, loss, metrics): method feed_batch (line 356) | def feed_batch(self, batch) -> Dict[str, Any]: method update_metrics (line 361) | def update_metrics(self, batch: dict, prediction: Union[Dict, List], m... method get_pred_ner (line 368) | def get_pred_ner(self, sentences, span_scores): FILE: hanlp/components/ner/biaffine_ner/biaffine_ner_model.py function initializer_1d (line 12) | def initializer_1d(input_tensor, initializer): class BiaffineNamedEntityRecognitionModel (line 19) | class BiaffineNamedEntityRecognitionModel(nn.Module): method __init__ (line 21) | def __init__(self, config, embed: torch.nn.Module, context_layer: torc... method forward (line 37) | def forward(self, class BiaffineNamedEntityRecognitionDecoder (line 54) | class BiaffineNamedEntityRecognitionDecoder(nn.Module): method __init__ (line 55) | def __init__(self, hidden_size, ffnn_size, label_space_size, loss_redu... method forward (line 76) | def forward(self, contextualized_embeddings: torch.FloatTensor, batch:... method get_dense_span_labels (line 86) | def get_dense_span_labels(self, span_starts, span_ends, span_labels, m... method decode (line 101) | def decode(self, contextualized_embeddings, gold_starts, gold_ends, go... FILE: hanlp/components/ner/ner_tf.py class IOBES_NamedEntityRecognizer (line 20) | class IOBES_NamedEntityRecognizer(KerasComponent, ABC): method predict_batch (line 22) | def predict_batch(self, batch, inputs=None): class IOBES_Transform (line 27) | class IOBES_Transform(Transform): method Y_to_outputs (line 29) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... class RNNNamedEntityRecognizerTF (line 35) | class RNNNamedEntityRecognizerTF(RNNTaggerTF, IOBES_NamedEntityRecognizer): method fit (line 37) | def fit(self, trn_data: str, dev_data: str = None, save_dir: str = Non... method build_loss (line 48) | def build_loss(self, loss, **kwargs): class NgramConvNamedEntityRecognizerTF (line 56) | class NgramConvNamedEntityRecognizerTF(NgramConvTaggerTF, IOBES_NamedEnt... method fit (line 58) | def fit(self, trn_data: Any, dev_data: Any, save_dir: str, word_embed:... class IOBES_TransformerTransform (line 69) | class IOBES_TransformerTransform(IOBES_Transform, TransformerTransform): class TransformerNamedEntityRecognizerTF (line 73) | class TransformerNamedEntityRecognizerTF(TransformerTaggerTF): method __init__ (line 75) | def __init__(self, transform: TransformerTransform = None) -> None: method fit (line 80) | def fit(self, trn_data, dev_data, save_dir, transformer, optimizer='ad... FILE: hanlp/components/ner/rnn_ner.py class RNNNamedEntityRecognizer (line 14) | class RNNNamedEntityRecognizer(RNNTagger): method __init__ (line 16) | def __init__(self, **kwargs) -> None: method build_metric (line 24) | def build_metric(self, **kwargs): method evaluate_dataloader (line 27) | def evaluate_dataloader(self, data, criterion, logger=None, ratio_widt... method fit (line 33) | def fit(self, trn_data, dev_data, save_dir, batch_size=50, epochs=100,... method update_metrics (line 41) | def update_metrics(self, metric, logits, y, mask, batch, prediction): method predict (line 47) | def predict(self, tokens: Any, batch_size: int = None, **kwargs): method predict_data (line 50) | def predict_data(self, data, batch_size, **kwargs): method save_config (line 65) | def save_config(self, save_dir, filename='config.json'): FILE: hanlp/components/ner/transformer_ner.py class TransformerNamedEntityRecognizer (line 18) | class TransformerNamedEntityRecognizer(TransformerTagger): method __init__ (line 20) | def __init__(self, **kwargs) -> None: method build_metric (line 35) | def build_metric(self, **kwargs): method update_metrics (line 39) | def update_metrics(self, metric, logits, y, mask, batch, prediction): method decode_output (line 46) | def decode_output(self, logits, mask, batch, model=None): method tag_to_span (line 51) | def tag_to_span(self, batch_tags, batch): method decorate_spans (line 104) | def decorate_spans(self, spans, batch): method generate_prediction_filename (line 114) | def generate_prediction_filename(self, tst_data, save_dir): method prediction_to_human (line 117) | def prediction_to_human(self, pred, vocab, batch): method input_is_flat (line 120) | def input_is_flat(self, tokens): method fit (line 123) | def fit(self, trn_data, dev_data, save_dir, transformer, method build_vocabs (line 204) | def build_vocabs(self, trn, logger, **kwargs): method build_dataset (line 214) | def build_dataset(self, data, transform=None, **kwargs): method dict_whitelist (line 223) | def dict_whitelist(self) -> DictInterface: method dict_whitelist (line 227) | def dict_whitelist(self, dictionary: Union[DictInterface, Union[Dict[s... method dict_blacklist (line 233) | def dict_blacklist(self) -> DictInterface: method dict_blacklist (line 237) | def dict_blacklist(self, dictionary: Union[DictInterface, Union[Dict[s... FILE: hanlp/components/parsers/alg.py function kmeans (line 29) | def kmeans(x, k, max_it=32): function eisner (line 102) | def eisner(scores, mask): function backtrack (line 195) | def backtrack(p_i, p_c, heads, i, j, complete): function stripe (line 209) | def stripe(x, n, w, offset=(0, 0), dim=1): function cky (line 246) | def cky(scores, mask): function istree (line 318) | def istree(sequence, proj=False, multiroot=False): function tarjan (line 352) | def tarjan(sequence): function chuliu_edmonds (line 408) | def chuliu_edmonds(s): function mst (line 507) | def mst(scores, mask, multiroot=False): function eisner2o (line 566) | def eisner2o(scores, mask): function pad (line 721) | def pad(tensors, padding_value=0, total_length=None): function decode_dep (line 733) | def decode_dep(s_arc, mask, tree=False, proj=False): FILE: hanlp/components/parsers/alg_tf.py function nonzero (line 11) | def nonzero(t: tf.Tensor) -> tf.Tensor: function view (line 15) | def view(t: tf.Tensor, *dims) -> tf.Tensor: function arange (line 19) | def arange(n: int) -> tf.Tensor: function randperm (line 23) | def randperm(n: int) -> tf.Tensor: function tolist (line 27) | def tolist(t: tf.Tensor) -> List: function kmeans (line 33) | def kmeans(x, k, seed=None): class Tarjan (line 91) | class Tarjan: method __init__ (line 94) | def __init__(self, prediction, tokens): method strongconnect (line 121) | def strongconnect(self, v, index, stack): method edges (line 158) | def edges(self): method vertices (line 162) | def vertices(self): method indices (line 166) | def indices(self): method SCCs (line 170) | def SCCs(self): function tarjan (line 174) | def tarjan(parse_probs, length, tokens_to_keep, ensure_tree=True): function rel_argmax (line 259) | def rel_argmax(rel_probs, length, root, ensure_tree=True): FILE: hanlp/components/parsers/biaffine/biaffine.py class Biaffine (line 28) | class Biaffine(nn.Module): method __init__ (line 54) | def __init__(self, n_in, n_out=1, bias_x=True, bias_y=True): method __repr__ (line 65) | def __repr__(self): method reset_parameters (line 74) | def reset_parameters(self): method forward (line 77) | def forward(self, x, y): FILE: hanlp/components/parsers/biaffine/biaffine_2nd_dep.py class BiaffineSeparateDecoder (line 25) | class BiaffineSeparateDecoder(torch.nn.Module): method __init__ (line 27) | def __init__(self, hidden_size, config) -> None: method forward (line 40) | def forward(self, x, mask): class BiaffineJointDecoder (line 44) | class BiaffineJointDecoder(BiaffineDecoder): method __init__ (line 45) | def __init__(self, hidden_size, config) -> None: method forward (line 56) | def forward(self, x, mask=None, **kwargs: Any): class BiaffineSecondaryModel (line 63) | class BiaffineSecondaryModel(torch.nn.Module): method __init__ (line 65) | def __init__(self, config, pretrained_embed: torch.Tensor = None, tran... method forward (line 72) | def forward(self, class BiaffineSecondaryParser (line 82) | class BiaffineSecondaryParser(BiaffineDependencyParser): method __init__ (line 84) | def __init__(self) -> None: method build_dataset (line 88) | def build_dataset(self, data, bos_transform=None): method build_criterion (line 99) | def build_criterion(self, **kwargs): method fit (line 103) | def fit(self, trn_data, dev_data, save_dir, feat=None, n_embed=100, pr... method build_vocabs (line 115) | def build_vocabs(self, dataset, logger=None, transformer=None): method create_model (line 122) | def create_model(self, pretrained_embed, transformer): method compute_loss (line 125) | def compute_loss(self, arc_scores, rel_scores, arcs, rels, mask, crite... method compute_mask (line 136) | def compute_mask(arc_scores_2nd, batch, mask_1st): method unpack_scores (line 142) | def unpack_scores(self, arc_scores, rel_scores): method get_pad_dict (line 147) | def get_pad_dict(self): method decode (line 152) | def decode(self, arc_scores, rel_scores, mask, batch=None, predicting=... method update_metric (line 184) | def update_metric(self, arc_preds, rel_preds, arcs, rels, mask, puncts... method build_metric (line 192) | def build_metric(self, **kwargs): method collect_outputs_extend (line 197) | def collect_outputs_extend(self, predictions: list, arc_preds, rel_pre... method predictions_to_human (line 200) | def predictions_to_human(self, predictions, outputs, data, use_pos, co... FILE: hanlp/components/parsers/biaffine/biaffine_dep.py class BiaffineDependencyParser (line 33) | class BiaffineDependencyParser(TorchComponent): method __init__ (line 34) | def __init__(self) -> None: method predict (line 41) | def predict(self, data: Any, batch_size=None, batch_max_tokens=None, c... method build_samples (line 70) | def build_samples(self, data, use_pos=None): method input_is_flat (line 84) | def input_is_flat(self, data, use_pos=None): method before_outputs (line 93) | def before_outputs(self, data): method post_outputs (line 100) | def post_outputs(self, predictions, data, order, use_pos, build_data, ... method predictions_to_human (line 108) | def predictions_to_human(self, predictions, outputs, data, use_pos, co... method collect_outputs (line 126) | def collect_outputs(self, arc_scores, rel_scores, mask, batch, predict... method collect_outputs_extend (line 138) | def collect_outputs_extend(self, predictions: list, arc_preds, rel_pre... method use_pos (line 143) | def use_pos(self): method fit (line 146) | def fit(self, trn_data, dev_data, save_dir, method execute_training_loop (line 194) | def execute_training_loop(self, trn, dev, devices, epochs, logger, pat... method build_optimizer (line 235) | def build_optimizer(self, epochs, trn, gradient_accumulation, **kwargs): method build_transformer_tokenizer (line 282) | def build_transformer_tokenizer(self): method build_dataloader (line 292) | def build_dataloader(self, method cache_dataset (line 330) | def cache_dataset(self, dataset, timer, training=False, logger=None): method get_pad_dict (line 334) | def get_pad_dict(self): method build_dataset (line 337) | def build_dataset(self, data, bos_transform=None): method build_tokenizer_transform (line 350) | def build_tokenizer_transform(self): method build_vocabs (line 357) | def build_vocabs(self, dataset, logger=None, transformer=None): method build_model (line 403) | def build_model(self, training=True, **kwargs) -> torch.nn.Module: method create_model (line 410) | def create_model(self, pretrained_embed, transformer): method build_embeddings (line 416) | def build_embeddings(self, training=True): method fit_dataloader (line 427) | def fit_dataloader(self, method _step (line 460) | def _step(self, optimizer, scheduler, transformer_optimizer, transform... method feed_batch (line 472) | def feed_batch(self, batch): method _report (line 484) | def _report(self, loss, metric: AttachmentScore): method compute_loss (line 487) | def compute_loss(self, arc_scores, rel_scores, arcs, rels, mask, crite... method evaluate_dataloader (line 499) | def evaluate_dataloader(self, loader: PadSequenceDataLoader, criterion... method update_metric (line 537) | def update_metric(self, arc_preds, rel_preds, arcs, rels, mask, puncts... method decode (line 543) | def decode(self, arc_scores, rel_scores, mask, batch=None): method build_criterion (line 554) | def build_criterion(self, **kwargs): method build_metric (line 558) | def build_metric(self, **kwargs): method on_config_ready (line 561) | def on_config_ready(self, **kwargs): method prediction_to_head_rel (line 565) | def prediction_to_head_rel(self, arcs: torch.LongTensor, rels: torch.L... FILE: hanlp/components/parsers/biaffine/biaffine_model.py class EncoderWithContextualLayer (line 18) | class EncoderWithContextualLayer(nn.Module): method __init__ (line 19) | def __init__(self, method forward (line 89) | def forward(self, words, feats, input_ids, token_span, mask, lens): method run_rnn (line 143) | def run_rnn(self, embed, lens, seq_len): method run_transformer (line 149) | def run_transformer(self, input_ids, token_span): class BiaffineDecoder (line 154) | class BiaffineDecoder(nn.Module): method __init__ (line 155) | def __init__(self, hidden_size, n_mlp_arc, n_mlp_rel, mlp_dropout, n_r... method forward (line 181) | def forward(self, x, mask=None, **kwargs: Any) -> Tuple[torch.Tensor, ... method decode (line 189) | def decode(arc_d, arc_h, rel_d, rel_h, mask, arc_attn, rel_attn): method apply_mlps (line 200) | def apply_mlps(self, x): class BiaffineDependencyModel (line 209) | class BiaffineDependencyModel(nn.Module): method __init__ (line 211) | def __init__(self, config, pretrained_embed: torch.Tensor = None, tran... method forward (line 221) | def forward(self, FILE: hanlp/components/parsers/biaffine/biaffine_sdp.py class BiaffineSemanticDependencyParser (line 20) | class BiaffineSemanticDependencyParser(BiaffineDependencyParser): method __init__ (line 21) | def __init__(self) -> None: method get_pad_dict (line 28) | def get_pad_dict(self): method build_metric (line 31) | def build_metric(self, **kwargs): method build_dataset (line 35) | def build_dataset(self, data, transform=None): method build_criterion (line 42) | def build_criterion(self, **kwargs): method feed_batch (line 45) | def feed_batch(self, batch): method convert_to_3d_puncts (line 52) | def convert_to_3d_puncts(puncts, mask): method convert_to_3d_mask (line 58) | def convert_to_3d_mask(arc_scores, mask): method compute_loss (line 64) | def compute_loss(self, arc_scores, rel_scores, arcs, rels, mask: torch... method cache_dataset (line 79) | def cache_dataset(self, dataset, timer, training=False, logger=None): method decode (line 106) | def decode(self, arc_scores, rel_scores, mask, batch=None): method collect_outputs_extend (line 134) | def collect_outputs_extend(self, predictions, arc_preds, rel_preds, le... method predictions_to_human (line 139) | def predictions_to_human(self, predictions, outputs, data, use_pos, co... method fit (line 153) | def fit(self, trn_data, dev_data, save_dir, FILE: hanlp/components/parsers/biaffine/mlp.py class MLP (line 30) | class MLP(nn.Module): method __init__ (line 46) | def __init__(self, n_in, n_out, dropout=0, activation=True): method __repr__ (line 57) | def __repr__(self): method reset_parameters (line 64) | def reset_parameters(self): method forward (line 68) | def forward(self, x): FILE: hanlp/components/parsers/biaffine/structual_attention.py class StructuralAttentionLayer (line 21) | class StructuralAttentionLayer(nn.Module): method __init__ (line 23) | def __init__(self, hidden_size, n_mlp_arc, n_mlp_rel, mlp_dropout, n_r... method forward (line 35) | def forward(self, x, mask): class StructuralAttentionModel (line 50) | class StructuralAttentionModel(nn.Module): method __init__ (line 51) | def __init__(self, method forward (line 77) | def forward(self, class MaskedTokenGenerator (line 91) | class MaskedTokenGenerator(object): method __init__ (line 93) | def __init__(self, transformer_tokenizer: PreTrainedTokenizer, mask_pr... method __call__ (line 103) | def __call__(self, tokens: torch.LongTensor, prefix_mask: torch.LongTe... class StructuralAttentionParser (line 118) | class StructuralAttentionParser(BiaffineDependencyParser): method __init__ (line 119) | def __init__(self) -> None: method build_model (line 124) | def build_model(self, training=True, **kwargs) -> torch.nn.Module: method fit (line 129) | def fit(self, trn_data, dev_data, save_dir, method feed_batch (line 165) | def feed_batch(self, batch): method on_config_ready (line 183) | def on_config_ready(self, **kwargs): method compute_loss (line 187) | def compute_loss(self, arc_scores, rel_scores, arcs, rels, mask, crite... method build_tokenizer_transform (line 201) | def build_tokenizer_transform(self): method build_metric (line 208) | def build_metric(self, training=None, **kwargs): method update_metric (line 215) | def update_metric(self, arc_scores, rel_scores, arcs, rels, mask, punc... method _report (line 229) | def _report(self, loss, metric): FILE: hanlp/components/parsers/biaffine/variationalbilstm.py class VariationalLSTM (line 33) | class VariationalLSTM(nn.Module): method __init__ (line 64) | def __init__(self, input_size, hidden_size, num_layers=1, bidirectiona... method __repr__ (line 85) | def __repr__(self): method reset_parameters (line 96) | def reset_parameters(self): method permute_hidden (line 105) | def permute_hidden(self, hx, permutation): method layer_forward (line 113) | def layer_forward(self, x, hx, cell, batch_sizes, reverse=False): method forward (line 141) | def forward(self, sequence, hx=None): class VariationalLSTMEncoder (line 208) | class VariationalLSTMEncoder(VariationalLSTM, ConfigTracker): method __init__ (line 209) | def __init__(self, method forward (line 222) | def forward(self, embed, mask): method get_output_dim (line 230) | def get_output_dim(self): FILE: hanlp/components/parsers/biaffine_parser_tf.py class BiaffineDependencyParserTF (line 27) | class BiaffineDependencyParserTF(KerasComponent): method __init__ (line 28) | def __init__(self, transform: CoNLL_DEP_Transform = None) -> None: method build_model (line 35) | def build_model(self, pretrained_embed, n_embed, training, **kwargs) -... method _init_config (line 49) | def _init_config(self): method load_weights (line 55) | def load_weights(self, save_dir, filename='model.h5', functional=False... method fit (line 60) | def fit(self, trn_data, dev_data, save_dir, method train_loop (line 94) | def train_loop(self, trn_data, dev_data, epochs, num_examples, method evaluate (line 149) | def evaluate(self, input_path: str, save_dir=None, output=False, batch... method evaluate_batch (line 155) | def evaluate_batch(self, words, feats, arcs, rels, arc_loss, rel_loss,... method _build_metrics (line 162) | def _build_metrics(self): method run_metrics (line 171) | def run_metrics(self, arcs, rels, arc_scores, rel_scores, words, mask,... method train_batch (line 179) | def train_batch(self, words, feats, arcs, rels, mask, optimizer, arc_l... method get_loss (line 187) | def get_loss(self, arc_scores, rel_scores, arcs, rels, mask, arc_loss,... method build_optimizer (line 197) | def build_optimizer(self, optimizer='adam', lr=2e-3, mu=.9, nu=.9, eps... method build_loss (line 213) | def build_loss(self, arc_loss, rel_loss, **kwargs): method sample_data (line 224) | def sample_data(self): method num_samples_in (line 227) | def num_samples_in(self, dataset): method build_train_dataset (line 230) | def build_train_dataset(self, trn_data, batch_size, num_examples): method build_callbacks (line 237) | def build_callbacks(self, save_dir, logger, metrics, **kwargs): method build_progbar (line 248) | def build_progbar(self, metrics, training=True): method decode (line 253) | def decode(self, arc_scores, rel_scores, mask): method evaluate_dataset (line 291) | def evaluate_dataset(self, tst_data, callbacks, output, num_batches, r... method predict_batch (line 338) | def predict_batch(self, batch, inputs=None, conll=True, **kwargs): method compile_model (line 347) | def compile_model(self, optimizer, loss, metrics): class BiaffineSemanticDependencyParserTF (line 351) | class BiaffineSemanticDependencyParserTF(BiaffineDependencyParserTF): method __init__ (line 352) | def __init__(self, transform: CoNLL_SDP_Transform = None) -> None: method fit (line 359) | def fit(self, trn_data, dev_data, save_dir, n_embed=100, pretrained_em... method get_loss (line 371) | def get_loss(self, arc_scores, rel_scores, arcs, rels, mask, arc_loss,... method decode (line 383) | def decode(self, arc_scores, rel_scores, mask): class BiaffineTransformerDependencyParserTF (line 390) | class BiaffineTransformerDependencyParserTF(BiaffineDependencyParserTF, ... method __init__ (line 391) | def __init__(self, transform: CoNLL_Transformer_Transform = None) -> N... method build_model (line 397) | def build_model(self, transformer, training, **kwargs) -> tf.keras.Model: method build_transformer (line 402) | def build_transformer(self, training, transformer): method fit (line 441) | def fit(self, trn_data, dev_data, save_dir, transformer, max_seq_lengt... method sample_data (line 463) | def sample_data(self): method build_optimizer (line 471) | def build_optimizer(self, optimizer, learning_rate, epsilon, weight_de... method build_vocab (line 493) | def build_vocab(self, trn_data, logger): method build_callbacks (line 497) | def build_callbacks(self, save_dir, logger, metrics, **kwargs): method on_train_begin (line 504) | def on_train_begin(self): method train_batch (line 510) | def train_batch(self, words, feats, arcs, rels, mask, optimizer, arc_l... method _apply_grads (line 524) | def _apply_grads(self, accum_grads): method on_epoch_end (line 540) | def on_epoch_end(self, epoch, logs=None): class BiaffineTransformerSemanticDependencyParser (line 545) | class BiaffineTransformerSemanticDependencyParser(BiaffineTransformerDep... method __init__ (line 547) | def __init__(self, transform: CoNLL_Transformer_Transform = None) -> N... method get_loss (line 552) | def get_loss(self, arc_scores, rel_scores, arcs, rels, mask, arc_loss,... method fit (line 556) | def fit(self, trn_data, dev_data, save_dir, transformer, max_seq_lengt... method decode (line 566) | def decode(self, arc_scores, rel_scores, mask): FILE: hanlp/components/parsers/biaffine_tf/alg.py function nonzero (line 11) | def nonzero(t: tf.Tensor) -> tf.Tensor: function view (line 15) | def view(t: tf.Tensor, *dims) -> tf.Tensor: function arange (line 19) | def arange(n: int) -> tf.Tensor: function randperm (line 23) | def randperm(n: int) -> tf.Tensor: function tolist (line 27) | def tolist(t: tf.Tensor) -> List: function kmeans (line 33) | def kmeans(x, k, seed=None): class Tarjan (line 91) | class Tarjan: method __init__ (line 94) | def __init__(self, prediction, tokens): method strongconnect (line 121) | def strongconnect(self, v, index, stack): method edges (line 158) | def edges(self): method vertices (line 162) | def vertices(self): method indices (line 166) | def indices(self): method SCCs (line 170) | def SCCs(self): function tarjan (line 174) | def tarjan(parse_probs, length, tokens_to_keep, ensure_tree=True): function rel_argmax (line 259) | def rel_argmax(rel_probs, length, root, ensure_tree=True): FILE: hanlp/components/parsers/biaffine_tf/layers.py class Biaffine (line 9) | class Biaffine(tf.keras.layers.Layer): method __init__ (line 10) | def __init__(self, n_in, n_out=1, bias_x=True, bias_y=True, trainable=... method build (line 19) | def build(self, input_shape): method extra_repr (line 26) | def extra_repr(self): method call (line 36) | def call(self, x, y, **kwargs): class MLP (line 50) | class MLP(tf.keras.layers.Layer): method __init__ (line 51) | def __init__(self, n_hidden, dropout=0, trainable=True, name=None, dty... method call (line 57) | def call(self, x, **kwargs): class SharedDropout (line 65) | class SharedDropout(tf.keras.layers.Layer): method __init__ (line 67) | def __init__(self, p=0.5, batch_first=True, trainable=True, name=None,... method extra_repr (line 73) | def extra_repr(self): method call (line 80) | def call(self, x, training=None, **kwargs): method get_mask (line 91) | def get_mask(x, p): class IndependentDropout (line 98) | class IndependentDropout(tf.keras.layers.Layer): method __init__ (line 100) | def __init__(self, p=0.5, trainable=True, name=None, dtype=None, dynam... method extra_repr (line 105) | def extra_repr(self): method call (line 108) | def call(self, inputs, training=None, **kwargs): FILE: hanlp/components/parsers/biaffine_tf/model.py class BiaffineModelTF (line 9) | class BiaffineModelTF(tf.keras.Model): method __init__ (line 11) | def __init__(self, config, embed=None, transformer: TFPreTrainedModel ... method call (line 85) | def call(self, inputs, mask_inf=True, **kwargs): method run_transformer (line 130) | def run_transformer(self, input_ids, input_mask, prefix_offset): method to_functional (line 146) | def to_functional(self): FILE: hanlp/components/parsers/chu_liu_edmonds.py function decode_mst (line 8) | def decode_mst( function chu_liu_edmonds (line 100) | def chu_liu_edmonds( function _find_cycle (line 274) | def _find_cycle( FILE: hanlp/components/parsers/conll.py function collapse_enhanced_empty_nodes (line 10) | def collapse_enhanced_empty_nodes(sent: list): function read_conll (line 27) | def read_conll(filepath: Union[str, TimingFileIterator], underline_to_no... FILE: hanlp/components/parsers/constituency/crf_constituency_model.py class CRFConstituencyDecoder (line 32) | class CRFConstituencyDecoder(nn.Module): method __init__ (line 97) | def __init__(self, method forward (line 119) | def forward(self, x, **kwargs): method loss (line 147) | def loss(self, s_span, s_label, charts, mask, mbr=True): method decode (line 174) | def decode(self, s_span, s_label, mask): class CRFConstituencyModel (line 194) | class CRFConstituencyModel(nn.Module): method __init__ (line 196) | def __init__(self, encoder, decoder: CRFConstituencyDecoder) -> None: method forward (line 201) | def forward(self, batch): FILE: hanlp/components/parsers/constituency/crf_constituency_parser.py class CRFConstituencyParser (line 27) | class CRFConstituencyParser(TorchComponent): method __init__ (line 28) | def __init__(self, **kwargs) -> None: method build_optimizer (line 37) | def build_optimizer(self, trn, **kwargs): method build_criterion (line 41) | def build_criterion(self, decoder=None, **kwargs): method build_metric (line 44) | def build_metric(self, **kwargs): method execute_training_loop (line 47) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 81) | def fit_dataloader(self, method decode_output (line 118) | def decode_output(self, out, mask, batch, span_probs=None, decoder=Non... method update_metrics (line 142) | def update_metrics(self, metric, batch, prediction): method feed_batch (line 156) | def feed_batch(self, batch: dict): method compute_mask (line 161) | def compute_mask(self, batch, offset=1): method compute_loss (line 168) | def compute_loss(self, out, y, mask, crf_decoder=None): method _step (line 176) | def _step(self, optimizer, scheduler, grad_norm): method evaluate_dataloader (line 183) | def evaluate_dataloader(self, data, criterion, logger=None, ratio_widt... method build_model (line 206) | def build_model(self, encoder, training=True, **kwargs) -> torch.nn.Mo... method build_dataloader (line 211) | def build_dataloader(self, method predict (line 237) | def predict(self, data: Union[str, List[str]], **kwargs): method input_is_flat (line 258) | def input_is_flat(self, data): method build_samples (line 261) | def build_samples(self, data): method fit (line 265) | def fit(self, method build_dataset (line 299) | def build_dataset(self, data, transform, logger=None): method build_vocabs (line 313) | def build_vocabs(self, trn, logger, **kwargs): FILE: hanlp/components/parsers/constituency/treecrf.py class CRFConstituency (line 32) | class CRFConstituency(nn.Module): method forward (line 45) | def forward(self, scores, mask, target=None, mbr=False): method inside (line 78) | def inside(self, scores, mask): class CRF2oDependency (line 105) | class CRF2oDependency(nn.Module): method __init__ (line 117) | def __init__(self): method forward (line 122) | def forward(self, scores, mask, target=None, mbr=True, partial=False): method inside (line 176) | def inside(self, scores, mask, cands=None): method loss (line 255) | def loss(self, s_arc, s_sib, s_rel, arcs, sibs, rels, mask, mbr=True, ... method decode (line 324) | def decode(self, s_arc, s_sib, s_rel, mask, tree=False, mbr=True, proj... FILE: hanlp/components/parsers/parse_alg.py class Tarjan (line 11) | class Tarjan: method __init__ (line 14) | def __init__(self, prediction, tokens): method strongconnect (line 41) | def strongconnect(self, v, index, stack): method edges (line 78) | def edges(self): method vertices (line 82) | def vertices(self): method indices (line 86) | def indices(self): method SCCs (line 90) | def SCCs(self): class UnionFind (line 94) | class UnionFind(object): method __init__ (line 96) | def __init__(self, n) -> None: method find (line 101) | def find(self, x): method unite (line 107) | def unite(self, x, y): method same (line 119) | def same(self, x, y): function tarjan (line 123) | def tarjan(parse_probs, length, tokens_to_keep, ensure_tree=True): function chu_liu_edmonds (line 177) | def chu_liu_edmonds(parse_probs, length): function unique_root (line 183) | def unique_root(parse_probs, tokens_to_keep: np.ndarray, length): function dfs (line 221) | def dfs(graph, start, end): function mst_then_greedy (line 234) | def mst_then_greedy(arc_scores, rel_scores, mask, root_rel_idx, rel_idx=... function adjust_root_score (line 255) | def adjust_root_score(arc_scores, parse_preds, root_rel_idx, rel_scores=... function add_secondary_arcs_by_scores (line 265) | def add_secondary_arcs_by_scores(arc_scores, rel_scores, tree, root_rel_... function add_secondary_arcs_by_preds (line 275) | def add_secondary_arcs_by_preds(arc_scores, arc_preds, rel_preds, tree, ... function adjust_root_score_then_add_secondary_arcs (line 304) | def adjust_root_score_then_add_secondary_arcs(arc_scores, rel_scores, tr... FILE: hanlp/components/parsers/ud/lemma_edit.py function min_edit_script (line 9) | def min_edit_script(source, target, allow_copy=False): function gen_lemma_rule (line 35) | def gen_lemma_rule(form, lemma, allow_copy=False): function apply_lemma_rule (line 79) | def apply_lemma_rule(form, lemma_rule): FILE: hanlp/components/parsers/ud/tag_decoder.py class TagDecoder (line 40) | class TagDecoder(torch.nn.Module): method __init__ (line 43) | def __init__(self, method forward (line 63) | def forward(self, method _adaptive_loss (line 79) | def _adaptive_loss(self, hidden, mask, gold_tags, output_dim): method _loss (line 95) | def _loss(self, hidden, mask, gold_tags, output_dim): method decode (line 109) | def decode(self, output_dict: Dict[str, torch.Tensor]) -> Dict[str, to... FILE: hanlp/components/parsers/ud/ud_model.py class UniversalDependenciesModel (line 16) | class UniversalDependenciesModel(torch.nn.Module): method __init__ (line 17) | def __init__(self, method forward (line 43) | def forward(self, class UniversalDependenciesDecoder (line 51) | class UniversalDependenciesDecoder(torch.nn.Module): method __init__ (line 52) | def __init__(self, method forward (line 89) | def forward(self, method decode (line 135) | def decode(self, output_dict: Dict[str, torch.Tensor]) -> Dict[str, to... FILE: hanlp/components/parsers/ud/ud_parser.py class UniversalDependenciesParser (line 34) | class UniversalDependenciesParser(TorchComponent): method __init__ (line 36) | def __init__(self, **kwargs) -> None: method build_dataloader (line 46) | def build_dataloader(self, method build_vocabs (line 71) | def build_vocabs(self, trn, logger, **kwargs): method build_dataset (line 86) | def build_dataset(self, data, transform): method build_optimizer (line 90) | def build_optimizer(self, trn, **kwargs): method build_criterion (line 94) | def build_criterion(self, **kwargs): method build_metric (line 97) | def build_metric(self, **kwargs): method evaluate_dataloader (line 105) | def evaluate_dataloader(self, method build_model (line 132) | def build_model(self, method predict (line 155) | def predict(self, data: Union[List[str], List[List[str]]], batch_size:... method build_samples (line 182) | def build_samples(self, data: List[List[str]]): method fit (line 185) | def fit(self, method execute_training_loop (line 214) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 248) | def fit_dataloader(self, method decode_output (line 284) | def decode_output(self, outputs, mask, batch): method update_metrics (line 291) | def update_metrics(self, metrics, batch, outputs, mask): method feed_batch (line 302) | def feed_batch(self, batch: dict): method compute_mask (line 310) | def compute_mask(self, batch): method _step (line 315) | def _step(self, optimizer, scheduler, grad_norm): method input_is_flat (line 321) | def input_is_flat(self, data): method prediction_to_human (line 325) | def prediction_to_human(self, outputs: dict, batch): method __call__ (line 345) | def __call__(self, data, batch_size=None, **kwargs) -> Union[CoNLLSent... FILE: hanlp/components/parsers/ud/udify_util.py function get_ud_treebank_files (line 31) | def get_ud_treebank_files(dataset_dir: str, treebanks: List[str] = None)... function sequence_cross_entropy (line 64) | def sequence_cross_entropy(log_probs: torch.FloatTensor, function sequence_cross_entropy_with_logits (line 109) | def sequence_cross_entropy_with_logits( function tiny_value_of_dtype (line 279) | def tiny_value_of_dtype(dtype: torch.dtype): function combine_initial_dims_to_1d_or_2d (line 301) | def combine_initial_dims_to_1d_or_2d(tensor: torch.Tensor) -> torch.Tensor: function uncombine_initial_dims (line 318) | def uncombine_initial_dims(tensor: torch.Tensor, original_size: torch.Si... function get_range_vector (line 340) | def get_range_vector(size: int, device: int) -> torch.Tensor: function get_device_of (line 357) | def get_device_of(tensor: torch.Tensor) -> int: FILE: hanlp/components/parsers/ud/util.py function generate_lemma_rule (line 8) | def generate_lemma_rule(sample: dict): function append_bos (line 15) | def append_bos(sample: dict): function sample_form_missing (line 27) | def sample_form_missing(sample: dict): FILE: hanlp/components/pipeline.py class Pipe (line 15) | class Pipe(Component): method __init__ (line 17) | def __init__(self, component: Component, input_key: str = None, output... method predict (line 33) | def predict(self, doc: Document, **kwargs) -> Document: method __repr__ (line 66) | def __repr__(self): method from_config (line 72) | def from_config(meta: dict, **kwargs): class Pipeline (line 78) | class Pipeline(Component, list): method __init__ (line 79) | def __init__(self, *pipes: Pipe) -> None: method append (line 86) | def append(self, component: Callable, input_key: Union[str, Iterable[s... method insert (line 106) | def insert(self, index: int, component: Callable, input_key: Union[str... method __call__ (line 132) | def __call__(self, doc: Union[Document, Any] = None, **kwargs) -> Docu... method copy (line 149) | def copy(self): method __copy__ (line 152) | def __copy__(self): method meta (line 157) | def meta(self): method meta (line 164) | def meta(self, value): method save (line 167) | def save(self, filepath): method load (line 170) | def load(self, filepath): method from_config (line 176) | def from_config(meta: Union[dict, str], **kwargs): FILE: hanlp/components/rnn_language_model_tf.py class RNNLanguageModel (line 12) | class RNNLanguageModel(KerasComponent): method __init__ (line 14) | def __init__(self, transform: TextTransform = None) -> None: method fit (line 20) | def fit(self, trn_data, dev_data, save_dir, method build_model (line 36) | def build_model(self, embedding, rnn_input_dropout, rnn_units, rnn_out... method build_optimizer (line 54) | def build_optimizer(self, optimizer, learning_rate, clipnorm, **kwargs): method build_train_dataset (line 59) | def build_train_dataset(self, trn_data, batch_size): method build_valid_dataset (line 63) | def build_valid_dataset(self, dev_data, batch_size): method generate_text (line 67) | def generate_text(self, text: Union[str, List[str]] = '\n', num_steps=... FILE: hanlp/components/srl/span_bio/baffine_tagging.py class BiaffineTaggingDecoder (line 14) | class BiaffineTaggingDecoder(nn.Module): method __init__ (line 16) | def __init__(self, method forward (line 38) | def forward(self, x: torch.Tensor, **kwargs): class SpanBIOSemanticRoleLabelingModel (line 48) | class SpanBIOSemanticRoleLabelingModel(nn.Module): method __init__ (line 50) | def __init__(self, method forward (line 70) | def forward(self, batch, mask): FILE: hanlp/components/srl/span_bio/span_bio.py class SpanBIOSemanticRoleLabeler (line 33) | class SpanBIOSemanticRoleLabeler(TorchComponent): method __init__ (line 35) | def __init__(self, **kwargs) -> None: method build_optimizer (line 45) | def build_optimizer(self, method build_criterion (line 65) | def build_criterion(self, decoder=None, **kwargs): method build_metric (line 75) | def build_metric(self, **kwargs): method execute_training_loop (line 78) | def execute_training_loop(self, method fit_dataloader (line 123) | def fit_dataloader(self, method naive_decode (line 157) | def naive_decode(self, pred, mask, batch, decoder=None): method decode_output (line 168) | def decode_output(self, pred, mask, batch, decoder=None): method update_metrics (line 196) | def update_metrics(self, metric, prediction, batch): method feed_batch (line 204) | def feed_batch(self, batch: dict): method compute_mask (line 215) | def compute_mask(self, mask2d): method _step (line 226) | def _step(self, optimizer, scheduler, grad_norm): method build_model (line 233) | def build_model(self, embed: Embedding, encoder, training, **kwargs) -... method build_dataloader (line 246) | def build_dataloader(self, data, batch_size, method build_dataset (line 269) | def build_dataset(self, data, transform): method build_vocabs (line 276) | def build_vocabs(self, dataset, logger, **kwargs): method predict (line 292) | def predict(self, data: Union[str, List[str]], batch_size: int = None,... method build_samples (line 311) | def build_samples(self, data): method fit (line 315) | def fit(self, method compute_loss (line 343) | def compute_loss(self, criterion, pred, srl, mask): method evaluate_dataloader (line 355) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method input_is_flat (line 371) | def input_is_flat(self, data) -> bool: method prediction_to_result (line 374) | def prediction_to_result(self, prediction: List, batch: Dict[str, Any]... FILE: hanlp/components/srl/span_rank/highway_variational_lstm.py function initializer_1d (line 11) | def initializer_1d(input_tensor, initializer): class HighwayBiLSTM (line 18) | class HighwayBiLSTM(nn.Module): method __init__ (line 21) | def __init__(self, input_size, hidden_size, num_layers=1, batch_first=... method reset_dropout_layer (line 47) | def reset_dropout_layer(self, batch_size): method _forward_rnn (line 54) | def _forward_rnn(cell, gate, input, masks, initial, drop_masks=None, h... method _forward_brnn (line 66) | def _forward_brnn(cell, gate, input, masks, initial, drop_masks=None, ... method forward (line 78) | def forward(self, input, masks, initial=None): class StackedHighwayBiLSTM (line 120) | class StackedHighwayBiLSTM(nn.Module): method __init__ (line 123) | def __init__(self, input_size, hidden_size, num_layers=1, batch_first=... method reset_parameters (line 158) | def reset_parameters(self): method reset_dropout_layer (line 166) | def reset_dropout_layer(self, batch_size): method reset_state (line 174) | def reset_state(self, batch_size): method _forward_rnn (line 182) | def _forward_rnn(cell, gate, input, masks, initial, drop_masks=None, h... method _forward_brnn (line 194) | def _forward_brnn(cell, gate, input, masks, initial, drop_masks=None, ... method forward (line 206) | def forward(self, input, masks, initial=None): FILE: hanlp/components/srl/span_rank/inference_utils.py function decode_spans (line 7) | def decode_spans(span_starts, span_ends, span_scores, labels_inv): function greedy_decode (line 34) | def greedy_decode(predict_dict, srl_labels_inv): function get_predicted_clusters (line 99) | def get_predicted_clusters(top_span_starts, top_span_ends, predicted_ant... function _decode_non_overlapping_spans (line 124) | def _decode_non_overlapping_spans(starts, ends, scores, max_len, labels_... function _dp_decode_non_overlapping_spans (line 147) | def _dp_decode_non_overlapping_spans(starts, ends, scores, max_len, labe... function srl_decode (line 212) | def srl_decode(sentence_lengths, predict_dict, srl_labels_inv, config): ... FILE: hanlp/components/srl/span_rank/layer.py function get_tensor_np (line 12) | def get_tensor_np(t): function orthonormal_initializer (line 16) | def orthonormal_initializer(output_size, input_size): class LayerNorm (line 54) | class LayerNorm(nn.Module): method __init__ (line 55) | def __init__(self, features, eps=1e-8): method forward (line 61) | def forward(self, x): class DropoutLayer3D (line 67) | class DropoutLayer3D(nn.Module): method __init__ (line 68) | def __init__(self, input_size, dropout_rate=0.0): method reset_dropout_mask (line 77) | def reset_dropout_mask(self, batch_size, length): method forward (line 83) | def forward(self, x): class DropoutLayer (line 90) | class DropoutLayer(nn.Module): method __init__ (line 91) | def __init__(self, input_size, dropout_rate=0.0): method reset_dropout_mask (line 98) | def reset_dropout_mask(self, batch_size): method forward (line 102) | def forward(self, x): class NonLinear (line 109) | class NonLinear(nn.Module): method __init__ (line 110) | def __init__(self, input_size, hidden_size, activation=None): method forward (line 124) | def forward(self, x): method reset_parameters (line 128) | def reset_parameters(self): class Biaffine (line 133) | class Biaffine(nn.Module): method __init__ (line 134) | def __init__(self, in1_features, in2_features, out_features, method reset_parameters (line 149) | def reset_parameters(self): method forward (line 152) | def forward(self, input1, input2): method __repr__ (line 175) | def __repr__(self): class HighwayLSTMCell (line 182) | class HighwayLSTMCell(nn.Module): method __init__ (line 183) | def __init__(self, input_size, hidden_size): method reset_parameters (line 194) | def reset_parameters(self): method forward (line 205) | def forward(self, x, mask=None, hx=None, dropout=None): class VariationalLSTMCell (line 225) | class VariationalLSTMCell(nn.Module): method __init__ (line 226) | def __init__(self, input_size, hidden_size): method reset_parameters (line 233) | def reset_parameters(self): method forward (line 238) | def forward(self, x, mask=None, hx=None, dropout=None): class VariationalLSTM (line 253) | class VariationalLSTM(nn.Module): method __init__ (line 256) | def __init__(self, input_size, hidden_size, num_layers=1, batch_first=... method reset_parameters (line 301) | def reset_parameters(self): # modified by kiro method _forward_rnn (line 313) | def _forward_rnn(cell, input, masks, initial, drop_masks): method _forward_brnn (line 328) | def _forward_brnn(cell, input, masks, initial, drop_masks): method forward (line 343) | def forward(self, input, masks, initial=None): FILE: hanlp/components/srl/span_rank/span_rank.py class SpanRankingSemanticRoleLabeler (line 28) | class SpanRankingSemanticRoleLabeler(TorchComponent): method __init__ (line 29) | def __init__(self, **kwargs) -> None: method build_optimizer (line 39) | def build_optimizer(self, method _get_transformer (line 68) | def _get_transformer(self): method build_criterion (line 71) | def build_criterion(self, **kwargs): method build_metric (line 75) | def build_metric(self, **kwargs) -> Tuple[F1, F1]: method execute_training_loop (line 80) | def execute_training_loop(self, method fit_dataloader (line 112) | def fit_dataloader(self, method _step (line 148) | def _step(self, optimizer, linear_scheduler): method evaluate_dataloader (line 156) | def evaluate_dataloader(self, method build_model (line 217) | def build_model(self, method build_dataloader (line 229) | def build_dataloader(self, data, batch_size, shuffle, device, logger: ... method build_dataset (line 247) | def build_dataset(self, data, generate_idx, logger, transform=None): method predict (line 264) | def predict(self, data: Union[str, List[str]], batch_size: int = None,... method format_dict_to_results (line 291) | def format_dict_to_results(data, outputs, exclusive_offset=False, with... method input_is_flat (line 313) | def input_is_flat(self, data): method fit (line 317) | def fit(self, method build_vocabs (line 355) | def build_vocabs(self, dataset, logger, **kwargs): method reset_metrics (line 371) | def reset_metrics(self, metrics): method report_metrics (line 375) | def report_metrics(self, loss, metrics): method feed_batch (line 379) | def feed_batch(self, batch) -> Dict[str, Any]: method decode_output (line 385) | def decode_output(self, output_dict, batch, training=False): method update_metrics (line 410) | def update_metrics(self, batch: dict, output_dict: dict, metrics): FILE: hanlp/components/srl/span_rank/span_ranking_srl_model.py function initializer_1d (line 13) | def initializer_1d(input_tensor, initializer): class SpanRankingSRLDecoder (line 20) | class SpanRankingSRLDecoder(nn.Module): method __init__ (line 22) | def __init__(self, context_layer_output_dim, label_space_size, config)... method reset_parameters (line 59) | def reset_parameters(self): method forward (line 83) | def forward(self, hidden_states, batch, mask=None): method get_candidate_spans (line 90) | def get_candidate_spans(sent_lengths: torch.Tensor, max_sent_length, m... method exclusive_cumsum (line 107) | def exclusive_cumsum(input: torch.Tensor, exclusive=True): method flatten_emb (line 128) | def flatten_emb(self, emb): method flatten_emb_in_sentence (line 134) | def flatten_emb_in_sentence(self, emb, batch_sentences_mask): method get_span_emb (line 139) | def get_span_emb(self, flatted_context_emb, flatted_candidate_starts, ... method get_arg_unary_scores (line 181) | def get_arg_unary_scores(self, span_emb): method get_pred_unary_scores (line 200) | def get_pred_unary_scores(self, span_emb): method extract_spans (line 208) | def extract_spans(self, candidate_scores, candidate_starts, candidate_... method batch_index_select (line 234) | def batch_index_select(self, emb, indices): method get_batch_topk (line 242) | def get_batch_topk(self, candidate_starts: torch.Tensor, candidate_end... method get_dense_span_labels (line 258) | def get_dense_span_labels(self, span_starts, span_ends, span_labels, m... method gather_4d (line 281) | def gather_4d(params, indices): method get_srl_labels (line 287) | def get_srl_labels(self, method get_srl_unary_scores (line 315) | def get_srl_unary_scores(self, span_emb): method get_srl_scores (line 323) | def get_srl_scores(self, arg_emb, pred_emb, arg_scores, pred_scores, n... method get_srl_softmax_loss (line 348) | def get_srl_softmax_loss(self, srl_scores, srl_labels, num_predicted_a... method get_srl_loss_mask (line 355) | def get_srl_loss_mask(self, srl_scores, num_predicted_args, num_predic... method decode (line 364) | def decode(self, contextualized_embeddings, sent_lengths, masks, gold_... class SpanRankingSRLModel (line 462) | class SpanRankingSRLModel(nn.Module): method __init__ (line 464) | def __init__(self, config, embed: torch.nn.Module, context_layer: torc... method forward (line 479) | def forward(self, method unpack (line 494) | def unpack(batch, mask=None, training=False): FILE: hanlp/components/srl/span_rank/srl_eval_utils.py function split_example_for_eval (line 14) | def split_example_for_eval(example): function evaluate_retrieval (line 43) | def evaluate_retrieval(span_starts, span_ends, span_scores, pred_starts,... function _calc_f1 (line 95) | def _calc_f1(total_gold, total_predicted, total_matched, message=None): function compute_span_f1 (line 104) | def compute_span_f1(gold_data, predictions, task_name): function compute_unlabeled_span_f1 (line 130) | def compute_unlabeled_span_f1(gold_data, predictions, task_name): function compute_srl_f1 (line 162) | def compute_srl_f1(sentences, gold_srl, predictions, gold_path=None) -> ... function print_sentence_to_conll (line 225) | def print_sentence_to_conll(fout, tokens, labels): function read_gold_predicates (line 247) | def read_gold_predicates(gold_path): function print_to_conll (line 262) | def print_to_conll(sentences, srl_labels, output_filename, gold_predicat... FILE: hanlp/components/srl/span_rank/util.py function block_orth_normal_initializer (line 5) | def block_orth_normal_initializer(input_size, output_size): FILE: hanlp/components/sts/transformer_sts.py class TransformerSemanticTextualSimilarity (line 23) | class TransformerSemanticTextualSimilarity(TorchComponent): method __init__ (line 25) | def __init__(self, **kwargs) -> None: method build_dataloader (line 37) | def build_dataloader(self, data, batch_size, sent_a_col=None, method build_optimizer (line 64) | def build_optimizer(self, trn, epochs, gradient_accumulation=1, lr=1e-... method build_criterion (line 74) | def build_criterion(self, **kwargs): method build_metric (line 77) | def build_metric(self, **kwargs): method execute_training_loop (line 80) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 101) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 130) | def evaluate_dataloader(self, data: DataLoader, logger: logging.Logger... method build_model (line 162) | def build_model(self, transformer, training=True, **kwargs) -> torch.n... method predict (line 170) | def predict(self, data: Union[List[str], List[List[str]]], batch_size:... method fit (line 203) | def fit(self, trn_data, dev_data, save_dir, method on_config_ready (line 226) | def on_config_ready(self, transformer, max_seq_len, **kwargs): method feed_batch (line 234) | def feed_batch(self, batch) -> SequenceClassifierOutput: method decode (line 238) | def decode(self, output: SequenceClassifierOutput): method report_metrics (line 241) | def report_metrics(self, loss, metric): FILE: hanlp/components/taggers/cnn_tagger_tf.py class WindowTokenTransform (line 15) | class WindowTokenTransform(TSVTaggingTransform): method fit (line 17) | def fit(self, trn_path: str, **kwargs): method create_types_shapes_values (line 25) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method inputs_to_samples (line 33) | def inputs_to_samples(self, inputs, gold=False): method X_to_inputs (line 55) | def X_to_inputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]]) -> Iterable: class CNNTaggingModel (line 63) | class CNNTaggingModel(tf.keras.models.Model): method __init__ (line 64) | def __init__(self, filters, num_tags, embed, dropout, kernels, **kwargs): method call (line 76) | def call(self, inputs, **kwargs): class CNNTaggerTF (line 94) | class CNNTaggerTF(TaggerComponent, ABC): method __init__ (line 95) | def __init__(self, transform: WindowTokenTransform = None) -> None: method build_model (line 102) | def build_model(self, embedding, **kwargs) -> tf.keras.Model: method fit (line 112) | def fit(self, trn_data: Any, dev_data: Any, save_dir: str, embedding=2... method input_shape (line 124) | def input_shape(self) -> List: FILE: hanlp/components/taggers/ngram_conv/ngram_conv_tagger.py class NgramTransform (line 19) | class NgramTransform(TSVTaggingTransform): method __init__ (line 21) | def __init__(self, config: SerializableDict = None, map_x=True, map_y=... method inputs_to_samples (line 26) | def inputs_to_samples(self, inputs, gold=False): method x_to_idx (line 38) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: method y_to_idx (line 44) | def y_to_idx(self, y) -> tf.Tensor: method create_types_shapes_values (line 47) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method fit (line 59) | def fit(self, trn_path: str, **kwargs): method X_to_inputs (line 76) | def X_to_inputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]]) -> Iterable: method input_truth_output_to_str (line 79) | def input_truth_output_to_str(self, input: List[str], truth: List[str]... class NgramConvTaggingModel (line 84) | class NgramConvTaggingModel(tf.keras.models.Model): method __init__ (line 85) | def __init__(self, word_embed: tf.keras.layers.Embedding, ngram_embed:... method call (line 109) | def call(self, inputs, **kwargs): class NgramConvTaggerTF (line 141) | class NgramConvTaggerTF(TaggerComponent): method __init__ (line 143) | def __init__(self, transform: NgramTransform = None) -> None: method build_model (line 149) | def build_model(self, word_embed, ngram_embed, window_size, weight_nor... method fit (line 168) | def fit(self, trn_data: Any, dev_data: Any, save_dir: str, word_embed:... FILE: hanlp/components/taggers/pos_tf.py class CNNPartOfSpeechTaggerTF (line 8) | class CNNPartOfSpeechTaggerTF(CNNTaggerTF): class RNNPartOfSpeechTaggerTF (line 12) | class RNNPartOfSpeechTaggerTF(RNNTaggerTF): FILE: hanlp/components/taggers/rnn/rnntaggingmodel.py class RNNTaggingModel (line 31) | class RNNTaggingModel(nn.Module): method __init__ (line 33) | def __init__(self, method reset_parameters (line 74) | def reset_parameters(self): method forward (line 78) | def forward(self, FILE: hanlp/components/taggers/rnn_tagger.py class RNNTagger (line 24) | class RNNTagger(Tagger): method __init__ (line 26) | def __init__(self, **kwargs) -> None: method execute_training_loop (line 36) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method build_scheduler (line 79) | def build_scheduler(self, optimizer, anneal_factor, anneal_patience, *... method fit_dataloader (line 86) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method feed_batch (line 108) | def feed_batch(self, batch): method build_model (line 114) | def build_model(self, rnn_input, rnn_hidden, drop, crf, **kwargs) -> t... method _convert_embed (line 126) | def _convert_embed(self): method build_dataloader (line 132) | def build_dataloader(self, data, batch_size, shuffle, device, logger=N... method build_dataset (line 156) | def build_dataset(self, data, transform): method build_vocabs (line 159) | def build_vocabs(self, dataset, logger): method fit (line 167) | def fit(self, trn_data, dev_data, save_dir, method _id_to_tags (line 185) | def _id_to_tags(self, ids): method write_output (line 194) | def write_output(self, yhat, y, mask, batch, prediction, output): FILE: hanlp/components/taggers/rnn_tagger_tf.py class RNNTaggerTF (line 17) | class RNNTaggerTF(TaggerComponent): method __init__ (line 19) | def __init__(self, transform: Transform = None) -> None: method fit (line 24) | def fit(self, trn_data: str, dev_data: str = None, save_dir: str = Non... method build_model (line 31) | def build_model(self, embeddings, embedding_trainable, rnn_input_dropo... method predict (line 46) | def predict(self, sents: Union[List[str], List[List[str]]], batch_size... method save_weights (line 50) | def save_weights(self, save_dir, filename='model.h5'): method build_loss (line 60) | def build_loss(self, loss, **kwargs): method tag_vocab (line 68) | def tag_vocab(self) -> VocabTF: method build_transform (line 71) | def build_transform(self, embeddings, **kwargs): method sample_data (line 79) | def sample_data(self): FILE: hanlp/components/taggers/tagger.py class Tagger (line 25) | class Tagger(DistillableComponent, ABC): method build_optimizer (line 26) | def build_optimizer(self, optimizer, lr, **kwargs): method build_criterion (line 32) | def build_criterion(self, model=None, reduction='mean', decoder=None, ... method build_metric (line 43) | def build_metric(self, **kwargs): method feed_batch (line 47) | def feed_batch(self, batch): method compute_loss (line 50) | def compute_loss(self, criterion, out, y, mask): method decode_output (line 58) | def decode_output(self, logits, mask, batch, model=None): method execute_training_loop (line 67) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method id_to_tags (line 101) | def id_to_tags(self, ids: torch.LongTensor, lens: List[int]): method update_metrics (line 110) | def update_metrics(self, metric, logits, y, mask, batch=None, predicti... method evaluate_dataloader (line 114) | def evaluate_dataloader(self, data, criterion, logger=None, ratio_widt... method write_prediction (line 140) | def write_prediction(self, prediction, batch, output: TextIO): method predict (line 145) | def predict(self, tokens: Any, batch_size: int = None, **kwargs): method input_is_flat (line 156) | def input_is_flat(self, tokens): method predict_data (line 159) | def predict_data(self, data, batch_size, sampler_builder=None, **kwargs): method build_samples (line 176) | def build_samples(self, data: List[str], **kwargs): method prediction_to_human (line 179) | def prediction_to_human(self, pred_ids, vocab: List[str], batch): method tagging_scheme (line 194) | def tagging_scheme(self): method dict_tags (line 205) | def dict_tags(self) -> DictInterface: method dict_tags (line 219) | def dict_tags(self, FILE: hanlp/components/taggers/tagger_tf.py class TaggerComponent (line 14) | class TaggerComponent(KerasComponent, ABC): method build_metrics (line 16) | def build_metrics(self, metrics, logger: logging.Logger, **kwargs): method build_loss (line 27) | def build_loss(self, loss, **kwargs): FILE: hanlp/components/taggers/transformers/metrics_tf.py class Accuracy (line 7) | class Accuracy(tf.keras.metrics.SparseCategoricalAccuracy): method __init__ (line 9) | def __init__(self, name='sparse_categorical_accuracy', dtype=None, mas... method update_state (line 13) | def update_state(self, y_true, y_pred, sample_weight=None): FILE: hanlp/components/taggers/transformers/transformer_tagger.py class TransformerTaggingModel (line 28) | class TransformerTaggingModel(nn.Module): method __init__ (line 29) | def __init__(self, method forward (line 54) | def forward(self, lens: torch.LongTensor, input_ids, token_span, token... class TransformerTagger (line 67) | class TransformerTagger(TransformerComponent, Tagger): method __init__ (line 69) | def __init__(self, **kwargs) -> None: method fit_dataloader (line 81) | def fit_dataloader(self, method _step (line 131) | def _step(self, optimizer, scheduler, grad_norm, transformer_grad_norm... method compute_distill_loss (line 139) | def compute_distill_loss(self, kd_criterion, out_S, out_T, mask, tempe... method build_model (line 145) | def build_model(self, training=True, extra_embeddings: Embedding = Non... method build_dataloader (line 170) | def build_dataloader(self, data, batch_size, shuffle, device, logger: ... method build_dataset (line 204) | def build_dataset(self, data, transform=None, **kwargs): method last_transform (line 207) | def last_transform(self): method tokenizer_transform (line 212) | def tokenizer_transform(self) -> TransformerSequenceTokenizer: method build_vocabs (line 219) | def build_vocabs(self, trn, logger, **kwargs): method fit (line 233) | def fit(self, method feed_batch (line 269) | def feed_batch(self, batch: dict): method distill (line 281) | def distill(self, FILE: hanlp/components/taggers/transformers/transformer_tagger_tf.py class TransformerTaggingModel (line 17) | class TransformerTaggingModel(tf.keras.Model): method __init__ (line 18) | def __init__(self, transformer: tf.keras.Model, *args, **kwargs): method call (line 22) | def call(self, inputs, training=None, mask=None): class TransformerTaggerTF (line 26) | class TransformerTaggerTF(TaggerComponent): method __init__ (line 27) | def __init__(self, transform: TransformerTransform = None) -> None: method build_model (line 33) | def build_model(self, transformer, max_seq_length, **kwargs) -> tf.ker... method fit (line 38) | def fit(self, trn_data, dev_data, save_dir, method build_optimizer (line 58) | def build_optimizer(self, optimizer, learning_rate, epsilon, weight_de... method build_vocab (line 67) | def build_vocab(self, trn_data, logger): method train_loop (line 73) | def train_loop(self, trn_data, dev_data, epochs, num_examples, train_s... method build_loss (line 85) | def build_loss(self, loss, **kwargs): method load_transform (line 90) | def load_transform(self, save_dir) -> Transform: FILE: hanlp/components/taggers/transformers/transformer_transform_tf.py class TransformerTransform (line 15) | class TransformerTransform(TsvTaggingFormat, Transform): method __init__ (line 16) | def __init__(self, method max_seq_length (line 28) | def max_seq_length(self): method tokenizer (line 33) | def tokenizer(self): method tokenizer (line 37) | def tokenizer(self, tokenizer): method fit (line 48) | def fit(self, trn_path: str, **kwargs) -> int: method create_types_shapes_values (line 56) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method lock_vocabs (line 64) | def lock_vocabs(self): method inputs_to_samples (line 67) | def inputs_to_samples(self, inputs, gold=False): method x_to_idx (line 111) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: method y_to_idx (line 114) | def y_to_idx(self, y) -> tf.Tensor: method input_is_single_sample (line 117) | def input_is_single_sample(self, input: Union[List[str], List[List[str... method Y_to_outputs (line 120) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... FILE: hanlp/components/taggers/util.py function guess_tagging_scheme (line 8) | def guess_tagging_scheme(labels: List[str]) -> str: function guess_allowed_transitions (line 15) | def guess_allowed_transitions(labels) -> List[Tuple[int, int]]: FILE: hanlp/components/tokenizers/multi_criteria_cws_transformer.py class MultiCriteriaTransformerTaggingTokenizer (line 17) | class MultiCriteriaTransformerTaggingTokenizer(TransformerTaggingTokeniz... method __init__ (line 18) | def __init__(self, **kwargs) -> None: method build_dataset (line 28) | def build_dataset(self, data, **kwargs): method on_config_ready (line 31) | def on_config_ready(self, **kwargs): method last_transform (line 41) | def last_transform(self): method build_vocabs (line 48) | def build_vocabs(self, trn, logger, **kwargs): method feed_batch (line 52) | def feed_batch(self, batch: dict): method build_samples (line 57) | def build_samples(self, data: List[str], criteria=None, **kwargs): method build_metric (line 68) | def build_metric(self, **kwargs): method update_metrics (line 74) | def update_metrics(self, metric, logits, y, mask, batch, prediction): method fit (line 80) | def fit(self, trn_data, dev_data, save_dir, transformer, average_subwo... FILE: hanlp/components/tokenizers/tok.py class RNNTokenizer (line 13) | class RNNTokenizer(RNNTagger): method predict (line 15) | def predict(self, sentence: Any, batch_size: int = None, **kwargs): method predict_data (line 26) | def predict_data(self, data, batch_size, **kwargs): method build_dataset (line 31) | def build_dataset(self, data, transform=None): method build_metric (line 39) | def build_metric(self, **kwargs): method update_metrics (line 42) | def update_metrics(self, metric, logits, y, mask, batch): method fit (line 48) | def fit(self, trn_data, dev_data, save_dir, batch_size=50, epochs=100,... FILE: hanlp/components/tokenizers/tok_tf.py class BMESTokenizerTF (line 21) | class BMESTokenizerTF(KerasComponent): method build_metrics (line 23) | def build_metrics(self, metrics, logger: logging.Logger, **kwargs): class NgramConvTokenizerTransform (line 30) | class NgramConvTokenizerTransform(TxtFormat, NgramTransform): method inputs_to_samples (line 32) | def inputs_to_samples(self, inputs, gold=False): method input_is_single_sample (line 39) | def input_is_single_sample(self, input: Union[List[str], List[List[str... method Y_to_outputs (line 44) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... class NgramConvTokenizerTF (line 49) | class NgramConvTokenizerTF(BMESTokenizerTF, NgramConvTaggerTF): method __init__ (line 51) | def __init__(self) -> None: method fit (line 54) | def fit(self, trn_data: Any, dev_data: Any, save_dir: str, word_embed:... method evaluate_output_to_file (line 62) | def evaluate_output_to_file(self, batch, outputs, out): method build_loss (line 68) | def build_loss(self, loss, **kwargs): class TransformerTokenizerTransform (line 74) | class TransformerTokenizerTransform(TxtBMESFormat, TransformerTransform): method inputs_to_samples (line 76) | def inputs_to_samples(self, inputs, gold=False): method Y_to_tokens (line 80) | def Y_to_tokens(self, tag_vocab, Y, gold, inputs): class TransformerTokenizerTF (line 88) | class TransformerTokenizerTF(BMESTokenizerTF, TransformerTaggerTF): method __init__ (line 89) | def __init__(self, transform: TransformerTokenizerTransform = None) ->... class RNNTokenizerTransform (line 95) | class RNNTokenizerTransform(TxtBMESFormat, TSVTaggingTransform): class RNNTokenizerTF (line 99) | class RNNTokenizerTF(BMESTokenizerTF, RNNTaggerTF): method __init__ (line 100) | def __init__(self, transform: RNNTokenizerTransform = None) -> None: method fit (line 105) | def fit(self, trn_data: str, dev_data: str = None, save_dir: str = Non... FILE: hanlp/components/tokenizers/transformer.py class TransformerTaggingTokenizer (line 21) | class TransformerTaggingTokenizer(TransformerTagger): method __init__ (line 23) | def __init__(self, **kwargs) -> None: method dict_force (line 43) | def dict_force(self) -> DictInterface: method dict_force (line 65) | def dict_force(self, dictionary: Union[DictInterface, Union[Dict[str, ... method dict_combine (line 72) | def dict_combine(self) -> DictInterface: method dict_combine (line 84) | def dict_combine(self, dictionary: Union[DictInterface, Union[Dict[str... method build_metric (line 98) | def build_metric(self, **kwargs): method update_metrics (line 102) | def update_metrics(self, metric, logits, y, mask, batch, prediction): method decode_output (line 108) | def decode_output(self, logits, mask, batch, model=None): method tag_to_span (line 115) | def tag_to_span(self, batch_tags, batch: dict): method write_prediction (line 157) | def write_prediction(self, prediction, batch, output: TextIO): method tokenizer_transform (line 164) | def tokenizer_transform(self): method spans_to_tokens (line 174) | def spans_to_tokens(self, spans, batch, rebuild_span=False): method generate_prediction_filename (line 213) | def generate_prediction_filename(self, tst_data, save_dir): method prediction_to_human (line 216) | def prediction_to_human(self, pred, vocab, batch, rebuild_span=False): method input_is_flat (line 230) | def input_is_flat(self, tokens): method build_dataset (line 233) | def build_dataset(self, data, **kwargs): method last_transform (line 236) | def last_transform(self): method fit (line 240) | def fit(self, trn_data, dev_data, save_dir, transformer, average_subwo... method feed_batch (line 297) | def feed_batch(self, batch: dict): FILE: hanlp/datasets/coref/loaders/conll12coref.py class Ontonotes (line 15) | class Ontonotes(_Ontonotes): method dataset_document_iterator (line 16) | def dataset_document_iterator(self, file_path: str) -> Iterator[List[O... class CONLL12CorefDataset (line 51) | class CONLL12CorefDataset(TransformableDataset): method __init__ (line 53) | def __init__(self, data: Union[str, List], transform: Union[Callable, ... method load_file (line 60) | def load_file(self, filepath: str): method text_to_instance (line 77) | def text_to_instance( FILE: hanlp/datasets/eos/eos.py class SentenceBoundaryDetectionDataset (line 14) | class SentenceBoundaryDetectionDataset(TransformableDataset): method __init__ (line 16) | def __init__(self, method load_file (line 48) | def load_file(self, filepath: str): FILE: hanlp/datasets/lm/loaders/lm_dataset.py class LanguageModelDataset (line 16) | class LanguageModelDataset(TransformSequentialDataset): method __init__ (line 18) | def __init__(self, method vocab (line 59) | def vocab(self): method vocab_path (line 63) | def vocab_path(self): method load_file (line 66) | def load_file(self, filepath): method __iter__ (line 95) | def __iter__(self): method estimate_num_batches (line 113) | def estimate_num_batches(self, seq_len=None): method max_seq_len (line 119) | def max_seq_len(self): method _read_chunk (line 124) | def _read_chunk(fp, offset, length): method _debug_load_cache (line 132) | def _debug_load_cache(self): method filecache (line 141) | def filecache(self): FILE: hanlp/datasets/lu/glue.py class SST2Dataset (line 15) | class SST2Dataset(TableDataset): function main (line 19) | def main(): FILE: hanlp/datasets/ner/loaders/json_ner.py class JsonNERDataset (line 15) | class JsonNERDataset(TransformableDataset): method __init__ (line 17) | def __init__(self, data: Union[str, List], transform: Union[Callable, ... method load_file (line 34) | def load_file(self, filepath: str): function convert_conll03_to_json (line 92) | def convert_conll03_to_json(file_path): function unpack_ner (line 130) | def unpack_ner(sample: dict) -> dict: function prune_ner_tagset (line 141) | def prune_ner_tagset(sample: dict, tagset: Union[set, Dict[str, str]]): FILE: hanlp/datasets/ner/loaders/tsv.py class TSVTaggingDataset (line 11) | class TSVTaggingDataset(TransformableDataset): method __init__ (line 13) | def __init__(self, method load_file (line 47) | def load_file(self, filepath): FILE: hanlp/datasets/parsing/amr.py class AbstractMeaningRepresentationDataset (line 23) | class AbstractMeaningRepresentationDataset(TransformableDataset): method load_file (line 24) | def load_file(self, filepath: str): function generate_oracle (line 29) | def generate_oracle(sample: dict): function chars_for_tok (line 38) | def chars_for_tok(sample: dict, max_string_len=20): function append_bos (line 48) | def append_bos(sample: dict): function get_concepts (line 55) | def get_concepts(sample: dict, vocab: VocabWithFrequency = None, rel_voc... function batchify (line 83) | def batchify(data, vocabs: VocabDict, unk_rate=0., device=None, squeeze=... function make_batch_for_bart (line 160) | def make_batch_for_bart(augmented_concept, ret, tokenizer, device, train... function levi_amr (line 182) | def levi_amr(concept, edge, extra_arc=False): function move_dict_to_device (line 194) | def move_dict_to_device(ret, device): function subtoken_to_tensor (line 204) | def subtoken_to_tensor(token_field, ret): function make_batch_for_squeeze (line 210) | def make_batch_for_squeeze(data, augmented_concept, tokenizer, device, r... function linearize (line 259) | def linearize(concept: List, edge: List, label='', prefix=REL, extra_arc... function unlinearize (line 289) | def unlinearize(concept: List, edge: List, prefix=REL, extra_arc=False): function separate_concept_rel (line 306) | def separate_concept_rel(concept, prefix=REL): function remove_unconnected_components (line 316) | def remove_unconnected_components(concept: List, edge: List): function largest_connected_component (line 342) | def largest_connected_component(triples: List): function to_triples (line 358) | def to_triples(concept: List, edge: List): function reverse_edge_for_levi_bfs (line 362) | def reverse_edge_for_levi_bfs(concept, edge): function un_kahn (line 370) | def un_kahn(concept, edge): FILE: hanlp/datasets/parsing/loaders/_ctb_utils.py function convert_to_dependency (line 76) | def convert_to_dependency(src, dst, language='zh', version='3.3.0', conl... function clean_ctb_bracketed (line 107) | def clean_ctb_bracketed(ctb_root, out_root): function _list_treebank_root (line 121) | def _list_treebank_root(ctb_root): function list_treebank (line 126) | def list_treebank(ctb_home): function load_bracketed_trees (line 132) | def load_bracketed_trees(chtbs) -> List[Tree]: function split_str_to_trees (line 144) | def split_str_to_trees(text: str): function make_ctb_tasks (line 160) | def make_ctb_tasks(chtbs, out_root, part): function reverse_splits (line 210) | def reverse_splits(splits): function split_chtb (line 218) | def split_chtb(chtbs: List[str], splits=None): function id_of_chtb (line 244) | def id_of_chtb(each: str): function make_ctb (line 248) | def make_ctb(ctb_home): function load_domains (line 273) | def load_domains(ctb_home): function ctb_pos_to_text_format (line 294) | def ctb_pos_to_text_format(path, delimiter='_'): function remove_all_ec (line 310) | def remove_all_ec(path): FILE: hanlp/datasets/parsing/loaders/conll_dataset.py class CoNLLParsingDataset (line 12) | class CoNLLParsingDataset(TransformableDataset): method __init__ (line 14) | def __init__(self, method load_file (line 33) | def load_file(self, filepath): method __len__ (line 56) | def __len__(self) -> int: function append_bos (line 60) | def append_bos(sample: dict, pos_key='CPOS', bos=ROOT) -> dict: function append_bos_eos (line 80) | def append_bos_eos(sample: dict) -> dict: function get_sibs (line 90) | def get_sibs(sample: dict) -> dict: FILE: hanlp/datasets/parsing/loaders/constituency_dataset.py class ConstituencyDataset (line 12) | class ConstituencyDataset(TransformableDataset): method load_file (line 13) | def load_file(self, filepath: str): function unpack_tree_to_features (line 22) | def unpack_tree_to_features(sample: dict): function append_bos_eos (line 36) | def append_bos_eos(sample: dict): function remove_subcategory (line 43) | def remove_subcategory(sample: dict): function binarize (line 52) | def binarize(tree: Tree): function factorize (line 105) | def factorize(tree, delete_labels=None, equal_labels=None): function build_tree (line 164) | def build_tree(tokens: List[str], sequence): FILE: hanlp/datasets/parsing/pmt1.py function _make_ptm (line 20) | def _make_ptm(): FILE: hanlp/datasets/parsing/semeval15.py function unpack_deps_to_head_deprel (line 16) | def unpack_deps_to_head_deprel(sample: dict, pad_rel=None, arc_key='arc'... function append_bos_to_form_pos (line 41) | def append_bos_to_form_pos(sample, pos_key='CPOS'): function merge_head_deprel_with_2nd (line 48) | def merge_head_deprel_with_2nd(sample: dict): FILE: hanlp/datasets/parsing/semeval16.py function convert_conll_to_conllu (line 33) | def convert_conll_to_conllu(path): FILE: hanlp/datasets/parsing/ud/__init__.py function concat_treebanks (line 12) | def concat_treebanks(home, version): FILE: hanlp/datasets/parsing/ud/ud210.py function _list_dir (line 19) | def _list_dir(path, home): function main (line 37) | def main(): FILE: hanlp/datasets/parsing/ud/ud23.py function _list_dir (line 9) | def _list_dir(path, home): function main (line 29) | def main(): FILE: hanlp/datasets/parsing/ud/ud27.py function _list_dir (line 19) | def _list_dir(path, home): function main (line 37) | def main(): FILE: hanlp/datasets/qa/hotpotqa.py class HotpotQADataset (line 18) | class HotpotQADataset(TransformableDataset): method load_file (line 20) | def load_file(self, filepath): class BuildGraph (line 25) | class BuildGraph(object): method __init__ (line 27) | def __init__(self, dst='graph') -> None: method __call__ (line 31) | def __call__(self, sample: dict): function hotpotqa_collate_fn (line 36) | def hotpotqa_collate_fn(samples): function flat_sentence (line 75) | def flat_sentence(sample: dict) -> dict: function create_sp_label (line 82) | def create_sp_label(sample: dict) -> dict: class Type (line 99) | class Type(Enum): class Vertex (line 109) | class Vertex(object): method __init__ (line 111) | def __init__(self, id, type: Type, text=None) -> None: method connect (line 121) | def connect(self, to, rel): method __str__ (line 125) | def __str__(self) -> str: method __hash__ (line 128) | def __hash__(self) -> int: method is_word (line 131) | def is_word(self): method is_question (line 134) | def is_question(self): method is_sp (line 137) | def is_sp(self): method is_sp_root (line 140) | def is_sp_root(self): method is_sp_root_candidate (line 143) | def is_sp_root_candidate(self): function build_graph (line 147) | def build_graph(each: dict, debug=False): FILE: hanlp/datasets/srl/loaders/conll2012.py class CoNLL2012BIOSRLDataset (line 17) | class CoNLL2012BIOSRLDataset(TransformableDataset): method load_file (line 18) | def load_file(self, filepath: str): method _make_bio_labels (line 44) | def _make_bio_labels(prop): method _remove_B_V (line 76) | def _remove_B_V(labels): class CoNLL2012SRLDataset (line 80) | class CoNLL2012SRLDataset(TransformableDataset): method __init__ (line 82) | def __init__(self, method load_file (line 91) | def load_file(self, filepath: str): method build_sample (line 145) | def build_sample(self, sentence, deduplicated_srl, doc, sid): function group_pa_by_p (line 152) | def group_pa_by_p(sample: dict) -> dict: function group_pa_by_p_ (line 160) | def group_pa_by_p_(srl): function filter_v_args (line 170) | def filter_v_args(sample: dict) -> dict: function unpack_srl (line 176) | def unpack_srl(sample: dict) -> dict: class SpanCandidatesGenerator (line 193) | class SpanCandidatesGenerator(NamedTransform): method __init__ (line 195) | def __init__(self, src: str, dst: str = None, max_span_width=None) -> ... method __call__ (line 201) | def __call__(self, sample: dict) -> dict: class CoNLL2012SRLBIODataset (line 206) | class CoNLL2012SRLBIODataset(CoNLL2012SRLDataset): method build_sample (line 207) | def build_sample(self, tokens, deduplicated_srl, doc, sid): FILE: hanlp/datasets/srl/loaders/ontonotes_loader.py class OntonotesSentence (line 13) | class OntonotesSentence: method __init__ (line 55) | def __init__( class Ontonotes (line 85) | class Ontonotes: method dataset_iterator (line 181) | def dataset_iterator(self, file_path: str) -> Iterator[OntonotesSenten... method dataset_path_iterator (line 189) | def dataset_path_iterator(file_path: str) -> Iterator[str]: method dataset_document_iterator (line 205) | def dataset_document_iterator(self, file_path: str) -> Iterator[List[O... method sentence_iterator (line 232) | def sentence_iterator(self, file_path: str) -> Iterator[OntonotesSente... method _conll_rows_to_sentence (line 240) | def _conll_rows_to_sentence(self, conll_rows: List[str]) -> OntonotesS... method _process_coref_span_annotations_for_word (line 369) | def _process_coref_span_annotations_for_word( method _process_span_annotations_for_word (line 420) | def _process_span_annotations_for_word( function make_coref_instance (line 463) | def make_coref_instance( function _normalize_word (line 579) | def _normalize_word(word): function _canonicalize_clusters (line 586) | def _canonicalize_clusters(clusters: List[List[Tuple[int, int]]]) -> Lis... FILE: hanlp/datasets/srl/ontonotes5/_utils.py function flatten (line 24) | def flatten(l): function get_doc_key (line 28) | def get_doc_key(doc_id, part): class DocumentState (line 32) | class DocumentState(object): method __init__ (line 33) | def __init__(self): method assert_empty (line 56) | def assert_empty(self): method assert_finalizable (line 77) | def assert_finalizable(self): method finalize_sentence (line 89) | def finalize_sentence(self): method finalize (line 112) | def finalize(self): function filter_data (line 147) | def filter_data(input_json_file, output_json_file, doc_ids_file=None, an... function normalize_word (line 224) | def normalize_word(word, language): function handle_bit (line 233) | def handle_bit(word_index, bit, stack, spans, label_set): function handle_line (line 269) | def handle_line(line, document_state: DocumentState, language, labels, s... function ontonotes_document_generator (line 339) | def ontonotes_document_generator(input_path, language, labels, stats): function convert_to_jsonlines (line 349) | def convert_to_jsonlines(input_path, output_path, language, labels=None,... function make_ontonotes_jsonlines (line 364) | def make_ontonotes_jsonlines(conll12_ontonotes_path, output_path, langua... function make_ontonotes_language_jsonlines (line 371) | def make_ontonotes_language_jsonlines(conll12_ontonotes_path, output_pat... function ensure_python_points_to_python2 (line 405) | def ensure_python_points_to_python2(): function make_gold_conll (line 414) | def make_gold_conll(ontonotes_path, language): function convert_jsonlines_to_IOBES (line 432) | def convert_jsonlines_to_IOBES(json_file, output_file=None, doc_level_of... function make_ner_tsv_if_necessary (line 463) | def make_ner_tsv_if_necessary(json_file): function batch_make_ner_tsv_if_necessary (line 471) | def batch_make_ner_tsv_if_necessary(json_files): function make_pos_tsv_if_necessary (line 476) | def make_pos_tsv_if_necessary(json_file): function make_pos_tsv (line 484) | def make_pos_tsv(json_file, output_file): function batch_make_pos_tsv_if_necessary (line 494) | def batch_make_pos_tsv_if_necessary(json_files): function make_con_txt (line 499) | def make_con_txt(conll_file, output_file): function make_con_txt_if_necessary (line 518) | def make_con_txt_if_necessary(json_file): function batch_make_con_txt_if_necessary (line 526) | def batch_make_con_txt_if_necessary(json_files): function batch_remove_empty_category_if_necessary (line 531) | def batch_remove_empty_category_if_necessary(json_files): function make_dep_conllx (line 539) | def make_dep_conllx(con_txt_file, output_file, language='en'): function make_dep_conllx_if_necessary (line 544) | def make_dep_conllx_if_necessary(con_txt_file: str, language='en'): function batch_make_dep_conllx_if_necessary (line 552) | def batch_make_dep_conllx_if_necessary(con_txt_files, language='en'): function make_ner_json_if_necessary (line 557) | def make_ner_json_if_necessary(json_file): function batch_make_ner_json_if_necessary (line 565) | def batch_make_ner_json_if_necessary(json_files): function make_ner_json (line 570) | def make_ner_json(json_file, output_file): function make_srl_json_if_necessary (line 574) | def make_srl_json_if_necessary(json_file): function make_coref_json_if_necessary (line 582) | def make_coref_json_if_necessary(json_file): function batch_make_srl_json_if_necessary (line 590) | def batch_make_srl_json_if_necessary(json_files): function make_srl_json (line 595) | def make_srl_json(json_file, output_file): function batch_make_coref_json_if_necessary (line 599) | def batch_make_coref_json_if_necessary(json_files): function make_coref_json (line 604) | def make_coref_json(json_file, output_file): function load_raw_text (line 608) | def load_raw_text(onf_file) -> List[str]: function batch_load_raw_text (line 633) | def batch_load_raw_text(root: str) -> Dict[str, List[str]]: function make_raw_text_if_necessary (line 642) | def make_raw_text_if_necessary(home: str): class RestoreToken (line 651) | class RestoreToken(NormalizeToken): method __init__ (line 652) | def __init__(self, src: str, mapper: Union[str, dict] = None, dst: str... method __call__ (line 660) | def __call__(self, sample: dict) -> dict: function main (line 667) | def main(): FILE: hanlp/datasets/sts/stsb.py class SemanticTextualSimilarityDataset (line 14) | class SemanticTextualSimilarityDataset(TransformableDataset): method __init__ (line 15) | def __init__(self, method load_file (line 30) | def load_file(self, filepath: str): FILE: hanlp/datasets/tokenization/loaders/chunking_dataset.py class ChunkingDataset (line 12) | class ChunkingDataset(TransformableDataset): method __init__ (line 14) | def __init__(self, data: Union[str, List], transform: Union[Callable, ... method load_file (line 25) | def load_file(self, filepath): method _generate_chars_tags (line 32) | def _generate_chars_tags(filepath, delimiter, max_seq_len): FILE: hanlp/datasets/tokenization/loaders/multi_criteria_cws/mcws_dataset.py class MultiCriteriaTextTokenizingDataset (line 11) | class MultiCriteriaTextTokenizingDataset(TextTokenizingDataset): method __init__ (line 12) | def __init__(self, method should_load_file (line 25) | def should_load_file(self, data) -> bool: method load_file (line 28) | def load_file(self, filepath: Union[Iterable[str], Dict[str, str]]): function append_criteria_token (line 87) | def append_criteria_token(sample: dict, criteria_tokens: Dict[str, int],... FILE: hanlp/datasets/tokenization/loaders/txt.py class TextTokenizingDataset (line 12) | class TextTokenizingDataset(TransformableDataset): method __init__ (line 13) | def __init__(self, method load_file (line 47) | def load_file(self, filepath: str): function generate_tags_for_subtokens (line 85) | def generate_tags_for_subtokens(sample: dict, tagging_scheme='BMES'): function subtoken_offsets_to_subtokens (line 117) | def subtoken_offsets_to_subtokens(text, token_subtoken_offsets): function subtokens_group_to_subtokens (line 124) | def subtokens_group_to_subtokens(tokens, subtoken_offsets_group): FILE: hanlp/datasets/tokenization/sighan2005/__init__.py function make (line 12) | def make(train): FILE: hanlp/layers/cnn_encoder.py class CnnEncoder (line 7) | class CnnEncoder(torch.nn.Module): method __init__ (line 48) | def __init__( method get_input_dim (line 81) | def get_input_dim(self) -> int: method get_output_dim (line 84) | def get_output_dim(self) -> int: method forward (line 87) | def forward(self, tokens: torch.Tensor, mask: torch.BoolTensor): FILE: hanlp/layers/crf/crf.py class CRF (line 28) | class CRF(nn.Module): method __init__ (line 57) | def __init__(self, num_tags: int, batch_first: bool = True) -> None: method reset_parameters (line 69) | def reset_parameters(self) -> None: method __repr__ (line 79) | def __repr__(self) -> str: method forward (line 82) | def forward( method decode (line 136) | def decode(self, emissions: torch.Tensor, method _validate (line 160) | def _validate( method _compute_score (line 188) | def _compute_score( method _compute_normalizer (line 227) | def _compute_normalizer( method _viterbi_decode (line 278) | def _viterbi_decode(self, emissions: torch.FloatTensor, FILE: hanlp/layers/crf/crf_layer_tf.py class CRF (line 21) | class CRF(tf.keras.layers.Layer): method __init__ (line 46) | def __init__(self, num_classes, **kwargs): method get_config (line 55) | def get_config(self): method build (line 64) | def build(self, input_shape): method compute_mask (line 82) | def compute_mask(self, inputs, mask=None): method call (line 88) | def call(self, inputs, sequence_lengths=None, mask=None, training=None... method compute_output_shape (line 113) | def compute_output_shape(self, input_shape): method viterbi_accuracy (line 118) | def viterbi_accuracy(self): class CRFLoss (line 131) | class CRFLoss(object): method __init__ (line 133) | def __init__(self, crf: CRF, dtype) -> None: method __call__ (line 139) | def __call__(self, y_true, y_pred, sample_weight=None, **kwargs): class CRFWrapper (line 153) | class CRFWrapper(tf.keras.Model): method __init__ (line 154) | def __init__(self, model: tf.keras.Model, num_classes=None, *args, **k... method call (line 159) | def call(self, inputs, training=None, mask=None): method compute_output_shape (line 164) | def compute_output_shape(self, input_shape): FILE: hanlp/layers/crf/crf_tf.py function crf_sequence_score (line 27) | def crf_sequence_score(inputs, tag_indices, sequence_lengths, function crf_multitag_sequence_score (line 75) | def crf_multitag_sequence_score(inputs, tag_bitmap, sequence_lengths, function crf_log_norm (line 125) | def crf_log_norm(inputs, sequence_lengths, transition_params): function crf_log_likelihood (line 175) | def crf_log_likelihood(inputs, function crf_unary_score (line 216) | def crf_unary_score(tag_indices, sequence_lengths, inputs): function crf_binary_score (line 256) | def crf_binary_score(tag_indices, sequence_lengths, transition_params): function crf_forward (line 295) | def crf_forward(inputs, state, transition_params, sequence_lengths): function viterbi_decode (line 333) | def viterbi_decode(score, transition_params): class CrfDecodeForwardRnnCell (line 366) | class CrfDecodeForwardRnnCell(tf.keras.layers.AbstractRNNCell): method __init__ (line 369) | def __init__(self, transition_params, **kwargs): method state_size (line 383) | def state_size(self): method output_size (line 387) | def output_size(self): method build (line 390) | def build(self, input_shape): method call (line 393) | def call(self, inputs, state): function crf_decode_forward (line 414) | def crf_decode_forward(inputs, state, transition_params, sequence_lengths): function crf_decode_backward (line 437) | def crf_decode_backward(inputs, state): function crf_decode (line 461) | def crf_decode(potentials, transition_params, sequence_length): FILE: hanlp/layers/dropout.py class WordDropout (line 9) | class WordDropout(nn.Module): method __init__ (line 10) | def __init__(self, p: float, oov_token: int, exclude_tokens: List[int]... method token_dropout (line 19) | def token_dropout(tokens: torch.LongTensor, method forward (line 62) | def forward(self, tokens: torch.LongTensor) -> torch.LongTensor: class SharedDropout (line 66) | class SharedDropout(nn.Module): method __init__ (line 68) | def __init__(self, p=0.5, batch_first=True): method extra_repr (line 74) | def extra_repr(self): method forward (line 81) | def forward(self, x): method get_mask (line 92) | def get_mask(x, p): class IndependentDropout (line 99) | class IndependentDropout(nn.Module): method __init__ (line 101) | def __init__(self, p=0.5): method extra_repr (line 127) | def extra_repr(self): method forward (line 130) | def forward(self, *items): class LockedDropout (line 143) | class LockedDropout(nn.Module): method __init__ (line 144) | def __init__(self, dropout_rate=0.5): method forward (line 148) | def forward(self, x): FILE: hanlp/layers/embeddings/char_cnn.py class CharCNN (line 15) | class CharCNN(nn.Module): method __init__ (line 16) | def __init__(self, method forward (line 74) | def forward(self, batch: dict, **kwargs): method get_output_dim (line 80) | def get_output_dim(self) -> int: class CharCNNEmbedding (line 84) | class CharCNNEmbedding(Embedding, AutoConfigurable): method __init__ (line 85) | def __init__(self, method transform (line 123) | def transform(self, vocabs: VocabDict, **kwargs) -> Optional[Callable]: method vocab_name (line 133) | def vocab_name(self): method module (line 137) | def module(self, vocabs: VocabDict, **kwargs) -> Optional[nn.Module]: FILE: hanlp/layers/embeddings/char_cnn_tf.py class CharCNNEmbeddingTF (line 13) | class CharCNNEmbeddingTF(tf.keras.layers.Layer): method __init__ (line 14) | def __init__(self, word_vocab: VocabTF, char_vocab: VocabTF, method call (line 32) | def call(self, inputs: tf.Tensor, **kwargs): method compute_output_shape (line 45) | def compute_output_shape(self, input_shape): method get_config (line 48) | def get_config(self): function masked_conv1d_and_max (line 59) | def masked_conv1d_and_max(t, weights, conv1d): FILE: hanlp/layers/embeddings/char_rnn.py class CharRNN (line 16) | class CharRNN(nn.Module, EmbeddingDim): method __init__ (line 17) | def __init__(self, method forward (line 47) | def forward(self, batch, mask, **kwargs): method embedding_dim (line 68) | def embedding_dim(self) -> int: class CharRNNEmbedding (line 72) | class CharRNNEmbedding(Embedding, AutoConfigurable): method __init__ (line 73) | def __init__(self, method transform (line 92) | def transform(self, vocabs: VocabDict, **kwargs) -> Optional[Callable]: method vocab_name (line 101) | def vocab_name(self): method module (line 105) | def module(self, vocabs: VocabDict, **kwargs) -> Optional[nn.Module]: FILE: hanlp/layers/embeddings/char_rnn_tf.py class CharRNNEmbeddingTF (line 11) | class CharRNNEmbeddingTF(tf.keras.layers.Layer): method __init__ (line 12) | def __init__(self, word_vocab: VocabTF, char_vocab: VocabTF, method call (line 29) | def call(self, inputs: tf.Tensor, **kwargs): method get_config (line 54) | def get_config(self): FILE: hanlp/layers/embeddings/concat_embedding.py class ConcatEmbedding (line 10) | class ConcatEmbedding(tf.keras.layers.Layer): method __init__ (line 11) | def __init__(self, *embeddings, trainable=True, name=None, dtype=None,... method build (line 26) | def build(self, input_shape): method compute_mask (line 31) | def compute_mask(self, inputs, mask=None): method call (line 38) | def call(self, inputs, **kwargs): method get_config (line 48) | def get_config(self): method compute_output_shape (line 55) | def compute_output_shape(self, input_shape): FILE: hanlp/layers/embeddings/contextual_string_embedding.py class RNNLanguageModel (line 26) | class RNNLanguageModel(nn.Module): method __init__ (line 29) | def __init__(self, method forward (line 44) | def forward(self, ids: torch.LongTensor, lens: torch.LongTensor): method load_language_model (line 52) | def load_language_model(cls, model_file): method save (line 62) | def save(self, file): class ContextualStringEmbeddingModule (line 73) | class ContextualStringEmbeddingModule(nn.Module, EmbeddingDim): method __init__ (line 75) | def __init__(self, field: str, path: str, trainable=False) -> None: method __call__ (line 87) | def __call__(self, batch: dict, **kwargs): method embedding_dim (line 94) | def embedding_dim(self): method run_lm (line 97) | def run_lm(self, lm, ids: torch.Tensor, offsets: torch.LongTensor): method forward (line 102) | def forward(self, method embed (line 111) | def embed(self, sents: List[List[str]], vocab: Dict[str, int]): class ContextualStringEmbeddingTransform (line 135) | class ContextualStringEmbeddingTransform(Configurable): method __init__ (line 137) | def __init__(self, src: str) -> None: method __call__ (line 140) | def __call__(self, sample: dict): class ContextualStringEmbedding (line 174) | class ContextualStringEmbedding(Embedding): method __init__ (line 175) | def __init__(self, field, path, trainable=False) -> None: method transform (line 181) | def transform(self, **kwargs) -> Callable: method module (line 188) | def module(self, **kwargs) -> nn.Module: function main (line 192) | def main(): function _validate (line 198) | def _validate(): FILE: hanlp/layers/embeddings/contextual_string_embedding_tf.py class ContextualStringEmbeddingTF (line 16) | class ContextualStringEmbeddingTF(tf.keras.layers.Layer): method __init__ (line 18) | def __init__(self, forward_model_path=None, backward_model_path=None, ... method call (line 36) | def call(self, inputs, **kwargs): method _load_lm (line 42) | def _load_lm(self, filepath): method embed (line 52) | def embed(self, texts: List[List[str]]): method _run_rnn (line 74) | def _run_rnn(self, texts, model): method _get_raw_string (line 97) | def _get_raw_string(self, sent: List[str], tokenizer): method get_config (line 113) | def get_config(self): method output_dim (line 123) | def output_dim(self): method compute_output_shape (line 130) | def compute_output_shape(self, input_shape): method compute_mask (line 133) | def compute_mask(self, inputs, mask=None): FILE: hanlp/layers/embeddings/contextual_word_embedding.py class ContextualWordEmbeddingModule (line 17) | class ContextualWordEmbeddingModule(TransformerEncoder): method __init__ (line 18) | def __init__(self, method forward (line 53) | def forward(self, batch: dict, mask=None, **kwargs): method get_output_dim (line 70) | def get_output_dim(self): method get_device (line 73) | def get_device(self): class ContextualWordEmbedding (line 78) | class ContextualWordEmbedding(Embedding, AutoConfigurable): method __init__ (line 79) | def __init__(self, field: str, method transform (line 156) | def transform(self, **kwargs) -> TransformerSequenceTokenizer: method module (line 159) | def module(self, training=True, **kwargs) -> Optional[nn.Module]: method get_output_dim (line 172) | def get_output_dim(self): method get_tokenizer (line 176) | def get_tokenizer(self): function find_transformer (line 180) | def find_transformer(embed: nn.Module): FILE: hanlp/layers/embeddings/embedding.py class EmbeddingDim (line 16) | class EmbeddingDim(ABC): method embedding_dim (line 19) | def embedding_dim(self) -> int: method get_output_dim (line 22) | def get_output_dim(self) -> int: class Embedding (line 26) | class Embedding(AutoConfigurable, ABC): method __init__ (line 28) | def __init__(self) -> None: method transform (line 34) | def transform(self, **kwargs) -> Optional[Callable]: method module (line 45) | def module(self, **kwargs) -> Optional[nn.Module]: class ConcatModuleList (line 57) | class ConcatModuleList(nn.ModuleList, EmbeddingDim): method __init__ (line 59) | def __init__(self, *modules: Optional[Iterable[Module]], dropout=None)... method embedding_dim (line 72) | def embedding_dim(self) -> int: method get_output_dim (line 75) | def get_output_dim(self) -> int: method forward (line 79) | def forward(self, batch: dict, **kwargs): method embeddings (line 86) | def embeddings(self): class EmbeddingList (line 93) | class EmbeddingList(Embedding): method __init__ (line 94) | def __init__(self, *embeddings_, embeddings: dict = None, dropout=None... method transform (line 112) | def transform(self, **kwargs): method module (line 117) | def module(self, **kwargs): method to_list (line 122) | def to_list(self): function find_embedding_by_class (line 126) | def find_embedding_by_class(embed: Embedding, cls): FILE: hanlp/layers/embeddings/fast_text.py class FastTextTransform (line 26) | class FastTextTransform(EmbeddingNamedTransform): method __init__ (line 27) | def __init__(self, filepath: str, src, dst=None, **kwargs) -> None: method __call__ (line 39) | def __call__(self, sample: dict): method embed (line 48) | def embed(self, word: str): class SelectFromBatchModule (line 52) | class SelectFromBatchModule(torch.nn.Module): method __init__ (line 53) | def __init__(self, key) -> None: method __call__ (line 57) | def __call__(self, batch: dict, mask=None, **kwargs): class FastTextEmbeddingModule (line 61) | class FastTextEmbeddingModule(SelectFromBatchModule): method __init__ (line 63) | def __init__(self, key, embedding_dim: int) -> None: method __call__ (line 73) | def __call__(self, batch: dict, mask=None, **kwargs): method __repr__ (line 80) | def __repr__(self): method get_output_dim (line 86) | def get_output_dim(self): class FastTextEmbedding (line 90) | class FastTextEmbedding(Embedding, AutoConfigurable): method __init__ (line 91) | def __init__(self, src: str, filepath: str) -> None: method transform (line 103) | def transform(self, **kwargs) -> Optional[Callable]: method module (line 106) | def module(self, **kwargs) -> Optional[nn.Module]: class FastTextDataset (line 110) | class FastTextDataset(TransformableDataset): method load_file (line 112) | def load_file(self, filepath: str): class FastTextEmbeddingComponent (line 116) | class FastTextEmbeddingComponent(TorchComponent): method __init__ (line 117) | def __init__(self, **kwargs) -> None: method build_dataloader (line 125) | def build_dataloader(self, data, shuffle=False, device=None, logger: l... method build_optimizer (line 131) | def build_optimizer(self, **kwargs): method build_criterion (line 134) | def build_criterion(self, **kwargs): method build_metric (line 137) | def build_metric(self, **kwargs): method execute_training_loop (line 140) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 144) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 147) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method load_vocabs (line 150) | def load_vocabs(self, save_dir, filename='vocabs.json'): method load_weights (line 153) | def load_weights(self, save_dir, filename='model.pt', **kwargs): method build_model (line 156) | def build_model(self, training=True, **kwargs) -> torch.nn.Module: method predict (line 160) | def predict(self, data: str, **kwargs): method devices (line 166) | def devices(self): FILE: hanlp/layers/embeddings/fast_text_tf.py class FastTextEmbeddingTF (line 18) | class FastTextEmbeddingTF(tf.keras.layers.Embedding): method __init__ (line 20) | def __init__(self, filepath: str, padding=PAD, name=None, **kwargs): method embed (line 41) | def embed(self, word): method embed_np (line 44) | def embed_np(self, words: np.ndarray): method build (line 56) | def build(self, input_shape): method compute_output_shape (line 60) | def compute_output_shape(self, input_shape): method call (line 63) | def call(self, inputs: tf.Tensor): method compute_mask (line 84) | def compute_mask(self, inputs, mask=None): method get_config (line 89) | def get_config(self): FILE: hanlp/layers/embeddings/util.py function index_word2vec_with_vocab (line 14) | def index_word2vec_with_vocab(filepath: str, function build_word2vec_with_vocab (line 78) | def build_word2vec_with_vocab(embed: Union[str, int], FILE: hanlp/layers/embeddings/util_tf.py function build_embedding (line 23) | def build_embedding(embeddings: Union[str, int, dict], word_vocab: Vocab... function any_embedding_in (line 69) | def any_embedding_in(embeddings, *cls): function embeddings_require_string_input (line 78) | def embeddings_require_string_input(embeddings): function embeddings_require_char_input (line 85) | def embeddings_require_char_input(embeddings): FILE: hanlp/layers/embeddings/word2vec.py class Word2VecEmbeddingModule (line 27) | class Word2VecEmbeddingModule(nn.Module, EmbeddingDim): method __init__ (line 28) | def __init__(self, field: str, embed: nn.Embedding, word_dropout: Word... method forward (line 57) | def forward(self, batch: dict, **kwargs): method embedding_dim (line 76) | def embedding_dim(self) -> int: method _apply (line 87) | def _apply(self, fn): class Word2VecEmbedding (line 93) | class Word2VecEmbedding(Embedding, AutoConfigurable): method __init__ (line 94) | def __init__(self, method module (line 139) | def module(self, vocabs: VocabDict, **kwargs) -> Optional[nn.Module]: method transform (line 162) | def transform(self, vocabs: VocabDict = None, **kwargs) -> Optional[Ca... class Word2VecDataset (line 169) | class Word2VecDataset(TransformableDataset): method load_file (line 171) | def load_file(self, filepath: str): class Word2VecEmbeddingComponent (line 175) | class Word2VecEmbeddingComponent(TorchComponent): method __init__ (line 177) | def __init__(self, **kwargs) -> None: method build_dataloader (line 186) | def build_dataloader(self, data: List[str], shuffle=False, device=None... method build_optimizer (line 191) | def build_optimizer(self, **kwargs): method build_criterion (line 194) | def build_criterion(self, **kwargs): method build_metric (line 197) | def build_metric(self, **kwargs): method execute_training_loop (line 200) | def execute_training_loop(self, trn: DataLoader, dev: DataLoader, epoc... method fit_dataloader (line 204) | def fit_dataloader(self, trn: DataLoader, criterion, optimizer, metric... method evaluate_dataloader (line 207) | def evaluate_dataloader(self, data: DataLoader, criterion: Callable, m... method load_vocabs (line 210) | def load_vocabs(self, save_dir, filename='vocabs.json'): method load_weights (line 213) | def load_weights(self, save_dir, filename='model.pt', **kwargs): method build_model (line 216) | def build_model(self, training=True, **kwargs) -> torch.nn.Module: method predict (line 222) | def predict(self, word: str, doc2vec=False, **kwargs): method most_similar (line 231) | def most_similar(self, words: Union[str, List[str]], topk=10, doc2vec=... method _tokenize (line 276) | def _tokenize(self, sample: dict) -> dict: method tokenizer (line 287) | def tokenizer(self): method load_config (line 296) | def load_config(self, save_dir, filename='config.json', **kwargs): class GazetterTransform (line 304) | class GazetterTransform(object): method __init__ (line 305) | def __init__(self, field, words: dict) -> None: method __call__ (line 312) | def __call__(self, sample: dict) -> dict: class GazetteerEmbedding (line 328) | class GazetteerEmbedding(Embedding, AutoConfigurable): method __init__ (line 329) | def __init__(self, embed: str, field='char', trainable=False) -> None: method transform (line 345) | def transform(self, **kwargs) -> Optional[Callable]: method module (line 348) | def module(self, **kwargs) -> Optional[nn.Module]: method _remove_short_tokens (line 353) | def _remove_short_tokens(word2vec): FILE: hanlp/layers/embeddings/word2vec_tf.py class Word2VecEmbeddingV1 (line 18) | class Word2VecEmbeddingV1(tf.keras.layers.Layer): method __init__ (line 19) | def __init__(self, path: str = None, vocab: VocabTF = None, normalize:... method compute_mask (line 32) | def compute_mask(self, inputs, mask=None): method call (line 38) | def call(self, inputs, **kwargs): method compute_output_shape (line 41) | def compute_output_shape(self, input_shape): method _load (line 45) | def _load(path, vocab, normalize=False) -> Tuple[VocabTF, Union[np.nda... method size (line 76) | def size(self): method dim (line 81) | def dim(self): method shape (line 86) | def shape(self): method get_vector (line 91) | def get_vector(self, word: str) -> np.ndarray: method __getitem__ (line 95) | def __getitem__(self, word: Union[str, List, tf.Tensor]) -> np.ndarray: class Word2VecEmbeddingTF (line 112) | class Word2VecEmbeddingTF(tf.keras.layers.Embedding): method __init__ (line 114) | def __init__(self, filepath: str = None, vocab: VocabTF = None, expand... method get_config (line 161) | def get_config(self): class StringWord2VecEmbeddingTF (line 173) | class StringWord2VecEmbeddingTF(Word2VecEmbeddingTF): method __init__ (line 175) | def __init__(self, filepath: str = None, vocab: VocabTF = None, expand... method call (line 186) | def call(self, inputs): method compute_mask (line 194) | def compute_mask(self, inputs, mask=None): FILE: hanlp/layers/feed_forward.py class FeedForward (line 11) | class FeedForward(feedforward.FeedForward, ConfigTracker): method __init__ (line 12) | def __init__(self, input_dim: int, num_layers: int, hidden_dims: Union... FILE: hanlp/layers/feedforward.py class FeedForward (line 10) | class FeedForward(torch.nn.Module): method __init__ (line 54) | def __init__( method get_output_dim (line 94) | def get_output_dim(self): method get_input_dim (line 97) | def get_input_dim(self): method forward (line 100) | def forward(self, inputs: torch.Tensor) -> torch.Tensor: FILE: hanlp/layers/scalar_mix.py class ScalarMixWithDropout (line 35) | class ScalarMixWithDropout(torch.nn.Module): method __init__ (line 51) | def __init__(self, method forward (line 86) | def forward(self, tensors: List[torch.Tensor], # pylint: disable=argu... class ScalarMixWithDropoutBuilder (line 144) | class ScalarMixWithDropoutBuilder(ConfigTracker, ScalarMixWithDropout): method __init__ (line 146) | def __init__(self, method build (line 155) | def build(self): FILE: hanlp/layers/time_distributed.py class TimeDistributed (line 13) | class TimeDistributed(torch.nn.Module): method __init__ (line 26) | def __init__(self, module): method forward (line 31) | def forward(self, *inputs, pass_through: List[str] = None, **kwargs): method _reshape_tensor (line 65) | def _reshape_tensor(input_tensor): FILE: hanlp/layers/transformers/encoder.py class TransformerEncoder (line 18) | class TransformerEncoder(nn.Module): method __init__ (line 19) | def __init__(self, method forward (line 97) | def forward(self, input_ids: torch.LongTensor, attention_mask=None, to... method build_transformer (line 120) | def build_transformer(config, training=True) -> PreTrainedModel: method build_transformer_tokenizer (line 128) | def build_transformer_tokenizer(config_or_str, use_fast=True, do_basic... FILE: hanlp/layers/transformers/loader_tf.py function build_transformer (line 10) | def build_transformer(transformer, max_seq_length, num_labels, tagging=T... FILE: hanlp/layers/transformers/pt_imports.py class AutoModel_ (line 16) | class AutoModel_(AutoModel): method from_pretrained (line 18) | def from_pretrained(cls, pretrained_model_name_or_path, *model_args, t... class AutoConfig_ (line 31) | class AutoConfig_(AutoConfig): method from_pretrained (line 33) | def from_pretrained(cls, pretrained_model_name_or_path, **kwargs): class AutoTokenizer_ (line 38) | class AutoTokenizer_(AutoTokenizer): method from_pretrained (line 41) | def from_pretrained(cls, pretrained_model_name_or_path, use_fast=True, FILE: hanlp/layers/transformers/relative_transformer.py class RelativeSinusoidalPositionalEmbedding (line 13) | class RelativeSinusoidalPositionalEmbedding(nn.Module): method __init__ (line 24) | def __init__(self, embedding_dim, padding_idx, init_size=1024): method get_embedding (line 36) | def get_embedding(self, num_embeddings, embedding_dim, padding_idx=None): method forward (line 62) | def forward(self, inputs: Tensor): class RelativeMultiHeadAttn (line 90) | class RelativeMultiHeadAttn(nn.Module): method __init__ (line 91) | def __init__(self, in_features, num_heads, dropout, r_w_bias=None, r_r... method forward (line 120) | def forward(self, x, mask): method _shift (line 168) | def _shift(self, BD): method _transpose_shift (line 193) | def _transpose_shift(self, E): class RelativeTransformerLayer (line 221) | class RelativeTransformerLayer(nn.Module): method __init__ (line 222) | def __init__(self, method forward (line 248) | def forward(self, x, mask): class RelativeTransformer (line 277) | class RelativeTransformer(nn.Module): method __init__ (line 278) | def __init__(self, method forward (line 295) | def forward(self, x: Tensor, mask: Tensor): class RelativeTransformerEncoder (line 314) | class RelativeTransformerEncoder(RelativeTransformer, ConfigTracker): method __init__ (line 315) | def __init__(self, method get_output_dim (line 328) | def get_output_dim(self): FILE: hanlp/layers/transformers/resource.py function get_tokenizer_mirror (line 27) | def get_tokenizer_mirror(transformer: str) -> str: function get_model_mirror (line 34) | def get_model_mirror(transformer: str) -> str: FILE: hanlp/layers/transformers/utils.py function transformer_encode (line 14) | def transformer_encode(transformer: PreTrainedModel, function pick_tensor_for_each_token (line 81) | def pick_tensor_for_each_token(h, token_span, average_subwords): function transformer_sliding_window (line 101) | def transformer_sliding_window(transformer: PreTrainedModel, function split_to_sliding_window (line 215) | def split_to_sliding_window(input_ids, max_pieces): function restore_from_sliding_window (line 227) | def restore_from_sliding_window(all_encoder_layers, batch_size, max_piec... function build_optimizer_for_pretrained (line 253) | def build_optimizer_for_pretrained(model: torch.nn.Module, function build_optimizer_scheduler_with_transformer (line 296) | def build_optimizer_scheduler_with_transformer(model: torch.nn.Module, function get_optimizers (line 320) | def get_optimizers( function collect_decay_params (line 357) | def collect_decay_params(model, weight_decay): FILE: hanlp/layers/transformers/utils_tf.py function config_is (line 9) | def config_is(config, model='bert'): function convert_examples_to_features (line 13) | def convert_examples_to_features( function build_adamw_optimizer (line 153) | def build_adamw_optimizer(config, learning_rate, epsilon, clipnorm, trai... function adjust_tokens_for_transformers (line 173) | def adjust_tokens_for_transformers(sentence): FILE: hanlp/layers/weight_normalization.py class WeightNormalization (line 25) | class WeightNormalization(tf.keras.layers.Wrapper): method __init__ (line 64) | def __init__(self, layer, data_init=True, **kwargs): method build (line 71) | def build(self, input_shape): method call (line 128) | def call(self, inputs): method compute_output_shape (line 160) | def compute_output_shape(self, input_shape): method _initialize_weights (line 164) | def _initialize_weights(self, inputs): method _init_norm (line 189) | def _init_norm(self): method _data_dep_init (line 197) | def _data_dep_init(self, inputs): method get_config (line 221) | def get_config(self): FILE: hanlp/losses/sparse_categorical_crossentropy.py class SparseCategoricalCrossentropyOverNonzeroWeights (line 11) | class SparseCategoricalCrossentropyOverNonzeroWeights(object): method __init__ (line 12) | def __init__(self) -> None: method __call__ (line 16) | def __call__(self, y_true, y_pred, sample_weight=None, **kwargs): class SparseCategoricalCrossentropyOverBatchFirstDim (line 30) | class SparseCategoricalCrossentropyOverBatchFirstDim(object): method __init__ (line 32) | def __init__(self) -> None: method __call__ (line 36) | def __call__(self, y_true, y_pred, sample_weight=None, **kwargs): method get_config (line 44) | def get_config(self): class MaskedSparseCategoricalCrossentropyOverBatchFirstDim (line 49) | class MaskedSparseCategoricalCrossentropyOverBatchFirstDim(object): method __init__ (line 50) | def __init__(self, mask_value=0) -> None: method __call__ (line 55) | def __call__(self, y_true, y_pred, sample_weight=None, **kwargs): FILE: hanlp/metrics/accuracy.py class CategoricalAccuracy (line 11) | class CategoricalAccuracy(Metric): method __init__ (line 20) | def __init__(self, top_k: int = 1, tie_break: bool = False) -> None: method __call__ (line 32) | def __call__( method score (line 98) | def score(self): method __repr__ (line 105) | def __repr__(self) -> str: method detach_tensors (line 109) | def detach_tensors(*tensors: torch.Tensor) -> Iterable[torch.Tensor]: method reset (line 118) | def reset(self): class BooleanAccuracy (line 123) | class BooleanAccuracy(Metric): method __init__ (line 139) | def __init__(self) -> None: method __call__ (line 143) | def __call__( method get_metric (line 201) | def get_metric(self, reset: bool = False): method reset (line 215) | def reset(self): method detach_tensors (line 220) | def detach_tensors(*tensors: torch.Tensor) -> Iterable[torch.Tensor]: FILE: hanlp/metrics/amr/smatch_eval.py class SmatchScores (line 17) | class SmatchScores(MetricDict): method score (line 19) | def score(self): function smatch_eval (line 23) | def smatch_eval(pred, gold, use_fast=False) -> Union[SmatchScores, F1_]: function post_process (line 36) | def post_process(pred, amr_version): function get_amr_utils (line 48) | def get_amr_utils(amr_version): function format_official_scores (line 60) | def format_official_scores(text: str): function format_fast_scores (line 88) | def format_fast_scores(text: str): FILE: hanlp/metrics/chunking/binary_chunking_f1.py class BinaryChunkingF1 (line 12) | class BinaryChunkingF1(F1): method __call__ (line 13) | def __call__(self, pred_tags: torch.LongTensor, gold_tags: torch.LongT... method update (line 18) | def update(self, pred_tags, gold_tags): method decode_spans (line 23) | def decode_spans(pred_tags: torch.LongTensor, lens: Union[List[int], t... FILE: hanlp/metrics/chunking/bmes_tf.py class BMES_F1_TF (line 10) | class BMES_F1_TF(ChunkingF1_TF): method __init__ (line 12) | def __init__(self, tag_vocab: VocabTF, from_logits=True, suffix=False,... method update_tags (line 19) | def update_tags(self, true_tags, pred_tags): method update_entities (line 24) | def update_entities(self, true_entities, pred_entities): method result (line 34) | def result(self): method reset_states (line 44) | def reset_states(self): FILE: hanlp/metrics/chunking/chunking_f1.py class ChunkingF1 (line 14) | class ChunkingF1(F1): method __call__ (line 16) | def __call__(self, pred_tags: List[List[str]], gold_tags: List[List[st... class DetailedSpanF1 (line 25) | class DetailedSpanF1(Metric): method __init__ (line 26) | def __init__(self, do_confusion_matrix=False): method states (line 44) | def states(self): method reset_state (line 47) | def reset_state(self): method score (line 59) | def score(self): method __call__ (line 65) | def __call__(self, pred: Set[Tuple[int, int, str]], gold: Set[Tuple[in... method reset (line 101) | def reset(self): method report (line 104) | def report(self) -> Tuple[DetailedF1, Dict[str, DetailedF1], str]: method __str__ (line 132) | def __str__(self) -> str: method confusion_matrix (line 135) | def confusion_matrix(self): FILE: hanlp/metrics/chunking/chunking_f1_tf.py class ChunkingF1_TF (line 11) | class ChunkingF1_TF(tf.keras.metrics.Metric, ABC): method __init__ (line 13) | def __init__(self, tag_vocab: VocabTF, from_logits=True, name='f1', dt... method update_the_state (line 18) | def update_the_state(self, y_true: tf.Tensor, y_pred: tf.Tensor, sampl... method __call__ (line 36) | def __call__(self, y_true: tf.Tensor, y_pred: tf.Tensor, sample_weight... method update_state (line 39) | def update_state(self, y_true: tf.Tensor, y_pred: tf.Tensor, sample_we... method to_tags (line 42) | def to_tags(self, y: tf.Tensor, sample_weight: tf.Tensor): method update_tags (line 60) | def update_tags(self, true_tags, pred_tags): method result (line 64) | def result(self): FILE: hanlp/metrics/chunking/conlleval.py class FormatError (line 24) | class FormatError(Exception): class EvalCounts (line 31) | class EvalCounts(object): method __init__ (line 32) | def __init__(self): method states (line 45) | def states(self): method reset_state (line 48) | def reset_state(self): class SpanF1 (line 58) | class SpanF1(Metric): method __init__ (line 60) | def __init__(self, label_encoding='IOBES') -> None: method reset (line 65) | def reset(self): method score (line 69) | def score(self): method reset_state (line 72) | def reset_state(self): method update_state (line 75) | def update_state(self, true_seqs: List[str], pred_seqs: List[str]): method batch_update_state (line 91) | def batch_update_state(self, true_seqs: List[List[str]], pred_seqs: Li... method result (line 95) | def result(self, full=True, verbose=True) -> Union[Tuple[DetailedF1, d... method __call__ (line 109) | def __call__(self, pred_seqs: List[List[str]], true_seqs: List[List[st... method __repr__ (line 112) | def __repr__(self) -> str: function parse_args (line 117) | def parse_args(argv): function split_tag (line 134) | def split_tag(chunk_tag): function evaluate_iobes (line 151) | def evaluate_iobes(true_seqs, pred_seqs): function evaluate_iob2 (line 207) | def evaluate_iob2(true_seqs, pred_seqs): function uniq (line 217) | def uniq(iterable): function calculate_metrics (line 222) | def calculate_metrics(correct, guessed, total): function calc_metrics (line 230) | def calc_metrics(tp, p, t, percent=True): function metrics (line 252) | def metrics(counts): function report (line 265) | def report(counts, out=None): function end_of_chunk (line 292) | def end_of_chunk(prev_tag, tag, prev_type, type_): function start_of_chunk (line 309) | def start_of_chunk(prev_tag, tag, prev_type, type_): function main (line 332) | def main(argv): FILE: hanlp/metrics/chunking/iobes_tf.py class IOBES_F1_TF (line 10) | class IOBES_F1_TF(ChunkingF1_TF): method __init__ (line 12) | def __init__(self, tag_vocab: VocabTF, from_logits=True, name='f1', dt... method update_tags (line 16) | def update_tags(self, true_tags, pred_tags): method result (line 24) | def result(self): method reset_states (line 27) | def reset_states(self): FILE: hanlp/metrics/chunking/sequence_labeling.py function iobes_to_span (line 31) | def iobes_to_span(words, tags): function get_entities (line 41) | def get_entities(seq, suffix=False): function end_of_chunk (line 83) | def end_of_chunk(prev_tag, tag, prev_type, type_): function start_of_chunk (line 114) | def start_of_chunk(prev_tag, tag, prev_type, type_): function f1_score (line 145) | def f1_score(y_true, y_pred, average='micro', suffix=False): function accuracy_score (line 185) | def accuracy_score(y_true, y_pred): function precision_score (line 218) | def precision_score(y_true, y_pred, average='micro', suffix=False): function recall_score (line 254) | def recall_score(y_true, y_pred, average='micro', suffix=False): function performance_measure (line 290) | def performance_measure(y_true, y_pred): function classification_report (line 322) | def classification_report(y_true, y_pred, digits=2, suffix=False): FILE: hanlp/metrics/f1.py class F1 (line 9) | class F1(Metric, ABC): method __init__ (line 10) | def __init__(self, nb_pred=0, nb_true=0, nb_correct=0) -> None: method __repr__ (line 16) | def __repr__(self) -> str: method prf (line 21) | def prf(self): method score (line 31) | def score(self): method reset (line 34) | def reset(self): method __call__ (line 39) | def __call__(self, pred: set, gold: set): class F1_ (line 45) | class F1_(Metric): method __init__ (line 46) | def __init__(self, p, r, f) -> None: method score (line 53) | def score(self): method __call__ (line 56) | def __call__(self, pred, gold): method reset (line 59) | def reset(self): method __repr__ (line 62) | def __repr__(self) -> str: FILE: hanlp/metrics/metric.py class Metric (line 7) | class Metric(ABC): method __lt__ (line 9) | def __lt__(self, other): method __le__ (line 12) | def __le__(self, other): method __eq__ (line 15) | def __eq__(self, other): method __ge__ (line 18) | def __ge__(self, other): method __gt__ (line 21) | def __gt__(self, other): method __ne__ (line 24) | def __ne__(self, other): method score (line 29) | def score(self): method __call__ (line 33) | def __call__(self, pred, gold, mask=None): method __repr__ (line 36) | def __repr__(self) -> str: method __float__ (line 39) | def __float__(self): method reset (line 43) | def reset(self): FILE: hanlp/metrics/mtl.py class MetricDict (line 7) | class MetricDict(Metric, dict): method score (line 11) | def score(self): method __call__ (line 14) | def __call__(self, pred, gold): method reset (line 18) | def reset(self): method __repr__ (line 22) | def __repr__(self) -> str: method cstr (line 25) | def cstr(self, idx=None, level=0) -> str: FILE: hanlp/metrics/parsing/attachmentscore.py class AttachmentScore (line 26) | class AttachmentScore(Metric): method __init__ (line 28) | def __init__(self, eps=1e-12): method __repr__ (line 36) | def __repr__(self): method __call__ (line 40) | def __call__(self, arc_preds, rel_preds, arc_golds, rel_golds, mask): method __lt__ (line 48) | def __lt__(self, other): method __le__ (line 51) | def __le__(self, other): method __ge__ (line 54) | def __ge__(self, other): method __gt__ (line 57) | def __gt__(self, other): method score (line 61) | def score(self): method uas (line 65) | def uas(self): method las (line 69) | def las(self): method reset (line 72) | def reset(self): FILE: hanlp/metrics/parsing/conllx_eval.py function evaluate (line 12) | def evaluate(gold_file, pred_file): function copy_cols (line 40) | def copy_cols(gold_file, pred_file, copied_pred_file, keep_comments=True): FILE: hanlp/metrics/parsing/labeled_f1.py class LabeledF1 (line 8) | class LabeledF1(Metric): method __init__ (line 10) | def __init__(self): method __repr__ (line 18) | def __repr__(self): method __call__ (line 21) | def __call__(self, arc_preds, rel_preds, arc_golds, rel_golds, mask): method __lt__ (line 34) | def __lt__(self, other): method __le__ (line 37) | def __le__(self, other): method __ge__ (line 40) | def __ge__(self, other): method __gt__ (line 43) | def __gt__(self, other): method score (line 47) | def score(self): method uas (line 51) | def uas(self): method las (line 55) | def las(self): method ur (line 59) | def ur(self): method up (line 65) | def up(self): method lr (line 71) | def lr(self): method lp (line 77) | def lp(self): method uf (line 83) | def uf(self): method lf (line 90) | def lf(self): method reset (line 96) | def reset(self): method to_dict (line 102) | def to_dict(self) -> dict: FILE: hanlp/metrics/parsing/labeled_f1_tf.py class LabeledF1TF (line 7) | class LabeledF1TF(object): method __init__ (line 9) | def __init__(self): method __repr__ (line 17) | def __repr__(self): method __call__ (line 20) | def __call__(self, arc_preds, rel_preds, arc_golds, rel_golds, mask): method __lt__ (line 34) | def __lt__(self, other): method __le__ (line 37) | def __le__(self, other): method __ge__ (line 40) | def __ge__(self, other): method __gt__ (line 43) | def __gt__(self, other): method score (line 47) | def score(self): method uas (line 51) | def uas(self): method las (line 55) | def las(self): method ur (line 59) | def ur(self): method up (line 65) | def up(self): method lr (line 71) | def lr(self): method lp (line 77) | def lp(self): method uf (line 83) | def uf(self): method lf (line 90) | def lf(self): method reset_states (line 96) | def reset_states(self): method to_dict (line 102) | def to_dict(self) -> dict: FILE: hanlp/metrics/parsing/labeled_score.py class LabeledScore (line 8) | class LabeledScore(object): method __init__ (line 10) | def __init__(self, eps=1e-5): method __repr__ (line 18) | def __repr__(self): method __call__ (line 21) | def __call__(self, arc_preds, rel_preds, arc_golds, rel_golds, mask): method __lt__ (line 29) | def __lt__(self, other): method __le__ (line 32) | def __le__(self, other): method __ge__ (line 35) | def __ge__(self, other): method __gt__ (line 38) | def __gt__(self, other): method score (line 42) | def score(self): method uas (line 46) | def uas(self): method las (line 50) | def las(self): method reset_states (line 53) | def reset_states(self): method to_dict (line 58) | def to_dict(self) -> dict: FILE: hanlp/metrics/parsing/semdep_eval.py function sdp_eval (line 28) | def sdp_eval(gold_files, sys_files, labeled=False): function main (line 122) | def main(): FILE: hanlp/metrics/parsing/span.py class SpanMetric (line 28) | class SpanMetric(Metric): method __init__ (line 30) | def __init__(self, eps=1e-12): method reset (line 35) | def reset(self, eps=1e-12): method __call__ (line 45) | def __call__(self, preds, golds): method __repr__ (line 62) | def __repr__(self): method score (line 70) | def score(self): method ucm (line 74) | def ucm(self): method lcm (line 78) | def lcm(self): method up (line 82) | def up(self): method ur (line 86) | def ur(self): method uf (line 90) | def uf(self): method lp (line 94) | def lp(self): method lr (line 98) | def lr(self): method lf (line 102) | def lf(self): FILE: hanlp/metrics/spearman_correlation.py function _get_ranks (line 9) | def _get_ranks(x: torch.Tensor) -> torch.Tensor: function spearman_correlation (line 16) | def spearman_correlation(x: torch.Tensor, y: torch.Tensor): class SpearmanCorrelation (line 34) | class SpearmanCorrelation(Metric): method score (line 46) | def score(self): method __init__ (line 49) | def __init__(self) -> None: method __call__ (line 54) | def __call__( method reset (line 81) | def reset(self): method __str__ (line 85) | def __str__(self) -> str: FILE: hanlp/metrics/srl/srlconll.py function official_conll_05_evaluate (line 9) | def official_conll_05_evaluate(pred_path, gold_path): function run_perl (line 28) | def run_perl(script, src, dst=None): FILE: hanlp/optimizers/adamw/__init__.py function create_optimizer (line 35) | def create_optimizer(init_lr, num_train_steps, num_warmup_steps, weight_... FILE: hanlp/optimizers/adamw/optimization.py class WarmUp (line 26) | class WarmUp(tf.keras.optimizers.schedules.LearningRateSchedule): method __init__ (line 29) | def __init__( method __call__ (line 43) | def __call__(self, step): method get_config (line 58) | def get_config(self): function create_optimizer (line 68) | def create_optimizer(init_lr, num_train_steps, num_warmup_steps): class AdamWeightDecay (line 104) | class AdamWeightDecay(AdamTF): method __init__ (line 121) | def __init__(self, method from_config (line 139) | def from_config(cls, config): method _prepare_local (line 152) | def _prepare_local(self, var_device, var_dtype, apply_state): method _decay_weights_op (line 158) | def _decay_weights_op(self, var, learning_rate, apply_state): method apply_gradients (line 167) | def apply_gradients(self, grads_and_vars, name=None): method _get_lr (line 172) | def _get_lr(self, var_device, var_dtype, apply_state): method _resource_apply_dense (line 194) | def _resource_apply_dense(self, grad, var, apply_state=None): method _resource_apply_sparse (line 201) | def _resource_apply_sparse(self, grad, var, indices, apply_state=None): method get_config (line 208) | def get_config(self): method _do_use_weight_decay (line 215) | def _do_use_weight_decay(self, param_name): method apply_gradients (line 238) | def apply_gradients(self, grads_and_vars, name=None, **kwargs): FILE: hanlp/transform/conll_tf.py class CoNLLTransform (line 25) | class CoNLLTransform(Transform): method __init__ (line 27) | def __init__(self, config: SerializableDict = None, map_x=True, map_y=... method use_pos (line 37) | def use_pos(self): method x_to_idx (line 40) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: method y_to_idx (line 44) | def y_to_idx(self, y): method X_to_inputs (line 48) | def X_to_inputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]]) -> Iterable: method lock_vocabs (line 67) | def lock_vocabs(self): method file_to_inputs (line 72) | def file_to_inputs(self, filepath: str, gold=True): method bos (line 95) | def bos(self): method input_is_single_sample (line 100) | def input_is_single_sample(self, input: Any) -> bool: method batched_inputs_to_batches (line 107) | def batched_inputs_to_batches(self, corpus, indices, shuffle): method len_of_sent (line 110) | def len_of_sent(self, sent): method samples_to_dataset (line 113) | def samples_to_dataset(self, samples: Generator, map_x=None, map_y=Non... class CoNLL_DEP_Transform (line 168) | class CoNLL_DEP_Transform(CoNLLTransform): method __init__ (line 170) | def __init__(self, config: SerializableDict = None, map_x=True, map_y=... method batched_inputs_to_batches (line 174) | def batched_inputs_to_batches(self, corpus, indices, shuffle): method create_types_shapes_values (line 203) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method inputs_to_samples (line 210) | def inputs_to_samples(self, inputs, gold=False): method XY_to_inputs_outputs (line 232) | def XY_to_inputs_outputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]], ... method fit (line 255) | def fit(self, trn_path: str, **kwargs) -> int: method root_rel_idx (line 284) | def root_rel_idx(self): method Y_to_outputs (line 293) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... class CoNLL_Transformer_Transform (line 306) | class CoNLL_Transformer_Transform(CoNLL_DEP_Transform): method __init__ (line 308) | def __init__(self, config: SerializableDict = None, map_x=True, map_y=... method lock_vocabs (line 318) | def lock_vocabs(self): method fit (line 323) | def fit(self, trn_path: str, **kwargs) -> int: method inputs_to_samples (line 342) | def inputs_to_samples(self, inputs, gold=False): method file_to_inputs (line 348) | def file_to_inputs(self, filepath: str, gold=True): method mask_p (line 355) | def mask_p(self) -> float: method graph (line 359) | def graph(self): method create_types_shapes_values (line 362) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method X_to_inputs (line 382) | def X_to_inputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]]) -> Iterable: method batched_inputs_to_batches (line 392) | def batched_inputs_to_batches(self, corpus, indices, shuffle): method len_of_sent (line 541) | def len_of_sent(self, sent): method samples_to_dataset (line 575) | def samples_to_dataset(self, samples: Generator, map_x=None, map_y=Non... method Y_to_outputs (line 602) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... class CoNLL_SDP_Transform (line 610) | class CoNLL_SDP_Transform(CoNLLTransform): method __init__ (line 612) | def __init__(self, config: SerializableDict = None, map_x=True, map_y=... method lock_vocabs (line 617) | def lock_vocabs(self): method _find_orphan_relation (line 622) | def _find_orphan_relation(self): method file_to_inputs (line 628) | def file_to_inputs(self, filepath: str, gold=True): method fit (line 678) | def fit(self, trn_path: str, **kwargs) -> int: method inputs_to_samples (line 711) | def inputs_to_samples(self, inputs, gold=False): method batched_inputs_to_batches (line 734) | def batched_inputs_to_batches(self, corpus, indices, shuffle): method create_types_shapes_values (line 771) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method Y_to_outputs (line 778) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... method XY_to_inputs_outputs (line 798) | def XY_to_inputs_outputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]], ... FILE: hanlp/transform/glue_tf.py class StanfordSentimentTreebank2Transorm (line 9) | class StanfordSentimentTreebank2Transorm(TableTransform): class MicrosoftResearchParaphraseCorpus (line 13) | class MicrosoftResearchParaphraseCorpus(TableTransform): method __init__ (line 15) | def __init__(self, config: SerializableDict = None, map_x=False, map_y... function main (line 20) | def main(): function _test_sst2 (line 25) | def _test_sst2(): function _test_mrpc (line 36) | def _test_mrpc(): FILE: hanlp/transform/table_tf.py class TableTransform (line 17) | class TableTransform(Transform, ABC): method __init__ (line 18) | def __init__(self, config: SerializableDict = None, map_x=False, map_y... method file_to_inputs (line 26) | def file_to_inputs(self, filepath: str, gold=True): method inputs_to_samples (line 57) | def inputs_to_samples(self, inputs, gold=False): method y_to_idx (line 65) | def y_to_idx(self, y) -> tf.Tensor: method fit (line 68) | def fit(self, trn_path: str, **kwargs): method create_types_shapes_values (line 79) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method x_to_idx (line 87) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: FILE: hanlp/transform/tacred_tf.py function get_positions (line 15) | def get_positions(start_idx, end_idx, length): class TACREDTransform (line 30) | class TACREDTransform(Transform): method __init__ (line 31) | def __init__(self, config: SerializableDict = None, map_x=True, map_y=... method fit (line 39) | def fit(self, trn_path: str, **kwargs) -> int: method file_to_inputs (line 52) | def file_to_inputs(self, filepath: str, gold=True): method inputs_to_samples (line 66) | def inputs_to_samples(self, inputs, gold=False): method create_types_shapes_values (line 85) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method x_to_idx (line 95) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: method y_to_idx (line 105) | def y_to_idx(self, y) -> tf.Tensor: FILE: hanlp/transform/text_tf.py class TextTransform (line 16) | class TextTransform(Transform): method __init__ (line 18) | def __init__(self, method tokenize_func (line 26) | def tokenize_func(self): method fit (line 34) | def fit(self, trn_path: str, **kwargs) -> int: method create_types_shapes_values (line 42) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method file_to_inputs (line 48) | def file_to_inputs(self, filepath: str, gold=True): method inputs_to_samples (line 61) | def inputs_to_samples(self, inputs, gold=False): method x_to_idx (line 73) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: method y_to_idx (line 76) | def y_to_idx(self, y) -> tf.Tensor: method Y_to_outputs (line 79) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... method input_is_single_sample (line 87) | def input_is_single_sample(self, input: Any) -> bool: function bmes_to_flat (line 91) | def bmes_to_flat(inpath, outpath): FILE: hanlp/transform/transformer_tokenizer.py class TransformerTokenizer (line 13) | class TransformerTokenizer(object): method __init__ (line 15) | def __init__(self, max_seq_length=512, truncate_long_sequences=True) -... method sliding_window (line 19) | def sliding_window(self, flat_wordpiece_ids, same_tail=True): class TransformerTextTokenizer (line 41) | class TransformerTextTokenizer(TransformerTokenizer): method __init__ (line 44) | def __init__(self, method __call__ (line 66) | def __call__(self, sample: dict): class TransformerSequenceTokenizer (line 82) | class TransformerSequenceTokenizer(TransformerTokenizer): method __init__ (line 84) | def __init__(self, method __call__ (line 244) | def __call__(self, sample: dict): method _init_prefix_mask (line 543) | def _init_prefix_mask(self, input_ids): function config_is (line 552) | def config_is(config, model='bert'): function convert_examples_to_features (line 556) | def convert_examples_to_features( function main (line 696) | def main(): function _test_text_transform (line 703) | def _test_text_transform(tokenizer): function _test_sequence_transform (line 709) | def _test_sequence_transform(tokenizer): FILE: hanlp/transform/tsv_tf.py function dataset_from_tsv (line 19) | def dataset_from_tsv(tsv_file_path, word_vocab: VocabTF, char_vocab: Voc... function dataset_from_generator (line 26) | def dataset_from_generator(generator, word_vocab, tag_vocab, batch_size=... function vocab_from_tsv (line 42) | def vocab_from_tsv(tsv_file_path, lower=False, lock_word_vocab=False, lo... class TsvTaggingFormat (line 67) | class TsvTaggingFormat(Transform, ABC): method file_to_inputs (line 68) | def file_to_inputs(self, filepath: str, gold=True): method max_seq_length (line 74) | def max_seq_length(self): class TSVTaggingTransform (line 78) | class TSVTaggingTransform(TsvTaggingFormat, Transform): method __init__ (line 79) | def __init__(self, config: SerializableDict = None, map_x=True, map_y=... method fit (line 85) | def fit(self, trn_path: str, **kwargs) -> int: method create_types_shapes_values (line 101) | def create_types_shapes_values(self) -> Tuple[Tuple, Tuple, Tuple]: method inputs_to_samples (line 107) | def inputs_to_samples(self, inputs, gold=False): method x_to_idx (line 119) | def x_to_idx(self, x) -> Union[tf.Tensor, Tuple]: method y_to_idx (line 122) | def y_to_idx(self, y) -> tf.Tensor: method X_to_inputs (line 125) | def X_to_inputs(self, X: Union[tf.Tensor, Tuple[tf.Tensor]]) -> Iterable: method Y_to_outputs (line 132) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=False, method input_is_single_sample (line 142) | def input_is_single_sample(self, input: Union[List[str], List[List[str... method input_truth_output_to_str (line 145) | def input_truth_output_to_str(self, input: List[str], truth: List[str]... FILE: hanlp/transform/txt_tf.py function generate_words_per_line (line 18) | def generate_words_per_line(file_path): function words_to_bmes (line 27) | def words_to_bmes(words): function extract_ngram_features_and_tags (line 39) | def extract_ngram_features_and_tags(sentence, bigram_only=False, window_... function extract_ngram_features (line 64) | def extract_ngram_features(chars, bigram_only, window_size): function generate_ngram_bmes (line 102) | def generate_ngram_bmes(file_path, bigram_only=False, window_size=4, gol... function vocab_from_txt (line 111) | def vocab_from_txt(txt_file_path, bigram_only=False, window_size=4, **kw... function dataset_from_txt (line 121) | def dataset_from_txt(txt_file_path: str, char_vocab: VocabTF, ngram_voca... function dataset_from_generator (line 129) | def dataset_from_generator(generator, char_vocab, ngram_vocab, tag_vocab... class TxtFormat (line 152) | class TxtFormat(Transform, ABC): method file_to_inputs (line 153) | def file_to_inputs(self, filepath: str, gold=True): class TxtBMESFormat (line 163) | class TxtBMESFormat(TxtFormat, ABC): method file_to_inputs (line 164) | def file_to_inputs(self, filepath: str, gold=True): method input_is_single_sample (line 182) | def input_is_single_sample(self, input: Union[List[str], List[List[str... method inputs_to_samples (line 185) | def inputs_to_samples(self, inputs, gold=False): method Y_to_outputs (line 192) | def Y_to_outputs(self, Y: Union[tf.Tensor, Tuple[tf.Tensor]], gold=Fal... method Y_to_tokens (line 196) | def Y_to_tokens(self, tag_vocab, Y, gold, inputs): FILE: hanlp/utils/__init__.py function ls_resource_in_module (line 7) | def ls_resource_in_module(root) -> dict: FILE: hanlp/utils/component_util.py function load_from_meta_file (line 15) | def load_from_meta_file(save_dir: str, meta_filename='meta.json', transf... function load_from_meta (line 189) | def load_from_meta(meta: dict) -> Component: FILE: hanlp/utils/file_read_backwards/buffer_work_space.py class BufferWorkSpace (line 12) | class BufferWorkSpace: method __init__ (line 16) | def __init__(self, fp, chunk_size): method add_to_buffer (line 29) | def add_to_buffer(self, content, read_position): method yieldable (line 45) | def yieldable(self): method return_line (line 60) | def return_line(self): method read_until_yieldable (line 85) | def read_until_yieldable(self): method has_returned_every_line (line 91) | def has_returned_every_line(self): function _get_file_size (line 98) | def _get_file_size(fp): function _get_next_chunk (line 102) | def _get_next_chunk(fp, previously_read_position, chunk_size): function _get_what_to_read_next (line 121) | def _get_what_to_read_next(fp, previously_read_position, chunk_size): function _remove_trailing_new_line (line 156) | def _remove_trailing_new_line(l): function _find_furthest_new_line (line 175) | def _find_furthest_new_line(read_buffer): function _is_partially_read_new_line (line 189) | def _is_partially_read_new_line(b): FILE: hanlp/utils/file_read_backwards/file_read_backwards.py class FileReadBackwards (line 14) | class FileReadBackwards: method __init__ (line 30) | def __init__(self, path, encoding="utf-8", chunk_size=io.DEFAULT_BUFFE... method __iter__ (line 48) | def __iter__(self): method __enter__ (line 52) | def __enter__(self): method __exit__ (line 55) | def __exit__(self, exc_type, exc_val, exc_tb): method close (line 60) | def close(self): method readline (line 64) | def readline(self): class FileReadBackwardsIterator (line 74) | class FileReadBackwardsIterator: method __init__ (line 84) | def __init__(self, fp, encoding, chunk_size): method __iter__ (line 98) | def __iter__(self): method next (line 101) | def next(self): method closed (line 132) | def closed(self): method close (line 144) | def close(self): FILE: hanlp/utils/init_util.py function embedding_uniform (line 11) | def embedding_uniform(tensor:torch.Tensor, seed=233): FILE: hanlp/utils/io_util.py function load_jsonl (line 39) | def load_jsonl(path, verbose=False): function make_debug_corpus (line 50) | def make_debug_corpus(path, delimiter=None, percentage=0.1, max_samples=... function path_join (line 73) | def path_join(path, *paths): function makedirs (line 77) | def makedirs(path): function tempdir (line 82) | def tempdir(name=None): function tempdir_human (line 89) | def tempdir_human(): function temp_lock (line 93) | def temp_lock(path): function hanlp_home_default (line 100) | def hanlp_home_default(): function windows (line 108) | def windows(): function hanlp_home (line 113) | def hanlp_home(): function file_exist (line 131) | def file_exist(filename) -> bool: function remove_file (line 135) | def remove_file(filename): function parent_dir (line 140) | def parent_dir(path): function download (line 144) | def download(url, save_path=None, save_dir=hanlp_home(), prefix=HANLP_UR... function parse_url_path (line 198) | def parse_url_path(url): function uncompress (line 204) | def uncompress(path, dest=None, remove=True, verbose=HANLP_VERBOSE): function split_if_compressed (line 273) | def split_if_compressed(path: str, compressed_ext=('.zip', '.tgz', '.gz'... function get_resource (line 284) | def get_resource(path: str, save_dir=hanlp_home(), extract=True, prefix=... function path_from_url (line 361) | def path_from_url(url, save_dir=hanlp_home(), prefix=HANLP_URL, append_l... function human_bytes (line 390) | def human_bytes(file_size: int) -> str: function read_cells (line 401) | def read_cells(filepath: str, delimiter='auto', strip=True, skip_header=... function replace_ext (line 423) | def replace_ext(filepath, ext) -> str: function read_tsv_as_sents (line 437) | def read_tsv_as_sents(tsv_file_path, ignore_prefix=None, delimiter=None): function generate_words_tags_from_tsv (line 455) | def generate_words_tags_from_tsv(tsv_file_path, lower=False, gold=True, ... function split_file (line 485) | def split_file(filepath, train=0.8, dev=0.1, test=0.1, names=None, shuff... function fileno (line 533) | def fileno(file_or_fd): function stdout_redirected (line 544) | def stdout_redirected(to=os.devnull, stdout=None): function get_exitcode_stdout_stderr (line 584) | def get_exitcode_stdout_stderr(cmd): function run_cmd (line 601) | def run_cmd(cmd: str) -> str: function pushd (line 609) | def pushd(new_dir): function basename_no_ext (line 618) | def basename_no_ext(path): function file_cache (line 624) | def file_cache(path: str, purge=False): function merge_files (line 632) | def merge_files(files: List[str], dst: str): class TimingFileIterator (line 639) | class TimingFileIterator(CountdownTimer): method __init__ (line 641) | def __init__(self, filepath) -> None: method __iter__ (line 645) | def __iter__(self): method log (line 656) | def log(self, info=None, ratio_percentage=True, ratio=True, step=0, in... method ratio (line 662) | def ratio(self) -> str: method ratio_width (line 666) | def ratio_width(self) -> int: method close (line 669) | def close(self): function check_outdated (line 673) | def check_outdated(package='hanlp', version=__version__, repository_url=... function get_latest_info_from_pypi (line 696) | def get_latest_info_from_pypi(package='hanlp', repository_url='https://p... function check_version_conflicts (line 702) | def check_version_conflicts(extras=None): FILE: hanlp/utils/lang/en/english_tokenizer.py function split_possessive_markers (line 102) | def split_possessive_markers(tokens): function split_contractions (line 134) | def split_contractions(tokens): function _matches (line 164) | def _matches(regex): function space_tokenizer (line 177) | def space_tokenizer(sentence): function symbol_tokenizer (line 188) | def symbol_tokenizer(sentence): function tokenize_english (line 223) | def tokenize_english(sentence): FILE: hanlp/utils/lang/ja/bert_tok.py class BertJapaneseTokenizer (line 11) | class BertJapaneseTokenizer(_BertJapaneseTokenizer): class BertJapaneseTokenizerFast (line 16) | class BertJapaneseTokenizerFast(BertTokenizerFast): method encode_plus (line 17) | def encode_plus( FILE: hanlp/utils/lang/zh/char_table.py class CharTable (line 13) | class CharTable: method convert_char (line 17) | def convert_char(c): method normalize_text (line 23) | def normalize_text(text: str) -> str: method normalize_chars (line 27) | def normalize_chars(chars: List[str]) -> List[str]: method _init (line 31) | def _init(): method load (line 35) | def load(): class JsonCharTable (line 47) | class JsonCharTable(CharTable): method load (line 50) | def load(): FILE: hanlp/utils/log_util.py class ColoredFormatter (line 16) | class ColoredFormatter(logging.Formatter): method __init__ (line 17) | def __init__(self, fmt=None, datefmt=None, style='%', enable=True): method formatMessage (line 21) | def formatMessage(self, record: LogRecord) -> str: function init_logger (line 29) | def init_logger(name=None, root_dir=None, level=logging.INFO, mode='w', function enable_debug (line 64) | def enable_debug(debug=True): class ErasablePrinter (line 68) | class ErasablePrinter(object): method __init__ (line 69) | def __init__(self, out=sys.stderr): method erase (line 73) | def erase(self): method print (line 85) | def print(self, msg: str, color=True): function flash (line 103) | def flash(line: str, color=True): function color_format (line 107) | def color_format(msg: str): function remove_color_tag (line 115) | def remove_color_tag(msg: str): function color_format_len (line 123) | def color_format_len(msg: str): function _replace_color_offset (line 135) | def _replace_color_offset(msg: str, color: str, ctrl: str): function cprint (line 141) | def cprint(*args, file=None, **kwargs): function main (line 150) | def main(): function show_colors_and_formats (line 159) | def show_colors_and_formats(): function show_colors (line 168) | def show_colors(): FILE: hanlp/utils/rules.py function _replace_with_separator (line 11) | def _replace_with_separator(text, separator, regexs): function split_sentence (line 19) | def split_sentence(text, best=True): FILE: hanlp/utils/span_util.py function generate_words_per_line (line 8) | def generate_words_per_line(file_path): function words_to_bmes (line 17) | def words_to_bmes(words): function words_to_bi (line 29) | def words_to_bi(words): function bmes_to_words (line 38) | def bmes_to_words(chars, tags): function bmes_to_spans (line 55) | def bmes_to_spans(tags): function bmes_of (line 70) | def bmes_of(sentence, segmented): function iobes_to_bilou (line 87) | def iobes_to_bilou(src, dst): function allowed_transitions (line 102) | def allowed_transitions(constraint_type: str, labels: Dict[int, str]) ->... function is_transition_allowed (line 147) | def is_transition_allowed( class InvalidTagSequence (line 251) | class InvalidTagSequence(Exception): method __init__ (line 252) | def __init__(self, tag_sequence=None): method __str__ (line 256) | def __str__(self): function enumerate_spans (line 263) | def enumerate_spans( function bio_tags_to_spans (line 314) | def bio_tags_to_spans( function iob1_tags_to_spans (line 388) | def iob1_tags_to_spans( function _iob1_start_of_chunk (line 450) | def _iob1_start_of_chunk( function bioul_tags_to_spans (line 465) | def bioul_tags_to_spans( function iobes_tags_to_spans (line 512) | def iobes_tags_to_spans( function iob1_to_bioul (line 559) | def iob1_to_bioul(tag_sequence: List[str]) -> List[str]: function to_bioul (line 567) | def to_bioul(tag_sequence: List[str], encoding: str = "IOB1") -> List[str]: function bmes_tags_to_spans (line 673) | def bmes_tags_to_spans( FILE: hanlp/utils/string_util.py function format_scores (line 8) | def format_scores(results: Dict[str, float]) -> str: function ispunct (line 12) | def ispunct(token): function split_long_sentence_into (line 17) | def split_long_sentence_into(tokens: List[str], max_seq_length, sent_del... function _gen_short_sent (line 53) | def _gen_short_sent(tokens, start, offset, max_seq_length, token_to_char... function _len (line 62) | def _len(start, end, token_to_char_offset, char_level): function guess_delimiter (line 70) | def guess_delimiter(tokens): function split_long_sent (line 78) | def split_long_sent(sent, delimiters, max_seq_length): function possible_tokenization (line 99) | def possible_tokenization(text: str) -> List[Tuple[str]]: FILE: hanlp/utils/tf_util.py function set_gpu (line 15) | def set_gpu(idx=0): function get_visible_gpus (line 37) | def get_visible_gpus(): function set_gpu_memory_growth (line 42) | def set_gpu_memory_growth(growth=True): function nice_gpu (line 55) | def nice_gpu(): function shut_up_python_logging (line 61) | def shut_up_python_logging(): function set_tf_loglevel (line 68) | def set_tf_loglevel(level=logging.ERROR): function size_of_dataset (line 93) | def size_of_dataset(dataset: tf.data.Dataset) -> int: function summary_of_model (line 100) | def summary_of_model(model: tf.keras.Model): function register_custom_cls (line 118) | def register_custom_cls(custom_cls, name=None): function set_seed_tf (line 124) | def set_seed_tf(seed=233): function nice (line 130) | def nice(): function hanlp_register (line 135) | def hanlp_register(arg): function tensor_is_eager (line 156) | def tensor_is_eager(tensor: tf.Tensor): function copy_mask (line 160) | def copy_mask(src: tf.Tensor, dst: tf.Tensor): function get_callback_by_class (line 167) | def get_callback_by_class(callbacks: List[tf.keras.callbacks.Callback], ... function tf_bernoulli (line 173) | def tf_bernoulli(shape, p, dtype=None): function str_tensor_to_str (line 177) | def str_tensor_to_str(str_tensor: tf.Tensor) -> str: function str_tensor_2d_to_list (line 181) | def str_tensor_2d_to_list(str_tensor: tf.Tensor, pad=PAD) -> List[List[s... function str_tensor_to_list (line 194) | def str_tensor_to_list(pred): function format_metrics (line 198) | def format_metrics(metrics: List[tf.keras.metrics.Metric]): class NumpyEncoder (line 202) | class NumpyEncoder(json.JSONEncoder): method default (line 203) | def default(self, obj): FILE: hanlp/utils/time_util.py function human_time_delta (line 13) | def human_time_delta(days, hours, minutes, seconds, delimiter=' ') -> str: function seconds_to_time_delta (line 32) | def seconds_to_time_delta(seconds): function report_time_delta (line 41) | def report_time_delta(seconds, human=True): class HumanTimeDelta (line 48) | class HumanTimeDelta(object): method __init__ (line 50) | def __init__(self, delta_seconds) -> None: method report (line 54) | def report(self, human=True): method __str__ (line 57) | def __str__(self) -> str: method __truediv__ (line 60) | def __truediv__(self, scalar): class CountdownTimer (line 64) | class CountdownTimer(ErasablePrinter): method __init__ (line 66) | def __init__(self, total: int, out=sys.stdout) -> None: method update (line 74) | def update(self, n=1): method ratio (line 81) | def ratio(self) -> str: method ratio_percentage (line 85) | def ratio_percentage(self) -> str: method eta (line 89) | def eta(self) -> float: method elapsed (line 99) | def elapsed(self) -> float: method elapsed_human (line 107) | def elapsed_human(self) -> str: method elapsed_average (line 111) | def elapsed_average(self) -> float: method elapsed_average_human (line 115) | def elapsed_average_human(self) -> str: method eta_human (line 119) | def eta_human(self) -> str: method total_time (line 123) | def total_time(self) -> float: method total_time_human (line 133) | def total_time_human(self) -> str: method stop (line 136) | def stop(self, total=None): method et_eta (line 146) | def et_eta(self): method et_eta_human (line 154) | def et_eta_human(self): method finished (line 162) | def finished(self): method log (line 165) | def log(self, info=None, ratio_percentage=True, ratio=True, step=1, in... method ratio_width (line 186) | def ratio_width(self) -> int: method print (line 189) | def print(self, msg, newline=False, erase=True, logger=None): class Timer (line 212) | class Timer(object): method __init__ (line 213) | def __init__(self) -> None: method start (line 216) | def start(self): method stop (line 219) | def stop(self) -> HumanTimeDelta: function now_human (line 226) | def now_human(year='y'): function now_datetime (line 231) | def now_datetime(): function now_filename (line 235) | def now_filename(fmt="%y%m%d_%H%M%S"): FILE: hanlp/utils/torch_util.py function gpus_available (line 21) | def gpus_available() -> Dict[int, float]: function cuda_devices (line 53) | def cuda_devices(query=None) -> List[int]: function pad_lists (line 85) | def pad_lists(sequences: List[List], dtype=torch.long, padding_value=0): function set_seed (line 89) | def set_seed(seed=233, dont_care_speed=False): function batched_index_select (line 110) | def batched_index_select(input, index, dim=1): function truncated_normal_ (line 130) | def truncated_normal_(tensor, mean=0, std=1): function dtype_of (line 140) | def dtype_of(e: Union[int, bool, float]): function mean_model (line 150) | def mean_model(model: torch.nn.Module): function main (line 154) | def main(): function clip_grad_norm (line 167) | def clip_grad_norm(model: nn.Module, grad_norm, transformer: nn.Module =... function load_word2vec (line 186) | def load_word2vec(path, delimiter=' ', cache=True) -> Tuple[Dict[str, np... function load_word2vec_as_vocab_tensor (line 221) | def load_word2vec_as_vocab_tensor(path, delimiter=' ', cache=True) -> Tu... function save_word2vec (line 248) | def save_word2vec(word2vec: dict, filepath, delimiter=' '): function lengths_to_mask (line 255) | def lengths_to_mask(seq_len, max_len=None): function activation_from_name (line 285) | def activation_from_name(name: str): function filter_state_dict_safely (line 289) | def filter_state_dict_safely(model_state: dict, load_state: dict): FILE: hanlp/version.py class NotCompatible (line 9) | class NotCompatible(Exception): FILE: plugins/hanlp_common/hanlp_common/amr.py function is_abstract_token (line 55) | def is_abstract_token(token): function is_english_punct (line 59) | def is_english_punct(c): function find_similar_token (line 63) | def find_similar_token(token, tokens): class AMR (line 83) | class AMR: method __init__ (line 85) | def __init__(self, method is_named_entity (line 105) | def is_named_entity(self, index): method get_named_entity_span (line 108) | def get_named_entity_span(self, index): method find_span_indexes (line 123) | def find_span_indexes(self, span): method replace_span (line 131) | def replace_span(self, indexes, new, pos=None, ner=None): method remove_span (line 141) | def remove_span(self, indexes): method __repr__ (line 144) | def __repr__(self): method get_src_tokens (line 169) | def get_src_tokens(self): class AMRNode (line 173) | class AMRNode: method __init__ (line 179) | def __init__(self, identifier, attributes=None, copy_of=None): method _sort_attributes (line 189) | def _sort_attributes(self): method __hash__ (line 200) | def __hash__(self): method __eq__ (line 203) | def __eq__(self, other): method __repr__ (line 208) | def __repr__(self): method __str__ (line 216) | def __str__(self): method instance (line 225) | def instance(self): method ops (line 233) | def ops(self): method copy (line 242) | def copy(self): method remove_attribute (line 250) | def remove_attribute(self, attr, value): method add_attribute (line 253) | def add_attribute(self, attr, value): method replace_attribute (line 256) | def replace_attribute(self, attr, old, new): method get_frame_attributes (line 260) | def get_frame_attributes(self): method get_senseless_attributes (line 265) | def get_senseless_attributes(self): class AMRGraph (line 271) | class AMRGraph(penman.Graph): method __init__ (line 283) | def __init__(self, penman_graph): method __str__ (line 290) | def __str__(self): method _build_extras (line 294) | def _build_extras(self): method attributes (line 331) | def attributes(self, source=None, relation=None, target=None): method _update_penman_graph (line 343) | def _update_penman_graph(self, triples): method is_name_node (line 348) | def is_name_node(self, node): method get_name_node_type (line 352) | def get_name_node_type(self, node): method get_name_node_wiki (line 359) | def get_name_node_wiki(self, node): method set_name_node_wiki (line 370) | def set_name_node_wiki(self, node, wiki): method is_date_node (line 382) | def is_date_node(self, node): method add_edge (line 385) | def add_edge(self, source, target, label): method remove_edge (line 392) | def remove_edge(self, x, y): method update_edge_label (line 402) | def update_edge_label(self, x, y, old, new): method add_node (line 411) | def add_node(self, instance): method remove_node (line 426) | def remove_node(self, node): method replace_node_attribute (line 431) | def replace_node_attribute(self, node, attr, old, new): method remove_node_attribute (line 444) | def remove_node_attribute(self, node, attr, value): method add_node_attribute (line 450) | def add_node_attribute(self, node, attr, value): method remove_node_ops (line 455) | def remove_node_ops(self, node): method remove_subtree (line 463) | def remove_subtree(self, root): method get_subtree (line 477) | def get_subtree(self, root, max_depth): method get_nodes (line 488) | def get_nodes(self): method get_edges (line 491) | def get_edges(self): method set_src_tokens (line 494) | def set_src_tokens(self, sentence): method get_src_tokens (line 499) | def get_src_tokens(self): method get_list_node (line 502) | def get_list_node(self, replace_copy=True): method sort_edges (line 526) | def sort_edges(self, edges): method get_tgt_tokens (line 529) | def get_tgt_tokens(self): method get_list_data (line 549) | def get_list_data(self, amr, bos=None, eos=None, bert_tokenizer=None, ... method decode (line 688) | def decode(cls, raw_graph_string): method from_lists (line 693) | def from_lists(cls, all_list): method from_prediction (line 724) | def from_prediction(cls, prediction): class SourceCopyVocabulary (line 823) | class SourceCopyVocabulary: method __init__ (line 824) | def __init__(self, sentence, pad_token=DEFAULT_PADDING_TOKEN, unk_toke... method get_token_from_idx (line 843) | def get_token_from_idx(self, idx): method get_token_idx (line 846) | def get_token_idx(self, token): method index_sequence (line 849) | def index_sequence(self, list_tokens): method get_copy_map (line 852) | def get_copy_map(self, list_tokens): method get_special_tok_list (line 858) | def get_special_tok_list(self): method __repr__ (line 861) | def __repr__(self): function is_similar (line 865) | def is_similar(instances1, instances2): class GraphRepair (line 877) | class GraphRepair: method __init__ (line 879) | def __init__(self, graph, nodes): method do (line 885) | def do(graph, nodes): method remove_unknown_nodes (line 890) | def remove_unknown_nodes(self): method remove_redundant_edges (line 904) | def remove_redundant_edges(self): FILE: plugins/hanlp_common/hanlp_common/configurable.py class Configurable (line 7) | class Configurable(object): method from_config (line 9) | def from_config(config: dict, **kwargs): class AutoConfigurable (line 35) | class AutoConfigurable(Configurable): method config (line 37) | def config(self) -> dict: method __repr__ (line 47) | def __repr__(self) -> str: FILE: plugins/hanlp_common/hanlp_common/conll.py class CoNLLWord (line 10) | class CoNLLWord(SerializableDict): method __init__ (line 11) | def __init__(self, id, form, lemma=None, cpos=None, pos=None, feats=No... method __str__ (line 51) | def __str__(self): method nonempty_fields (line 63) | def nonempty_fields(self): method get_pos (line 71) | def get_pos(self): class CoNLLUWord (line 81) | class CoNLLUWord(SerializableDict): method __init__ (line 82) | def __init__(self, id: Union[int, str], form, lemma=None, upos=None, x... method __str__ (line 139) | def __str__(self): method nonempty_fields (line 150) | def nonempty_fields(self): method get_pos (line 158) | def get_pos(self): class CoNLLSentence (line 168) | class CoNLLSentence(list): method __init__ (line 169) | def __init__(self, words=None): method __str__ (line 181) | def __str__(self): method from_str (line 185) | def from_str(conll: str, conllu=False): method from_file (line 226) | def from_file(path: str, conllu=False): method from_dict (line 240) | def from_dict(d: dict, conllu=False): method to_markdown (line 259) | def to_markdown(self, headings: Union[str, List[str]] = 'auto') -> str: method to_tree (line 284) | def to_tree(self, extras: List[str] = None) -> str: method projective (line 321) | def projective(self): class CoNLLSentenceList (line 328) | class CoNLLSentenceList(list): method __str__ (line 330) | def __str__(self) -> str: function sanitize_conll_int_value (line 334) | def sanitize_conll_int_value(value: Union[str, int]): function isprojective (line 344) | def isprojective(sequence): FILE: plugins/hanlp_common/hanlp_common/document.py class Document (line 17) | class Document(dict): method __init__ (line 18) | def __init__(self, *args, **kwargs) -> None: method to_json (line 88) | def to_json(self, ensure_ascii=False, indent=2) -> str: method to_dict (line 104) | def to_dict(self): method __str__ (line 129) | def __str__(self) -> str: method to_conll (line 132) | def to_conll(self, tok='tok', lem='lem', pos='pos', fea='fea', dep='de... method to_pretty (line 186) | def to_pretty(self, tok='tok', lem='lem', pos='pos', dep='dep', sdp='s... method pretty_print (line 406) | def pretty_print(self, tok='tok', lem='lem', pos='pos', dep='dep', sdp... method translate (line 434) | def translate(self, lang, tok='tok', pos='pos', dep='dep', sdp='sdp', ... method squeeze (line 476) | def squeeze(self, i=0): method _to_doc_without_spans (line 494) | def _to_doc_without_spans(self, tok: str): method get_by_prefix (line 519) | def get_by_prefix(self, prefix: str): method count_sentences (line 534) | def count_sentences(self) -> int: FILE: plugins/hanlp_common/hanlp_common/io.py function save_pickle (line 11) | def save_pickle(item, path): function load_pickle (line 16) | def load_pickle(path): function save_json (line 21) | def save_json(item: Union[dict, list, str, int, float], path: str, ensur... function load_json (line 30) | def load_json(path): function filename_is_json (line 35) | def filename_is_json(filename): function eprint (line 40) | def eprint(*args, **kwargs): FILE: plugins/hanlp_common/hanlp_common/reflection.py function classpath_of (line 8) | def classpath_of(obj) -> str: function module_path_of (line 22) | def module_path_of(func) -> str: function object_from_classpath (line 26) | def object_from_classpath(classpath, **kwargs): function str_to_type (line 33) | def str_to_type(classpath): function type_to_str (line 48) | def type_to_str(type_object) -> str: FILE: plugins/hanlp_common/hanlp_common/structure.py class Serializable (line 10) | class Serializable(object): method save (line 13) | def save(self, path, fmt=None): method load (line 24) | def load(self, path, fmt=None): method save_pickle (line 35) | def save_pickle(self, path): method load_pickle (line 47) | def load_pickle(self, path): method save_json (line 60) | def save_json(self, path): method load_json (line 63) | def load_json(self, path): method copy_from (line 68) | def copy_from(self, item): method to_json (line 72) | def to_json(self, ensure_ascii=False, indent=2, sort=False) -> str: method to_dict (line 78) | def to_dict(self) -> dict: class SerializableDict (line 82) | class SerializableDict(Serializable, dict): method save_json (line 84) | def save_json(self, path): method copy_from (line 87) | def copy_from(self, item): method __getattr__ (line 92) | def __getattr__(self, key): method __setattr__ (line 97) | def __setattr__(self, key, value): method to_dict (line 100) | def to_dict(self) -> dict: FILE: plugins/hanlp_common/hanlp_common/util.py function powerset (line 10) | def powerset(iterable, descending=False): function isdebugging (line 25) | def isdebugging(): function list_is_list_of_lists (line 33) | def list_is_list_of_lists(sent: Union[Any, List[Any]]) -> Optional[bool]: function set_tuple_with (line 39) | def set_tuple_with(t: Tuple, v, at=0) -> Tuple: function consume_keys_from_dict (line 45) | def consume_keys_from_dict(keys: Iterable, d: dict) -> dict: function merge_dict (line 53) | def merge_dict(d: dict, overwrite=False, inplace=False, **kwargs): function merge_locals_kwargs (line 75) | def merge_locals_kwargs(locals: dict, kwargs: dict = None, excludes=('se... function infer_space_after (line 82) | def infer_space_after(sent: List[str]): function collapse_json (line 110) | def collapse_json(text, indent=12): class DummyContext (line 170) | class DummyContext(object): method __enter__ (line 171) | def __enter__(self): method __exit__ (line 174) | def __exit__(self, exc_type, exc_val, exc_tb): function merge_list_of_dict (line 178) | def merge_list_of_dict(samples: List[Dict]) -> dict: function split_dict (line 190) | def split_dict(batch: Dict[str, Any]) -> List[Dict[str, Any]]: function reorder (line 199) | def reorder(samples: List, order: List[int]) -> List: function k_fold (line 203) | def k_fold(k, total, i): function dfs (line 209) | def dfs(graph, start): function topological_sort (line 223) | def topological_sort(graph, start): function prefix_match (line 241) | def prefix_match(target, sources: Iterable[str]): FILE: plugins/hanlp_common/hanlp_common/visualization.py function make_table (line 10) | def make_table(rows, insert_header=False): function _start_end (line 19) | def _start_end(arrow): function pretty_tree_horizontal (line 26) | def pretty_tree_horizontal(arrows, _do_print_debug_info=False): function render_arrows (line 127) | def render_arrows(lines): function render_span (line 145) | def render_span(begin, end, unidirectional=False): function tree_to_list (line 170) | def tree_to_list(T): function list_to_tree (line 174) | def list_to_tree(L): function render_labeled_span (line 180) | def render_labeled_span(b, e, spans, labels, label, offset, unidirection... function main (line 189) | def main(): function evalute_field (line 210) | def evalute_field(record, field_spec): function markdown_table (line 228) | def markdown_table(headings, records, fields=None, alignment=None, file=... FILE: plugins/hanlp_demo/hanlp_demo/mul/train/mul_base.py function main (line 17) | def main(): FILE: plugins/hanlp_demo/hanlp_demo/zh/demo_parse_constituency.py function merge_pos_into_con (line 14) | def merge_pos_into_con(doc: Document): FILE: plugins/hanlp_demo/hanlp_demo/zh/tf/demo_cws.py function split_by_dic (line 18) | def split_by_dic(text: str): FILE: plugins/hanlp_demo/hanlp_demo/zh/tf/demo_cws_trie.py function split_sents (line 16) | def split_sents(text: str, trie: Trie): function merge_parts (line 35) | def merge_parts(parts, offsets, words): FILE: plugins/hanlp_demo/hanlp_demo/zh/tf/demo_multiprocess.py function worker (line 10) | def worker(job): FILE: plugins/hanlp_restful/hanlp_restful/__init__.py function _post (line 16) | def _post(url, form: Dict[str, Any], headers: Dict[str, Any], timeout=60... function _post (line 25) | def _post(url, form: Dict[str, Any], headers: Dict[str, Any], timeout=60... class HanLPClient (line 37) | class HanLPClient(object): method __init__ (line 39) | def __init__(self, url: str, auth: str = None, language=None, timeout=... method parse (line 63) | def parse(self, method __call__ (line 122) | def __call__(self, method about (line 134) | def about(self) -> Dict[str, Any]: method _send_post (line 144) | def _send_post(self, url, form: Dict[str, Any]): method _fire_request (line 149) | def _fire_request(self, request): method _send_post_json (line 152) | def _send_post_json(self, url, form: Dict[str, Any]): method _send_get (line 158) | def _send_get(self, url, form: Dict[str, Any]): method _add_headers (line 163) | def _add_headers(self, request): method _send_get_json (line 167) | def _send_get_json(self, url, form: Dict[str, Any]): method text_style_transfer (line 170) | def text_style_transfer(self, text: Union[str, List[str]], target_styl... method semantic_textual_similarity (line 203) | def semantic_textual_similarity(self, text: Union[Tuple[str, str], Lis... method coreference_resolution (line 232) | def coreference_resolution(self, text: Optional[str] = None, tokens: O... method tokenize (line 275) | def tokenize(self, text: Union[str, List[str]], coarse: Optional[bool]... method abstract_meaning_representation (line 330) | def abstract_meaning_representation(self, method keyphrase_extraction (line 369) | def keyphrase_extraction( method extractive_summarization (line 402) | def extractive_summarization( method abstractive_summarization (line 443) | def abstractive_summarization( method grammatical_error_correction (line 475) | def grammatical_error_correction(self, text: Union[str, List[str]], la... method text_classification (line 504) | def text_classification(self, text: Union[str, List[str]], model, topk... method sentiment_analysis (line 524) | def sentiment_analysis(self, text: Union[str, List[str]], language=Non... method language_identification (line 553) | def language_identification(self, text: Union[str, List[str]], topk=Fa... FILE: plugins/hanlp_restful/tests/test_client.py class TestClient (line 6) | class TestClient(unittest.TestCase): method setUp (line 8) | def setUp(self) -> None: method test_raw_text (line 11) | def test_raw_text(self): method test_sents (line 15) | def test_sents(self): method test_tokens (line 20) | def test_tokens(self): method test_sents_mul (line 27) | def test_sents_mul(self): method test_tokenize (line 33) | def test_tokenize(self): method test_coreference_resolution (line 42) | def test_coreference_resolution(self): method test_text_style_transfer (line 45) | def test_text_style_transfer(self): method test_abstract_meaning_representation (line 50) | def test_abstract_meaning_representation(self): method test_keyphrase_extraction (line 57) | def test_keyphrase_extraction(self): method test_extractive_summarization (line 62) | def test_extractive_summarization(self): FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/BaseInput.java class BaseInput (line 16) | public class BaseInput method BaseInput (line 22) | public BaseInput(String[] tasks, String[] skipTasks, String language) FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/CoreferenceResolutionOutput.java class CoreferenceResolutionOutput (line 22) | public class CoreferenceResolutionOutput method CoreferenceResolutionOutput (line 27) | public CoreferenceResolutionOutput(List> clusters, ArrayList... FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/DocumentInput.java class DocumentInput (line 16) | public class DocumentInput extends BaseInput method DocumentInput (line 20) | public DocumentInput(String text, String[] tasks, String[] skipTasks, ... FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/HanLPClient.java class HanLPClient (line 32) | public class HanLPClient method HanLPClient (line 48) | public HanLPClient(String url, String auth, String language, int timeout) method HanLPClient (line 65) | public HanLPClient(String url, String auth) method parse (line 80) | public Map parse(String text, String[] tasks, String[] s... method parse (line 94) | public Map parse(String text) throws IOException method parse (line 109) | public Map parse(String[] sentences, String[] tasks, Str... method parse (line 123) | public Map parse(String[] sentences) throws IOException method parse (line 138) | public Map parse(String[][] tokens, String[] tasks, Stri... method parse (line 152) | public Map parse(String[][] tokens) throws IOException method tokenize (line 165) | public List> tokenize(String text, Boolean coarse) throws... method tokenize (line 189) | public List> tokenize(String text) throws IOException method textStyleTransfer (line 201) | public List textStyleTransfer(List text, String target... method textStyleTransfer (line 218) | public String textStyleTransfer(String text, String targetStyle) throw... method grammaticalErrorCorrection (line 235) | public List grammaticalErrorCorrection(List text) thro... method grammaticalErrorCorrection (line 252) | public String[] grammaticalErrorCorrection(String[] text) throws IOExc... method grammaticalErrorCorrection (line 269) | public String grammaticalErrorCorrection(String text) throws IOException method semanticTextualSimilarity (line 285) | public Double semanticTextualSimilarity(String textA, String textB) th... method semanticTextualSimilarity (line 300) | public List semanticTextualSimilarity(String[][] text) throws ... method coreferenceResolution (line 316) | public CoreferenceResolutionOutput coreferenceResolution(String text) ... method coreferenceResolution (line 336) | public List> coreferenceResolution(String[][] tokens, String... method coreferenceResolution (line 354) | public List> coreferenceResolution(String[][] tokens) throws... method _convert_clusters (line 364) | private static List> _convert_clusters(List> clus... method abstractMeaningRepresentation (line 387) | public MeaningRepresentation[] abstractMeaningRepresentation(String te... method abstractMeaningRepresentation (line 403) | public MeaningRepresentation[] abstractMeaningRepresentation(String[][... method keyphraseExtraction (line 419) | public Map keyphraseExtraction(String text, int topk) ... method extractiveSummarization (line 437) | public Map extractiveSummarization(String text) throws... method extractiveSummarization (line 452) | public Map extractiveSummarization(String text, int to... method abstractiveSummarization (line 471) | public String abstractiveSummarization(String text) throws IOException method textClassification (line 489) | public String textClassification(String text, String model) throws IOE... method sentimentAnalysis (line 503) | public Double sentimentAnalysis(String text) throws IOException method textClassification (line 524) | public Object textClassification(Object text, String model, Object top... method languageIdentification (line 542) | public String languageIdentification(String text) throws IOException method languageIdentification (line 554) | public List languageIdentification(String[] text) throws IOExc... method keyphraseExtraction (line 566) | public Map keyphraseExtraction(String text) throws IOE... method post (line 571) | private String post(String api, Object input_) throws IOException FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/SentenceInput.java class SentenceInput (line 16) | public class SentenceInput extends BaseInput method SentenceInput (line 20) | public SentenceInput(String[] text, String[] tasks, String[] skipTasks... FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/Span.java class Span (line 20) | public class Span method Span (line 35) | public Span(String form, int begin, int end) method equals (line 42) | @Override method hashCode (line 53) | @Override method toString (line 59) | @Override FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/TokenInput.java class TokenInput (line 16) | public class TokenInput extends BaseInput method TokenInput (line 20) | public TokenInput(String[][] tokens, String[] tasks, String[] skipTask... FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/mrp/Anchor.java class Anchor (line 16) | public class Anchor FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/mrp/Edge.java class Edge (line 16) | public class Edge FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/mrp/MeaningRepresentation.java class MeaningRepresentation (line 18) | public class MeaningRepresentation FILE: plugins/hanlp_restful_java/src/main/java/com/hankcs/hanlp/restful/mrp/Node.java class Node (line 16) | public class Node FILE: plugins/hanlp_restful_java/src/test/java/com/hankcs/hanlp/restful/HanLPClientTest.java class HanLPClientTest (line 13) | class HanLPClientTest method setUp (line 17) | @BeforeEach method parseText (line 23) | @org.junit.jupiter.api.Test method parseSentences (line 30) | @org.junit.jupiter.api.Test method parseTokens (line 40) | @org.junit.jupiter.api.Test method parseCoarse (line 50) | @Test method tokenize (line 60) | @Test method textStyleTransfer (line 69) | @Test method semanticTextualSimilarity (line 76) | @Test method coreferenceResolutionText (line 91) | @Test method coreferenceResolutionTokens (line 98) | @Test method coreferenceResolutionTokensWithSpeakers (line 108) | @Test method keyphraseExtraction (line 119) | @Test method extractiveSummarization (line 127) | @Test method abstractiveSummarization (line 140) | @Test method abstractMeaningRepresentationText (line 149) | @Test method abstractMeaningRepresentationTokens (line 155) | @Test method grammaticalErrorCorrection (line 163) | @Test method languageIdentification (line 169) | @Test method sentimentAnalysis (line 179) | @Test method prettyPrint (line 187) | void prettyPrint(Object object) throws JsonProcessingException FILE: plugins/hanlp_restful_java/src/test/java/com/hankcs/hanlp/restful/MeaningRepresentationTest.java class MeaningRepresentationTest (line 14) | class MeaningRepresentationTest method parseText (line 18) | @Test method prettyPrint (line 28) | void prettyPrint(Object object) throws JsonProcessingException FILE: plugins/hanlp_trie/hanlp_trie/dictionary.py class DictInterface (line 12) | class DictInterface(ABC): method tokenize (line 14) | def tokenize(self, text: Union[str, Sequence[str]]) -> List[Tuple[int,... method split (line 28) | def split(self, text: Union[str, Sequence[str]]) -> List[Tuple[int, in... class TrieDict (line 53) | class TrieDict(Trie, DictInterface, Configurable): method __init__ (line 54) | def __init__(self, dictionary: Optional[Union[Dict[Iterable[str], Any]... method tokenize (line 65) | def tokenize(self, text: Union[str, Sequence[str]]) -> List[Tuple[int,... method split_batch (line 68) | def split_batch(self, data: List[str]) -> Tuple[List[str], List[int], ... method merge_batch (line 106) | def merge_batch(data, new_outputs, new_data_belongs, parts): method config (line 152) | def config(self): class TupleTrieDict (line 159) | class TupleTrieDict(TrieDict): method __init__ (line 160) | def __init__(self, dictionary: Optional[Union[Dict[Iterable[str], Any]... method config (line 178) | def config(self): method parse_longest (line 184) | def parse_longest(self, text: Sequence[str]) -> List[Tuple[int, int, A... FILE: plugins/hanlp_trie/hanlp_trie/trie.py class Node (line 7) | class Node(object): method __init__ (line 8) | def __init__(self, value=None) -> None: method _get_or_add_child (line 17) | def _get_or_add_child(self, char): method transit (line 24) | def transit(self, key): method _walk (line 41) | def _walk(self, prefix: Union[str, tuple], ordered=False): class Trie (line 49) | class Trie(Node): method __init__ (line 50) | def __init__(self, tokens: Optional[Union[Dict[str, Any], Iterable[str... method __contains__ (line 69) | def __contains__(self, key): method __getitem__ (line 72) | def __getitem__(self, key): method __setitem__ (line 78) | def __setitem__(self, key, value): method __delitem__ (line 88) | def __delitem__(self, key): method update (line 94) | def update(self, dic: Dict[str, Any]): method parse (line 99) | def parse(self, text: Sequence[str]) -> List[Tuple[int, int, Any]]: method parse_longest (line 123) | def parse_longest(self, text: Sequence[str]) -> List[Tuple[int, int, A... method items (line 157) | def items(self, ordered=False, prefix=''): method __len__ (line 160) | def __len__(self): method __bool__ (line 163) | def __bool__(self): FILE: plugins/hanlp_trie/tests/test_trie.py class TestTrie (line 6) | class TestTrie(unittest.TestCase): method build_small_trie (line 7) | def build_small_trie(self): method assert_results_valid (line 10) | def assert_results_valid(self, text, results, trie): method test_parse (line 14) | def test_parse(self): method test_parse_longest (line 26) | def test_parse_longest(self): method test_items (line 34) | def test_items(self): method test_len (line 39) | def test_len(self): FILE: plugins/hanlp_trie/tests/test_trie_dict.py class TestTrieDict (line 6) | class TestTrieDict(unittest.TestCase): method setUp (line 8) | def setUp(self) -> None: method test_tokenize (line 13) | def test_tokenize(self): method test_split_batch (line 16) | def test_split_batch(self): method test_tokenize_2 (line 24) | def test_tokenize_2(self): method test_empty_dict (line 29) | def test_empty_dict(self): FILE: tests/__init__.py function cdroot (line 9) | def cdroot(): FILE: tests/test_config_tracker.py class MyClass (line 6) | class MyClass(ConfigTracker): method __init__ (line 7) | def __init__(self, i_need_this='yes') -> None: class TestConfigTracker (line 11) | class TestConfigTracker(unittest.TestCase): method test_init (line 12) | def test_init(self): FILE: tests/test_mtl.py function tokenize (line 9) | def tokenize(mtl, text): class TestMultiTaskLearning (line 13) | class TestMultiTaskLearning(unittest.TestCase): method test_mtl_single_sent (line 14) | def test_mtl_single_sent(self): method test_mtl_multiple_sents (line 18) | def test_mtl_multiple_sents(self): method test_mtl_empty_str (line 25) | def test_mtl_empty_str(self): method test_skip_tok (line 34) | def test_skip_tok(self): method test_sdp_as_the_first_task (line 42) | def test_sdp_as_the_first_task(self): method test_threading (line 60) | def test_threading(self): method test_emoji (line 66) | def test_emoji(self): method test_unicode_removed_by_hf (line 73) | def test_unicode_removed_by_hf(self): method test_space (line 76) | def test_space(self): method test_transform (line 84) | def test_transform(self): method test_tok_offset (line 90) | def test_tok_offset(self): FILE: tests/test_pipeline.py class TestPipeLine (line 5) | class TestPipeLine(unittest.TestCase): method test_copy (line 6) | def test_copy(self): FILE: tests/test_rules.py class TestRules (line 9) | class TestRules(unittest.TestCase): method test_eos (line 10) | def test_eos(self): FILE: tests/test_string_util.py class TestStringUtility (line 9) | class TestStringUtility(unittest.TestCase): method test_enumerate_tokenization (line 10) | def test_enumerate_tokenization(self):