repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/ctb7.py
hanlp/datasets/parsing/ctb7.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-28 18:44 from hanlp.datasets.parsing.ctb5 import _CTB_HOME _CTB7_HOME = _CTB_HOME + 'BPNN/data/ctb7/' CTB7_DEP_TRAIN = _CTB7_HOME + 'train.conll' '''Training set for ctb7 dependency parsing.''' CTB7_DEP_DEV = _CTB7_HOME + 'dev.conll' '''Dev set for ctb7 dependen...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/semeval16.py
hanlp/datasets/parsing/semeval16.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-28 00:51 from hanlp_common.conll import CoNLLSentence import os from hanlp.utils.io_util import get_resource, merge_files from hanlp_common.io import eprint _SEMEVAL2016_HOME = 'https://github.com/HIT-SCIR/SemEval-2016/archive/master.zip' SEMEVAL2016_NEWS_TRAIN...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/loaders/_ctb_utils.py
hanlp/datasets/parsing/loaders/_ctb_utils.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-11-25 16:14 import os import shutil import sys from collections import defaultdict from os import listdir from os.path import join, isfile from typing import List from phrasetree.tree import Tree from hanlp.components.parsers.conll import read_conll from hanlp.util...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/loaders/constituency_dataset.py
hanlp/datasets/parsing/loaders/constituency_dataset.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-11-28 19:27 from typing import List from phrasetree.tree import Tree from hanlp_common.constant import EOS, BOS from hanlp.common.dataset import TransformableDataset class ConstituencyDataset(TransformableDataset): def load_file(self, filepath: str): ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/loaders/conll_dataset.py
hanlp/datasets/parsing/loaders/conll_dataset.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-05-08 16:10 from typing import Union, List, Callable, Dict from hanlp_common.constant import ROOT, EOS, BOS from hanlp.common.dataset import TransformableDataset from hanlp.components.parsers.conll import read_conll from hanlp.utils.io_util import TimingFileIterator...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/loaders/__init__.py
hanlp/datasets/parsing/loaders/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-12-28 19:04
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/ud/ud27m.py
hanlp/datasets/parsing/ud/ud27m.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-05-21 20:39 import os from hanlp.datasets.parsing.ud import concat_treebanks from hanlp.datasets.parsing.ud.ud27 import _UD_27_HOME _UD_27_MULTILINGUAL_HOME = concat_treebanks(_UD_27_HOME, '2.7') UD_27_MULTILINGUAL_TRAIN = os.path.join(_UD_27_MULTILINGUAL_HOME, 'tr...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/ud/ud23.py
hanlp/datasets/parsing/ud/ud23.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-05-21 20:26 _UD_23_HOME = "https://lindat.mff.cuni.cz/repository/xmlui/bitstream/handle/11234/1-2895/ud-treebanks-v2.3.tgz?sequence=1&isAllowed=y" _UD_24_HOME = "https://lindat.mff.cuni.cz/repository/xmlui/bitstream/handle/11234/1-2988/ud-treebanks-v2.4.tgz?sequence...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/ud/ud210m.py
hanlp/datasets/parsing/ud/ud210m.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-05-21 20:39 import os from hanlp.datasets.parsing.ud import concat_treebanks from hanlp.datasets.parsing.ud.ud210 import _UD_210_HOME _UD_210_MULTILINGUAL_HOME = concat_treebanks(_UD_210_HOME, '2.10') UD_210_MULTILINGUAL_TRAIN = os.path.join(_UD_210_MULTILINGUAL_HO...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/ud/ud23m.py
hanlp/datasets/parsing/ud/ud23m.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-05-21 20:39 import os from hanlp.datasets.parsing.ud import concat_treebanks from .ud23 import _UD_23_HOME _UD_23_MULTILINGUAL_HOME = concat_treebanks(_UD_23_HOME, '2.3') UD_23_MULTILINGUAL_TRAIN = os.path.join(_UD_23_MULTILINGUAL_HOME, 'train.conllu') UD_23_MULTIL...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/ud/__init__.py
hanlp/datasets/parsing/ud/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-07 21:45 import os import shutil from hanlp.components.parsers.ud.udify_util import get_ud_treebank_files from hanlp.utils.io_util import get_resource from hanlp.utils.log_util import flash def concat_treebanks(home, version): ud_home = get_resource(home) ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/ud/ud210.py
hanlp/datasets/parsing/ud/ud210.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-07 21:03 import glob import os from hanlp.utils.io_util import uncompress, get_resource _UD_210_URL = "https://lindat.mff.cuni.cz/repository/xmlui/handle/11234/1-4758/allzip" _UD_210_HOME = _UD_210_URL + '#ud-treebanks-v2.10/' _path = get_resource(_UD_210_URL) i...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
true
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/ud/ud27.py
hanlp/datasets/parsing/ud/ud27.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-07 21:03 import glob import os from hanlp.utils.io_util import uncompress, get_resource _UD_27_URL = "https://lindat.mff.cuni.cz/repository/xmlui/handle/11234/1-3424/allzip" _UD_27_HOME = _UD_27_URL + '#ud-treebanks-v2.7/' _path = get_resource(_UD_27_URL) if os....
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
true
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/eos/eos.py
hanlp/datasets/eos/eos.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-07-26 18:12 import itertools from collections import Counter from typing import Union, List, Callable from hanlp.common.dataset import TransformableDataset from hanlp.utils.io_util import TimingFileIterator from hanlp.utils.log_util import cprint from hanlp.utils.st...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/eos/__init__.py
hanlp/datasets/eos/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-07-26 18:11
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/eos/loaders/nn_eos.py
hanlp/datasets/eos/loaders/nn_eos.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-24 22:51 _SETIMES2_EN_HR_SENTENCES_HOME = 'https://schweter.eu/cloud/nn_eos/SETIMES2.en-hr.sentences.tar.xz' SETIMES2_EN_HR_HR_SENTENCES_TRAIN = _SETIMES2_EN_HR_SENTENCES_HOME + '#SETIMES2.en-hr.hr.sentences.train' '''Training set of SETimes corpus.''' SETIMES2_EN...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/eos/loaders/__init__.py
hanlp/datasets/eos/loaders/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-12-28 19:03
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/classification/sentiment.py
hanlp/datasets/classification/sentiment.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-30 21:03 _ERNIE_TASK_DATA = 'https://ernie.bj.bcebos.com/task_data_zh.tgz#' CHNSENTICORP_ERNIE_TRAIN = _ERNIE_TASK_DATA + 'chnsenticorp/train.tsv' CHNSENTICORP_ERNIE_DEV = _ERNIE_TASK_DATA + 'chnsenticorp/dev.tsv' CHNSENTICORP_ERNIE_TEST = _ERNIE_TASK_DATA + 'chn...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/classification/__init__.py
hanlp/datasets/classification/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-11-10 11:49
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/lu/glue.py
hanlp/datasets/lu/glue.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-11-10 11:47 from hanlp.common.dataset import TableDataset STANFORD_SENTIMENT_TREEBANK_2_TRAIN = 'http://file.hankcs.com/corpus/SST2.zip#train.tsv' STANFORD_SENTIMENT_TREEBANK_2_DEV = 'http://file.hankcs.com/corpus/SST2.zip#dev.tsv' STANFORD_SENTIMENT_TREEBANK_2_TEST...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/lu/__init__.py
hanlp/datasets/lu/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-12-28 19:08
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/sts/__init__.py
hanlp/datasets/sts/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-05-20 16:25
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/sts/stsb.py
hanlp/datasets/sts/stsb.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-05-20 16:25 from typing import Union, List, Callable from hanlp.common.dataset import TransformableDataset from hanlp.utils.io_util import read_cells STS_B_TRAIN = 'http://ixa2.si.ehu.es/stswiki/images/4/48/Stsbenchmark.tar.gz#sts-train.csv' STS_B_DEV = 'http://ixa...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/ner/msra.py
hanlp/datasets/ner/msra.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-28 23:13 _MSRA_NER_HOME = 'http://file.hankcs.com/corpus/msra_ner.zip' _MSRA_NER_TOKEN_LEVEL_HOME = 'http://file.hankcs.com/corpus/msra_ner_token_level.zip' MSRA_NER_CHAR_LEVEL_TRAIN = f'{_MSRA_NER_HOME}#train.tsv' '''Training set of MSRA (:cite:`levow-2006-thir...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/ner/weibo.py
hanlp/datasets/ner/weibo.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-03 23:33 from hanlp.common.dataset import TransformableDataset from hanlp.utils.io_util import get_resource, generate_words_tags_from_tsv _WEIBO_NER_HOME = 'https://github.com/hltcoe/golden-horse/archive/master.zip#data/' WEIBO_NER_TRAIN = _WEIBO_NER_HOME + 'we...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/ner/resume.py
hanlp/datasets/ner/resume.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-08 12:10 from hanlp.common.dataset import TransformableDataset from hanlp.utils.io_util import get_resource, generate_words_tags_from_tsv _RESUME_NER_HOME = 'https://github.com/jiesutd/LatticeLSTM/archive/master.zip#' RESUME_NER_TRAIN = _RESUME_NER_HOME + 'Resu...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/ner/conll03.py
hanlp/datasets/ner/conll03.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-06 15:31 CONLL03_EN_TRAIN = 'https://file.hankcs.com/corpus/conll03_en_iobes.zip#eng.train.tsv' '''Training set of CoNLL03 (:cite:`tjong-kim-sang-de-meulder-2003-introduction`)''' CONLL03_EN_DEV = 'https://file.hankcs.com/corpus/conll03_en_iobes.zip#eng.dev.tsv'...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/ner/__init__.py
hanlp/datasets/ner/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-06 15:32
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/ner/loaders/tsv.py
hanlp/datasets/ner/loaders/tsv.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-24 23:09 from typing import Union, List, Callable from hanlp.common.dataset import TransformableDataset from hanlp.utils.io_util import get_resource, generate_words_tags_from_tsv from hanlp.utils.string_util import split_long_sentence_into class TSVTaggingDatas...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/ner/loaders/__init__.py
hanlp/datasets/ner/loaders/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-12-28 19:04
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/ner/loaders/json_ner.py
hanlp/datasets/ner/loaders/json_ner.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-07-21 16:26 import json import os from typing import Union, List, Callable, Dict from hanlp_common.constant import NULL import hanlp.utils.span_util from hanlp.common.dataset import TransformableDataset from hanlp.utils.io_util import TimingFileIterator, read_tsv_a...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/lm/__init__.py
hanlp/datasets/lm/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-05 21:41 _PTB_HOME = 'http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz#' PTB_TOKEN_TRAIN = _PTB_HOME + 'data/ptb.train.txt' PTB_TOKEN_DEV = _PTB_HOME + 'data/ptb.valid.txt' PTB_TOKEN_TEST = _PTB_HOME + 'data/ptb.test.txt' PTB_CHAR_TRAIN = _PTB_HOME + ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/lm/loaders/lm_dataset.py
hanlp/datasets/lm/loaders/lm_dataset.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-05 21:42 import os from typing import Union, Callable, List import hanlp_common.io import torch from hanlp.common.dataset import TransformSequentialDataset from hanlp.common.transform import ToChar, WhitespaceTokenizer, AppendEOS, FieldToIndex from hanlp.common....
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/lm/loaders/__init__.py
hanlp/datasets/lm/loaders/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-12-28 19:04
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/srl/__init__.py
hanlp/datasets/srl/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-22 19:15
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/srl/ontonotes5/english.py
hanlp/datasets/srl/ontonotes5/english.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-25 18:48 from urllib.error import HTTPError from hanlp.datasets.srl.ontonotes5 import ONTONOTES5_HOME, CONLL12_HOME from hanlp.datasets.srl.ontonotes5._utils import make_gold_conll, make_ontonotes_language_jsonlines, \ batch_make_ner_tsv_if_necessary, batch...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/srl/ontonotes5/chinese.py
hanlp/datasets/srl/ontonotes5/chinese.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-11-26 16:07 import os from urllib.error import HTTPError import shutil from hanlp.datasets.srl.ontonotes5 import ONTONOTES5_HOME, CONLL12_HOME from hanlp.datasets.srl.ontonotes5._utils import make_gold_conll, make_ontonotes_language_jsonlines, \ batch_make_ner_t...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/srl/ontonotes5/__init__.py
hanlp/datasets/srl/ontonotes5/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-11-26 16:07 ONTONOTES5_HOME = 'https://catalog.ldc.upenn.edu/LDC2013T19/LDC2013T19.tgz#/ontonotes-release-5.0/data/' CONLL12_HOME = ONTONOTES5_HOME + '../conll-2012/'
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/srl/ontonotes5/_utils.py
hanlp/datasets/srl/ontonotes5/_utils.py
#!/usr/bin/env python import codecs import collections import glob import json import os import re import sys from pprint import pprint from typing import List, Dict, Union from hanlp_common.io import eprint, save_json from hanlp.common.transform import NormalizeToken from hanlp.datasets.parsing.loaders._ctb_utils im...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/srl/loaders/ontonotes_loader.py
hanlp/datasets/srl/loaders/ontonotes_loader.py
from typing import DefaultDict, List, Optional, Iterator, Set, Tuple, Dict from collections import defaultdict import codecs import os import logging from hanlp.utils.span_util import TypedSpan, enumerate_spans from phrasetree.tree import Tree logger = logging.getLogger(__name__) class OntonotesSentence: """ ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/srl/loaders/__init__.py
hanlp/datasets/srl/loaders/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-12-28 19:05
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/srl/loaders/conll2012.py
hanlp/datasets/srl/loaders/conll2012.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-22 19:15 import glob import json import os from typing import Union, List, Callable from hanlp.utils.span_util import enumerate_spans from hanlp.common.dataset import TransformableDataset from hanlp.common.transform import NamedTransform from hanlp.utils.io_util...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/pos/ctb5.py
hanlp/datasets/pos/ctb5.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-28 22:51 _CTB5_POS_HOME = 'http://file.hankcs.com/corpus/ctb5.1-pos.zip' CTB5_POS_TRAIN = f'{_CTB5_POS_HOME}#train.tsv' '''PoS training set for CTB5.''' CTB5_POS_DEV = f'{_CTB5_POS_HOME}#dev.tsv' '''PoS dev set for CTB5.''' CTB5_POS_TEST = f'{_CTB5_POS_HOME}#tes...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/pos/__init__.py
hanlp/datasets/pos/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-28 22:50
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/coref/__init__.py
hanlp/datasets/coref/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-07-04 13:39
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/coref/loaders/conll12coref.py
hanlp/datasets/coref/loaders/conll12coref.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-07-04 15:33 import collections import os from typing import Union, List, Callable, DefaultDict, Tuple, Optional, Iterator from hanlp.datasets.srl.loaders.ontonotes_loader import Ontonotes as _Ontonotes, OntonotesSentence, \ make_coref_instance from hanlp.common...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/coref/loaders/__init__.py
hanlp/datasets/coref/loaders/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-12-28 19:03
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/accuracy.py
hanlp/metrics/accuracy.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-12 17:56 from typing import Optional, Iterable import torch from hanlp.metrics.metric import Metric class CategoricalAccuracy(Metric): """ Categorical Top-K accuracy. Assumes integer labels, with each item to be classified having a single correct c...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/spearman_correlation.py
hanlp/metrics/spearman_correlation.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2021-05-23 16:12 import torch from hanlp.metrics.metric import Metric def _get_ranks(x: torch.Tensor) -> torch.Tensor: argsort = x.argsort() ranks = torch.zeros_like(argsort, device=x.device) ranks[argsort] = torch.arange(len(x), device=x.device) return...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/__init__.py
hanlp/metrics/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-09-14 21:55
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/metric.py
hanlp/metrics/metric.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-03 11:35 from abc import ABC, abstractmethod class Metric(ABC): def __lt__(self, other): return self.score < other def __le__(self, other): return self.score <= other def __eq__(self, other): return self.score == other ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/f1.py
hanlp/metrics/f1.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-07-10 14:55 from abc import ABC from hanlp.metrics.metric import Metric class F1(Metric, ABC): def __init__(self, nb_pred=0, nb_true=0, nb_correct=0) -> None: super().__init__() self.nb_correct = nb_correct self.nb_pred = nb_pred ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/mtl.py
hanlp/metrics/mtl.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-03 00:16 from hanlp.metrics.metric import Metric class MetricDict(Metric, dict): _COLORS = ["magenta", "cyan", "green", "yellow"] @property def score(self): return sum(float(x) for x in self.values()) / len(self) def __call__(self, pred...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/amr/__init__.py
hanlp/metrics/amr/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-24 12:47
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/amr/smatch_eval.py
hanlp/metrics/amr/smatch_eval.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-24 12:47 import os import warnings from typing import Union from hanlp.metrics.f1 import F1_ from hanlp.metrics.mtl import MetricDict from hanlp.utils.io_util import get_resource, run_cmd, pushd from hanlp.utils.log_util import flash _SMATCH_SCRIPT = 'https://gi...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/parsing/span.py
hanlp/metrics/parsing/span.py
# MIT License # # Copyright (c) 2020 Yu Zhang # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pub...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/parsing/labeled_score.py
hanlp/metrics/parsing/labeled_score.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-27 00:49 import tensorflow as tf class LabeledScore(object): def __init__(self, eps=1e-5): super(LabeledScore, self).__init__() self.eps = eps self.total = 0.0 self.correct_arcs = 0.0 self.correct_rels = 0.0 de...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/parsing/labeled_f1_tf.py
hanlp/metrics/parsing/labeled_f1_tf.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-27 21:42 import tensorflow as tf class LabeledF1TF(object): def __init__(self): super(LabeledF1TF, self).__init__() self.sum_gold_arcs_wo_punc = 0.0 self.sum_pred_arcs_wo_punc = 0.0 self.correct_arcs_wo_punc = 0.0 se...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/parsing/conllx_eval.py
hanlp/metrics/parsing/conllx_eval.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-03-08 22:35 import tempfile from hanlp.utils.io_util import get_resource, get_exitcode_stdout_stderr CONLLX_EVAL = get_resource( 'https://github.com/elikip/bist-parser/archive/master.zip' + '#bmstparser/src/utils/eval.pl') def evaluate(gold_file, pred_file): ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/parsing/attachmentscore.py
hanlp/metrics/parsing/attachmentscore.py
# MIT License # # Copyright (c) 2020 Yu Zhang # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, pub...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/parsing/labeled_f1.py
hanlp/metrics/parsing/labeled_f1.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-27 21:42 from hanlp.metrics.metric import Metric class LabeledF1(Metric): def __init__(self): super(LabeledF1, self).__init__() self.sum_gold_arcs_wo_punc = 0.0 self.sum_pred_arcs_wo_punc = 0.0 self.correct_arcs_wo_punc = 0...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/parsing/semdep_eval.py
hanlp/metrics/parsing/semdep_eval.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2017 Timothy Dozat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/parsing/__init__.py
hanlp/metrics/parsing/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-27 00:48
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/srl/srlconll.py
hanlp/metrics/srl/srlconll.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-07-16 18:44 import os from hanlp.utils.io_util import get_resource, get_exitcode_stdout_stderr, run_cmd def official_conll_05_evaluate(pred_path, gold_path): script_root = get_resource('http://www.lsi.upc.edu/~srlconll/srlconll-1.1.tgz') lib_path = f'{scri...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/srl/__init__.py
hanlp/metrics/srl/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-07-16 18:44
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/chunking/iobes_tf.py
hanlp/metrics/chunking/iobes_tf.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-09-14 21:55 from hanlp.common.vocab_tf import VocabTF from hanlp.metrics.chunking.conlleval import SpanF1 from hanlp.metrics.chunking.chunking_f1_tf import ChunkingF1_TF class IOBES_F1_TF(ChunkingF1_TF): def __init__(self, tag_vocab: VocabTF, from_logits=True...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/chunking/bmes_tf.py
hanlp/metrics/chunking/bmes_tf.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-09-14 21:55 from hanlp.common.vocab_tf import VocabTF from hanlp.metrics.chunking.chunking_f1_tf import ChunkingF1_TF from hanlp.metrics.chunking.sequence_labeling import get_entities class BMES_F1_TF(ChunkingF1_TF): def __init__(self, tag_vocab: VocabTF, fro...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/chunking/sequence_labeling.py
hanlp/metrics/chunking/sequence_labeling.py
# MIT License # # Copyright (c) 2018 chakki # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publi...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/chunking/chunking_f1_tf.py
hanlp/metrics/chunking/chunking_f1_tf.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-29 23:09 from abc import ABC, abstractmethod import tensorflow as tf from hanlp.common.vocab_tf import VocabTF class ChunkingF1_TF(tf.keras.metrics.Metric, ABC): def __init__(self, tag_vocab: VocabTF, from_logits=True, name='f1', dtype=None, **kwargs): ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/chunking/binary_chunking_f1.py
hanlp/metrics/chunking/binary_chunking_f1.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-02 14:27 from collections import defaultdict from typing import List, Union import torch from hanlp.metrics.f1 import F1 class BinaryChunkingF1(F1): def __call__(self, pred_tags: torch.LongTensor, gold_tags: torch.LongTensor, lens: List[int] = None): ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/chunking/__init__.py
hanlp/metrics/chunking/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-21 03:49
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/chunking/conlleval.py
hanlp/metrics/chunking/conlleval.py
#!/usr/bin/env python # Python version of the evaluation script from CoNLL'00- # Intentional differences: # - accept any space as delimiter by default # - optional file argument (default STDIN) # - option to set boundary (-b argument) # - LaTeX output (-l argument) not supported # - raw tags (-r argument) not support...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/metrics/chunking/chunking_f1.py
hanlp/metrics/chunking/chunking_f1.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-11 22:14 import io from collections import defaultdict from typing import List, Set, Tuple, Dict from hanlp.metrics.chunking.conlleval import calculate_metrics, DetailedF1, metrics from hanlp.metrics.chunking.sequence_labeling import get_entities from hanlp.metri...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/lambda_wrapper.py
hanlp/components/lambda_wrapper.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-31 18:36 from typing import Callable, Any from hanlp.common.component import Component from hanlp_common.reflection import classpath_of, object_from_classpath, str_to_type class LambdaComponent(Component): def __init__(self, function: Callable) -> None: ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/rnn_language_model_tf.py
hanlp/components/rnn_language_model_tf.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-04 17:28 from typing import List, Union import tensorflow as tf from hanlp.common.keras_component import KerasComponent from hanlp.transform.text_tf import TextTransform class RNNLanguageModel(KerasComponent): def __init__(self, transform: TextTransform =...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/lemmatizer.py
hanlp/components/lemmatizer.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-08 18:35 from typing import List from hanlp.common.transform import TransformList from hanlp.components.parsers.ud.lemma_edit import gen_lemma_rule, apply_lemma_rule from hanlp.components.taggers.transformers.transformer_tagger import TransformerTagger def add_...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/pipeline.py
hanlp/components/pipeline.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-31 00:22 import types from typing import Callable, Union, Iterable, Any from hanlp.components.lambda_wrapper import LambdaComponent from hanlp.common.component import Component from hanlp_common.document import Document from hanlp.utils.component_util import load_...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/__init__.py
hanlp/components/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-08-26 16:10 from .pipeline import Pipeline
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/distillation/distillable_component.py
hanlp/components/distillation/distillable_component.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-10-17 20:30 from abc import ABC from copy import copy import hanlp from hanlp.common.torch_component import TorchComponent from hanlp.components.distillation.losses import KnowledgeDistillationLoss from hanlp.components.distillation.schedulers import TemperatureSche...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/distillation/losses.py
hanlp/components/distillation/losses.py
# Adopted from https://github.com/airaria/TextBrewer # Apache License Version 2.0 import torch import torch.nn.functional as F from hanlp_common.configurable import AutoConfigurable def kd_mse_loss(logits_S, logits_T, temperature=1): ''' Calculate the mse loss between logits_S and logits_T :param logit...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/distillation/schedulers.py
hanlp/components/distillation/schedulers.py
# Adopted from https://github.com/airaria/TextBrewer # Apache License Version 2.0 from abc import ABC, abstractmethod import torch # x is between 0 and 1 from hanlp_common.configurable import AutoConfigurable def linear_growth_weight_scheduler(x): return x def linear_decay_weight_scheduler(x): return 1 - ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/distillation/__init__.py
hanlp/components/distillation/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-10-17 20:29
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/multi_task_learning.py
hanlp/components/mtl/multi_task_learning.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-20 19:55 import functools import itertools import logging import os from collections import defaultdict from copy import copy from itertools import chain from typing import Union, List, Callable, Dict, Optional, Any, Iterable, Tuple import numpy as np import torc...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
true
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/__init__.py
hanlp/components/mtl/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-06-20 19:54
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/amr.py
hanlp/components/mtl/tasks/amr.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-12 16:05 import logging from typing import Dict, Any, List, Union, Iterable, Callable import torch from stog.data.dataset_readers.amr_parsing.amr import AMRGraph from stog.data.dataset_readers.amr_parsing.node_utils import NodeUtilities from stog.data.dataset_rea...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/lem.py
hanlp/components/mtl/tasks/lem.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-09 16:37 import logging from typing import Dict, Any, Union, Iterable, Callable, List import torch from hanlp.common.dataset import SamplerBuilder, PadSequenceDataLoader from hanlp.common.transform import VocabDict from hanlp.components.lemmatizer import Transfor...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/dep_2nd.py
hanlp/components/mtl/tasks/dep_2nd.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-07 14:14 import logging from typing import Dict, Any, Union, Iterable, Callable, List import torch from hanlp_common.util import merge_locals_kwargs from torch.utils.data import DataLoader import hanlp.utils.torch_util from hanlp.common.dataset import SamplerBui...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/dep.py
hanlp/components/mtl/tasks/dep.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-13 21:39 import logging from typing import Dict, Any, Union, Iterable, List import torch from torch.optim import Adam from torch.optim.lr_scheduler import ExponentialLR from torch.utils.data import DataLoader from hanlp.common.dataset import SamplerBuilder, PadS...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/sdp.py
hanlp/components/mtl/tasks/sdp.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-13 21:39 import logging from typing import Dict, Any, Union, Iterable, List import torch from torch.optim import Adam from torch.optim.lr_scheduler import ExponentialLR from torch.utils.data import DataLoader from hanlp.common.dataset import SamplerBuilder, PadS...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/__init__.py
hanlp/components/mtl/tasks/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-02 16:51 import logging import os import warnings from abc import ABC, abstractmethod from copy import copy from typing import Callable, Dict, Any, Union, Iterable, List import torch from hanlp_common.util import merge_locals_kwargs from torch.utils.data import D...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/pos.py
hanlp/components/mtl/tasks/pos.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-10-19 18:56 import logging from typing import Dict, Any, Union, Iterable, Callable, List, Tuple, Sequence import torch from torch.utils.data import DataLoader from hanlp.common.dataset import SamplerBuilder, PadSequenceDataLoader from hanlp.common.transform import ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/ud.py
hanlp/components/mtl/tasks/ud.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-17 21:54 import logging from typing import Dict, Any, List, Union, Iterable, Callable import torch from torch.utils.data import DataLoader from hanlp.common.dataset import SamplerBuilder, PadSequenceDataLoader from hanlp_common.document import Document from hanl...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/constituency.py
hanlp/components/mtl/tasks/constituency.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-11-29 16:52 import logging from typing import Dict, Any, List, Union, Iterable, Callable import torch from phrasetree.tree import Tree from hanlp_common.constant import BOS, EOS from hanlp_common.document import Document from hanlp.components.parsers.biaffine.biaff...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/ner/tag_ner.py
hanlp/components/mtl/tasks/ner/tag_ner.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-03 14:35 import logging from typing import Union, List, Dict, Any, Iterable, Callable, Set, Sequence import torch from hanlp_trie import DictInterface from torch.utils.data import DataLoader from hanlp.common.dataset import SamplerBuilder, PadSequenceDataLoader ...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/ner/biaffine_ner.py
hanlp/components/mtl/tasks/ner/biaffine_ner.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-05 01:49 import logging from copy import copy from typing import Dict, Any, Union, Iterable, List import torch from torch.utils.data import DataLoader from hanlp.common.dataset import SamplerBuilder, PadSequenceDataLoader from hanlp.common.transform import Vocab...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/ner/__init__.py
hanlp/components/mtl/tasks/ner/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-03 14:34
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/srl/__init__.py
hanlp/components/mtl/tasks/srl/__init__.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-04 16:49
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/srl/rank_srl.py
hanlp/components/mtl/tasks/srl/rank_srl.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-05 15:43 import logging from typing import Union, List, Dict, Any, Iterable, Callable import torch from torch.utils.data import DataLoader from hanlp.common.dataset import SamplerBuilder, PadSequenceDataLoader from hanlp.common.transform import VocabDict from ha...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/srl/bio_srl.py
hanlp/components/mtl/tasks/srl/bio_srl.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-12-04 16:50 import logging from typing import Dict, Any, List, Union, Iterable, Callable import torch from torch.utils.data import DataLoader from hanlp.common.dataset import PadSequenceDataLoader, SamplerBuilder from hanlp.common.transform import VocabDict from ha...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false
hankcs/HanLP
https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/components/mtl/tasks/tok/tag_tok.py
hanlp/components/mtl/tasks/tok/tag_tok.py
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2020-08-11 16:35 import logging from typing import Dict, Any, Union, Iterable, List, Set import torch from torch.utils.data import DataLoader from hanlp.common.dataset import SamplerBuilder, PadSequenceDataLoader from hanlp.common.transform import VocabDict, TransformLi...
python
Apache-2.0
ddb1299bddff079e447af52ec12549c50636bfa8
2026-01-04T14:42:01.948856Z
false