repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_pos_dict.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-12-15 22:26
import hanlp
from hanlp.components.mtl.multi_task_learning import MultiTaskLearning
from hanlp.components.mtl.tasks.pos import TransformerTagging
from hanlp.components.mtl.tasks.tok.tag_tok import TaggingTokenization
from tests import cdroot
cdroot()
Han... | 26 | 1,126 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_parse_constituency.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2022-01-18 11:09
from hanlp_common.document import Document
import hanlp
con = hanlp.load(hanlp.pretrained.constituency.CTB9_CON_FULL_TAG_ELECTRA_SMALL)
# To speed up, parse multiple sentences at once, and use a GPU.
print(con(["2021年", "HanLPv2.1", "带来", "最", "先进", "的",... | 49 | 1,831 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_mlm.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2022-01-29 21:11
from hanlp.components.lm.mlm import MaskedLanguageModel
mlm = MaskedLanguageModel()
mlm.load('bert-base-chinese')
print(mlm('生活的真谛是[MASK]。'))
# Batching is always faster
print(mlm(['生活的真谛是[MASK]。', '巴黎是[MASK][MASK]的首都。']))
| 12 | 332 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_del_tasks.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2021-02-03 13:28
import hanlp
from hanlp.components.mtl.multi_task_learning import MultiTaskLearning
from hanlp_common.document import Document
HanLP: MultiTaskLearning = hanlp.load(hanlp.pretrained.mtl.OPEN_TOK_POS_NER_SRL_DEP_SDP_CON_ELECTRA_SMALL_ZH)
tasks = list(HanL... | 21 | 806 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_pipeline.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2021-12-28 20:47
import hanlp
# Pipeline allows blending multiple callable functions no matter they are a rule, a TensorFlow component or a PyTorch
# one. However, it's slower than the MTL framework.
# pos = hanlp.load(hanlp.pretrained.pos.CTB9_POS_ALBERT_BASE) # In cas... | 21 | 1,069 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_amr.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2022-04-12 22:19
import hanlp
parser = hanlp.load(hanlp.pretrained.amr.MRP2020_AMR_ENG_ZHO_XLM_BASE)
# For Chinese:
print(parser(["男孩", "希望", "女孩", "相信", "他", "。"]))
print(parser(["男孩", "希望", "女孩", "相信", "他", "。"], output_amr=False))
# For English:
print(parser(['The',... | 17 | 700 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_custom_dict.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-12-15 22:26
import hanlp
from hanlp.components.mtl.multi_task_learning import MultiTaskLearning
from hanlp.components.mtl.tasks.tok.tag_tok import TaggingTokenization
# 加载多任务模型
HanLP: MultiTaskLearning = hanlp.load(hanlp.pretrained.mtl.CLOSE_TOK_POS_NER_SRL_DEP_SDP_... | 34 | 1,730 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_ner_dict.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2021-04-29 11:06
import hanlp
from hanlp.components.mtl.tasks.ner.tag_ner import TaggingNamedEntityRecognition
from hanlp.utils.io_util import get_resource
HanLP = hanlp.load(hanlp.pretrained.mtl.CLOSE_TOK_POS_NER_SRL_DEP_SDP_CON_ERNIE_GRAM_ZH)
ner: TaggingNamedEntityRec... | 22 | 973 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/demo_word2vec.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2021-12-12 18:33
import hanlp
import torch
word2vec = hanlp.load(hanlp.pretrained.word2vec.CONVSEG_W2V_NEWS_TENSITE_WORD_PKU)
vec = word2vec('先进')
print(vec)
print(torch.nn.functional.cosine_similarity(word2vec('先进'), word2vec('优秀'), dim=0))
print(torch.nn.functional.co... | 24 | 907 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/train/finetune_ner.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2023-10-18 18:49
import os
import hanlp
from hanlp.components.ner.transformer_ner import TransformerNamedEntityRecognizer
from tests import cdroot
cdroot()
your_training_corpus = 'data/ner/finetune/word_to_iobes.tsv'
your_development_corpus = your_training_corpus # Us... | 49 | 1,511 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/train/open_base.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-12-03 14:24
from hanlp_demo import block_windows
from hanlp.common.dataset import SortingSamplerBuilder
from hanlp.common.transform import NormalizeCharacter
from hanlp.components.mtl.multi_task_learning import MultiTaskLearning
from hanlp.components.mtl.tasks.consti... | 123 | 4,639 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/train/open_small.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-12-03 14:24
from hanlp_demo import block_windows
from hanlp.common.dataset import SortingSamplerBuilder
from hanlp.common.transform import NormalizeCharacter
from hanlp.components.mtl.multi_task_learning import MultiTaskLearning
from hanlp.components.mtl.tasks.consti... | 128 | 4,827 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_classifier.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-01-01 03:52
from hanlp.datasets.classification.sentiment import CHNSENTICORP_ERNIE_TEST
import hanlp
classifier = hanlp.load('CHNSENTICORP_BERT_BASE_ZH')
print(classifier.predict('前台客房服务态度非常好!早餐很丰富,房价很干净。再接再厉!'))
# predict a whole file in batch mode
outputs = clas... | 14 | 485 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_multiprocess.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-02-15 11:30
import multiprocessing
import hanlp
tokenizer = hanlp.load(hanlp.pretrained.tok.LARGE_ALBERT_BASE)
def worker(job):
print(job)
print(tokenizer(job))
if __name__ == '__main__':
num_proc = 2
# Important! The python multiprocessing packa... | 24 | 888 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_cws.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 21:25
import hanlp
tokenizer = hanlp.load(hanlp.pretrained.tok.LARGE_ALBERT_BASE)
print(tokenizer('商品和服务'))
print(tokenizer(['萨哈夫说,伊拉克将同联合国销毁伊拉克大规模杀伤性武器特别委员会继续保持合作。',
'上海华安工业(集团)公司董事长谭旭光和秘书张晚霞来到美国纽约现代艺术博物馆参观。',
'HanLP支援臺灣正體、香港... | 41 | 1,521 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_client.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-01-08 04:43
# pip3 install tensorflow-serving-api-gpu
import grpc
import tensorflow as tf
from tensorflow_core.python.framework import tensor_util
from tensorflow_serving.apis import predict_pb2, prediction_service_pb2_grpc
import hanlp
from hanlp.common.keras_compon... | 35 | 1,272 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_sdp.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-31 23:55
import hanlp
semantic_parser = hanlp.load('SEMEVAL16_NEWS_BIAFFINE_ZH')
sent = [('蜡烛', 'NN'), ('两', 'CD'), ('头', 'NN'), ('烧', 'VV')]
print(semantic_parser(sent))
| 9 | 238 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_pos.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 21:25
import hanlp
from hanlp.pretrained.pos import CTB9_POS_ALBERT_BASE
tagger = hanlp.load(CTB9_POS_ALBERT_BASE)
print(tagger.predict(['我', '的', '希望', '是', '希望', '世界', '和平']))
print(tagger.predict([['支持', '批处理', '地', '预测'], ['速度', '更', '快']]))
| 10 | 352 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_fasttext.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2021-12-12 18:33
import hanlp
import torch
# fasttext is a `torch.nn.Module`. Unless you know how to code in
# PyTorch, otherwise don't bother to use this.
fasttext = hanlp.load(hanlp.pretrained.fasttext.FASTTEXT_WIKI_300_ZH)
vec = fasttext('单词')
print(vec)
print(torch... | 16 | 497 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_ner.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-30 19:52
import hanlp
recognizer = hanlp.load(hanlp.pretrained.ner.MSRA_NER_BERT_BASE_ZH)
print(recognizer.predict([list('上海华安工业(集团)公司董事长谭旭光和秘书张晚霞来到美国纽约现代艺术博物馆参观。'),
list('萨哈夫说,伊拉克将同联合国销毁伊拉克大规模杀伤性武器特别委员会继续保持合作。')]))
| 9 | 455 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_pipeline.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-31 03:24
import hanlp
tokenizer = hanlp.load('LARGE_ALBERT_BASE')
tagger = hanlp.load('CTB9_POS_ALBERT_BASE')
syntactic_parser = hanlp.load('CTB7_BIAFFINE_DEP_ZH')
semantic_parser = hanlp.load('SEMEVAL16_TEXT_BIAFFINE_ZH')
pipeline = hanlp.pipeline() \
.app... | 36 | 1,482 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_serving.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-01-06 20:23
import hanlp
from hanlp.common.keras_component import KerasComponent
tagger: KerasComponent = hanlp.load(hanlp.pretrained.pos.CTB5_POS_RNN)
print(tagger('商品 和 服务'.split()))
tagger.serve()
| 10 | 264 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_cws_trie.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 21:25
from hanlp_trie.trie import Trie
import hanlp
tokenizer = hanlp.load('LARGE_ALBERT_BASE')
text = 'NLP统计模型没有加规则,聪明人知道自己加。英文、数字、自定义词典统统都是规则。'
print(tokenizer(text))
trie = Trie()
trie.update({'自定义词典': 'custom_dict', '聪明人': 'smart'})
def split_sents(tex... | 47 | 1,376 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/demo_dep.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 21:25
import hanlp
syntactic_parser = hanlp.load(hanlp.pretrained.dep.CTB7_BIAFFINE_DEP_ZH)
sent = [('蜡烛', 'NN'), ('两', 'CD'), ('头', 'NN'), ('烧', 'VV')]
tree = syntactic_parser(sent)
print(tree)
| 10 | 265 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ctb7_dep.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 18:33
from hanlp.components.parsers.biaffine_parser_tf import BiaffineDependencyParserTF
from hanlp.datasets.parsing.ctb5 import CIP_W2V_100_CN
from hanlp.datasets.parsing.ctb7 import CTB7_DEP_TRAIN, CTB7_DEP_DEV, CTB7_DEP_TEST
from tests import cdroot
cdroot(... | 28 | 1,227 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ptb_dep_biaffine_albert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-03-07 23:48
from hanlp.metrics.parsing import conllx_eval
from hanlp.datasets.parsing.ptb import PTB_SD330_DEV, PTB_SD330_TRAIN, PTB_SD330_TEST, PTB_TOKEN_MAPPING
from hanlp.components.parsers.biaffine_parser_tf import BiaffineTransformerDependencyParserTF
from test... | 30 | 1,091 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_chnsenticorp_bert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-30 21:01
from hanlp.components.classifiers.transformer_classifier_tf import TransformerClassifierTF, TransformerTextTransform
from hanlp.datasets.classification.sentiment import CHNSENTICORP_ERNIE_TRAIN, CHNSENTICORP_ERNIE_TEST, \
CHNSENTICORP_ERNIE_DEV
from t... | 17 | 816 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ptb_dep_biaffine_bert_positional.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-03-07 23:48
from hanlp.metrics.parsing import conllx_eval
from hanlp.datasets.parsing.ptb import PTB_SD330_DEV, PTB_SD330_TRAIN, PTB_SD330_TEST, PTB_TOKEN_MAPPING
from hanlp.components.parsers.biaffine_parser_tf import BiaffineTransformerDependencyParserTF
from test... | 30 | 1,130 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ctb9_pos_albert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 23:15
from hanlp.components.taggers.transformers.transformer_tagger_tf import TransformerTaggerTF
from tests import cdroot
cdroot()
tagger = TransformerTaggerTF()
save_dir = 'data/model/pos/ctb9_albert_base'
tagger.fit('data/pos/ctb9/train.tsv',
'da... | 22 | 735 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_semeval15_pas.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-01-01 18:26
from hanlp.components.parsers.biaffine_parser_tf import BiaffineSemanticDependencyParserTF
from hanlp.pretrained.glove import GLOVE_6B_100D
from tests import cdroot
cdroot()
save_dir = 'data/model/sdp/semeval15_biaffine_pas'
parser = BiaffineSemanticDepe... | 28 | 1,322 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_msra_ner_ngram_conv.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 23:15
from hanlp.components.ner.ner_tf import NgramConvNamedEntityRecognizerTF
from hanlp.datasets.ner.msra import MSRA_NER_CHAR_LEVEL_TRAIN, MSRA_NER_CHAR_LEVEL_DEV, MSRA_NER_CHAR_LEVEL_TEST
from hanlp.pretrained.word2vec import CONVSEG_W2V_NEWS_TENSITE_CHAR, ... | 30 | 1,401 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_msra_ner_bert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 23:15
from hanlp.components.ner.ner_tf import TransformerNamedEntityRecognizerTF
from hanlp.datasets.ner.msra import MSRA_NER_CHAR_LEVEL_TRAIN, MSRA_NER_CHAR_LEVEL_DEV, MSRA_NER_CHAR_LEVEL_TEST
from tests import cdroot
cdroot()
recognizer = TransformerNamedEnt... | 17 | 851 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ptb_dep_sa_albert_topk.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-03-07 23:48
from hanlp.metrics.parsing import conllx_eval
from hanlp.datasets.parsing.ptb import PTB_SD330_DEV, PTB_SD330_TRAIN, PTB_SD330_TEST, PTB_TOKEN_MAPPING
from hanlp.components.parsers.biaffine_parser_tf import BiaffineTransformerDependencyParserTF, \
St... | 35 | 1,269 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/finetune_msra_ner_albert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 23:15
import hanlp
from hanlp.components.ner.ner_tf import TransformerNamedEntityRecognizerTF
from hanlp.datasets.ner.msra import MSRA_NER_CHAR_LEVEL_TRAIN, MSRA_NER_CHAR_LEVEL_DEV, MSRA_NER_CHAR_LEVEL_TEST
from tests import cdroot
cdroot()
recognizer = Transf... | 18 | 872 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ctb5_pos_rnn.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 22:46
from hanlp.components.taggers.pos_tf import RNNPartOfSpeechTaggerTF
from hanlp.datasets.pos.ctb5 import CTB5_POS_TRAIN, CTB5_POS_DEV, CTB5_POS_TEST
from hanlp.pretrained.fasttext import FASTTEXT_WIKI_300_ZH
from tests import cdroot
cdroot()
tagger = RNNP... | 16 | 696 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_msra_ner_rnn.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 23:15
from hanlp.components.ner.ner_tf import RNNNamedEntityRecognizerTF
from hanlp.datasets.ner.msra import MSRA_NER_CHAR_LEVEL_TRAIN, MSRA_NER_CHAR_LEVEL_DEV, MSRA_NER_CHAR_LEVEL_TEST
from hanlp.pretrained.word2vec import RADICAL_CHAR_EMBEDDING_100
from tests... | 17 | 683 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ptb_dep_biaffine_bert_96.6.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-03-07 23:48
from hanlp.datasets.parsing.ptb import PTB_SD330_DEV, PTB_SD330_TRAIN, PTB_SD330_TEST, PTB_TOKEN_MAPPING
from hanlp.components.parsers.biaffine_parser_tf import BiaffineTransformerDependencyParserTF
from tests import cdroot
from hanlp.metrics.parsing imp... | 25 | 954 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_conll03_ner_bert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-10-25 21:34
from hanlp.components.ner.ner_tf import TransformerNamedEntityRecognizerTF
from hanlp.datasets.ner.conll03 import CONLL03_EN_TRAIN, CONLL03_EN_DEV, CONLL03_EN_TEST
from tests import cdroot
cdroot()
tagger = TransformerNamedEntityRecognizerTF()
save_dir =... | 17 | 722 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_semeval15_dm.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-01-01 18:26
from hanlp.components.parsers.biaffine_parser_tf import BiaffineSemanticDependencyParserTF
from hanlp.pretrained.glove import GLOVE_6B_100D
from tests import cdroot
cdroot()
save_dir = 'data/model/sdp/semeval15_biaffine_dm'
parser = BiaffineSemanticDepen... | 28 | 1,329 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ctb5_dep.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 18:33
from hanlp.components.parsers.biaffine_parser_tf import BiaffineDependencyParserTF
from hanlp.datasets.parsing.ctb5 import CTB5_DEP_TRAIN, CTB5_DEP_DEV, CTB5_DEP_TEST
from hanlp.pretrained.word2vec import CTB5_FASTTEXT_300_CN
from tests import cdroot
cdr... | 28 | 1,236 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ctb9_pos_electra.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 23:15
from hanlp.components.taggers.transformers.transformer_tagger_tf import TransformerTaggerTF
from tests import cdroot
cdroot()
tagger = TransformerTaggerTF()
save_dir = 'data/model/pos/ctb9_electra_small_zh_epoch_20'
tagger.fit('data/pos/ctb9/train.tsv',
... | 22 | 749 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_semeval16_text.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-26 23:20
from hanlp.datasets.parsing.semeval16 import SEMEVAL2016_TEXT_TRAIN, SEMEVAL2016_TEXT_DEV, SEMEVAL2016_TEXT_TEST
from hanlp.pretrained.word2vec import SEMEVAL16_EMBEDDINGS_300_TEXT_CN
from hanlp.utils.tf_util import nice
nice()
from hanlp.components.pars... | 31 | 1,376 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ptb_dep_sa_pos_bert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-03-07 23:48
from hanlp.metrics.parsing import conllx_eval
from hanlp.datasets.parsing.ptb import PTB_SD330_DEV, PTB_SD330_TRAIN, PTB_SD330_TEST, PTB_TOKEN_MAPPING
from hanlp.components.parsers.biaffine_parser_tf import BiaffineTransformerDependencyParserTF, \
St... | 35 | 1,341 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_semeval16_news.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-26 23:20
from hanlp.datasets.parsing.semeval16 import SEMEVAL2016_NEWS_TRAIN, SEMEVAL2016_NEWS_DEV, SEMEVAL2016_NEWS_TEST
from hanlp.pretrained.word2vec import SEMEVAL16_EMBEDDINGS_300_NEWS_CN
from hanlp.utils.tf_util import nice
nice()
from hanlp.components.pars... | 31 | 1,376 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_semeval15_psd.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2020-01-01 18:26
from hanlp.components.parsers.biaffine_parser_tf import BiaffineSemanticDependencyParserTF
from hanlp.pretrained.glove import GLOVE_6B_100D
from tests import cdroot
cdroot()
save_dir = 'data/model/sdp/semeval15_biaffine_psd'
parser = BiaffineSemanticDepe... | 28 | 1,322 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_msra_ner_albert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 23:15
from hanlp.components.ner.ner_tf import TransformerNamedEntityRecognizerTF
from hanlp.datasets.ner.msra import MSRA_NER_CHAR_LEVEL_TRAIN, MSRA_NER_CHAR_LEVEL_DEV, MSRA_NER_CHAR_LEVEL_TEST
from tests import cdroot
cdroot()
recognizer = TransformerNamedEnt... | 19 | 938 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_msra_ner_electra.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 23:15
from hanlp.components.ner.ner_tf import TransformerNamedEntityRecognizerTF
from hanlp.datasets.ner.msra import MSRA_NER_CHAR_LEVEL_TRAIN, MSRA_NER_CHAR_LEVEL_DEV, MSRA_NER_CHAR_LEVEL_TEST
from tests import cdroot
cdroot()
recognizer = TransformerNamedEnt... | 19 | 975 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_ptb_pos_rnn_fasttext.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-10-25 21:34
import tensorflow as tf
from hanlp.components.taggers.pos_tf import RNNPartOfSpeechTaggerTF
from hanlp.pretrained.fasttext import FASTTEXT_CC_300_EN
from tests import cdroot
cdroot()
tagger = RNNPartOfSpeechTaggerTF()
save_dir = 'data/model/pos/ptb_pos... | 35 | 1,181 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/train_conll03_ner_flair.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-10-25 21:34
import tensorflow as tf
from hanlp.components.ner.ner_tf import RNNNamedEntityRecognizerTF
from hanlp.datasets.ner.conll03 import CONLL03_EN_TRAIN, CONLL03_EN_TEST
from hanlp.pretrained.glove import GLOVE_6B_100D
from hanlp.pretrained.rnnlm import FLAIR... | 52 | 2,033 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_pku_conv_cws.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-21 15:39
from hanlp.datasets.tokenization.sighan2005 import SIGHAN2005_PKU_TRAIN, SIGHAN2005_PKU_DEV, SIGHAN2005_PKU_TEST
from hanlp.pretrained.word2vec import CONVSEG_W2V_NEWS_TENSITE_CHAR
from hanlp.utils.tf_util import nice
from tests import cdroot
import tenso... | 36 | 1,527 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_large_rnn_cws.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-21 15:39
import tensorflow as tf
from hanlp.components.tokenizers.tok_tf import RNNTokenizerTF
from hanlp.datasets.cws.ctb import CTB6_CWS_TEST, CTB6_CWS_DEV
from hanlp.pretrained.word2vec import RADICAL_CHAR_EMBEDDING_100
from tests import cdroot
cdroot()
toke... | 36 | 1,343 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_ctb6_cws_bert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 22:22
from hanlp.components.tokenizers.tok_tf import TransformerTokenizerTF
from hanlp.datasets.tokenization.ctb6 import CTB6_CWS_TRAIN, CTB6_CWS_DEV, CTB6_CWS_TEST
from tests import cdroot
cdroot()
tokenizer = TransformerTokenizerTF()
save_dir = 'data/model/... | 18 | 670 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_msr_cws_ngram_conv.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-21 15:39
import tensorflow as tf
from hanlp.components.tokenizers.tok_tf import NgramConvTokenizerTF
from hanlp.datasets.tokenization.sighan2005.msr import SIGHAN2005_MSR_TRAIN, SIGHAN2005_MSR_DEV, SIGHAN2005_MSR_TEST
from hanlp.pretrained.word2vec import CONVSEG... | 32 | 1,336 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_large_bert_cws.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-21 15:39
from hanlp.components.tokenizers.tok_tf import TransformerTokenizerTF
from hanlp.datasets.tokenization.ctb6 import CTB6_CWS_DEV, CTB6_CWS_TEST
from tests import cdroot
cdroot()
tokenizer = TransformerTokenizerTF()
save_dir = 'data/model/cws_bert_base_100... | 17 | 698 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_large_cws_electra.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 22:22
from hanlp.components.tokenizers.tok_tf import TransformerTokenizerTF
from hanlp.datasets.tokenization.ctb6 import CTB6_CWS_DEV, CTB6_CWS_TEST
from tests import cdroot
cdroot()
tokenizer = TransformerTokenizerTF()
save_dir = 'data/model/large_corpus_cws_... | 20 | 804 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_msr_cws_ngram_conv_embed.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-21 15:39
import tensorflow as tf
from hanlp.components.tokenizers.tok import NgramConvTokenizer
from hanlp.datasets.tokenization.sighan2005.msr import SIGHAN2005_MSR_TRAIN, SIGHAN2005_MSR_VALID, SIGHAN2005_MSR_TEST
from hanlp.pretrained.word2vec import CONVSEG_W2... | 40 | 1,775 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_large_conv_cws.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-29 21:58
import tensorflow as tf
from hanlp.components.tokenizers.tok_tf import NgramConvTokenizerTF
from hanlp.datasets.cws.ctb import CTB6_CWS_TRAIN, CTB6_CWS_DEV, CTB6_CWS_TEST
from hanlp.pretrained.word2vec import CONVSEG_W2V_NEWS_TENSITE_CHAR
from tests imp... | 33 | 1,270 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_ctb6_cws_albert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 22:22
from hanlp.components.tokenizers.tok_tf import TransformerTokenizerTF
from hanlp.datasets.tokenization.ctb6 import CTB6_CWS_TRAIN, CTB6_CWS_DEV, CTB6_CWS_TEST
from tests import cdroot
cdroot()
tokenizer = TransformerTokenizerTF()
save_dir = 'data/model/... | 19 | 751 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_large_cws_albert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 22:22
from hanlp.components.tokenizers.tok_tf import TransformerTokenizerTF
from hanlp.datasets.tokenization.ctb6 import CTB6_CWS_DEV, CTB6_CWS_TEST
from tests import cdroot
cdroot()
tokenizer = TransformerTokenizerTF()
save_dir = 'data/model/large_corpus_cws_... | 20 | 801 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_msr_cws_bert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-21 15:39
from hanlp.components.tokenizers.tok_tf import TransformerTokenizerTF
from hanlp.datasets.tokenization.sighan2005.msr import SIGHAN2005_MSR_TRAIN, SIGHAN2005_MSR_DEV, SIGHAN2005_MSR_TEST
from tests import cdroot
cdroot()
tokenizer = TransformerTokenizerT... | 17 | 708 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_ctb6_cws_convseg.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 22:22
import tensorflow as tf
from hanlp.components.tokenizers.tok_tf import NgramConvTokenizerTF
from hanlp.datasets.tokenization.ctb6 import CTB6_CWS_TRAIN, CTB6_CWS_DEV, CTB6_CWS_TEST
from hanlp.pretrained.word2vec import CONVSEG_W2V_NEWS_TENSITE_CHAR
from ... | 32 | 1,279 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_pku980106_rnn_cws.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-21 15:39
import tensorflow as tf
from hanlp.components.tokenizers.tok_tf import RNNTokenizerTF
from hanlp.pretrained.word2vec import RADICAL_CHAR_EMBEDDING_100
from tests import cdroot
cdroot()
tokenizer = RNNTokenizerTF()
save_dir = 'data/model/cws/pku_6m_rnn_... | 30 | 1,155 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_msr_cws_albert.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-28 22:22
from hanlp.components.tokenizers.tok import TransformerTokenizer
from hanlp.datasets.cws.ctb import CTB6_CWS_TEST
from hanlp.datasets.tokenization.sighan2005.msr import SIGHAN2005_MSR_VALID, SIGHAN2005_MSR_TRAIN
from tests import cdroot
cdroot()
tokeniz... | 21 | 806 |
HanLP | plugins/hanlp_demo/hanlp_demo/zh/tf/train/cws/train_pku980106_conv_cws.py | .py | # -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-21 15:39
import tensorflow as tf
from hanlp.components.tokenizers.tok_tf import NgramConvTokenizerTF
from hanlp.pretrained.word2vec import RADICAL_CHAR_EMBEDDING_100
from tests import cdroot
cdroot()
tokenizer = NgramConvTokenizerTF()
save_dir = 'data/model/cws... | 32 | 1,277 |
PDFMathTranslate | pdf2zh/doclayout.py | .py | import abc
import logging
import os
import cv2
import numpy as np
import ast
from babeldoc.assets.assets import get_doclayout_onnx_model_path
try:
import onnx
import onnxruntime
except ImportError as e:
if "DLL load failed" in str(e):
raise OSError(
"Microsoft Visual C++ Redistributabl... | 224 | 7,236 |
PDFMathTranslate | pdf2zh/gui.py | .py | import asyncio
import cgi
import os
import shutil
import socket
import uuid
from asyncio import CancelledError
from pathlib import Path
import typing as T
import gradio as gr
import requests
import tqdm
from gradio_pdf import PDF
from string import Template
import logging
from pdf2zh import __version__
from pdf2zh.hi... | 922 | 28,839 |
PDFMathTranslate | pdf2zh/pdfinterp.py | .py | import logging
from typing import Any, Dict, Optional, Sequence, Tuple, cast
import numpy as np
from pdfminer import settings
from pdfminer.pdfcolor import PREDEFINED_COLORSPACE, PDFColorSpace
from pdfminer.pdfdevice import PDFDevice
from pdfminer.pdfinterp import (
PDFPageInterpreter,
PDFResourceManager,
... | 367 | 14,002 |
PDFMathTranslate | pdf2zh/__init__.py | .py | import logging
log = logging.getLogger(__name__)
__version__ = "1.9.11"
__author__ = "Byaidu"
__all__ = ["translate", "translate_stream"]
def __getattr__(name):
if name in {"translate", "translate_stream"}:
from pdf2zh.high_level import translate, translate_stream
return {"translate": translate... | 16 | 441 |
PDFMathTranslate | pdf2zh/converter.py | .py | import concurrent.futures
import logging
import re
import unicodedata
from enum import Enum
from string import Template
from typing import Dict
import numpy as np
from pdfminer.converter import PDFConverter
from pdfminer.layout import LTChar, LTFigure, LTLine, LTPage
from pdfminer.pdffont import PDFCIDFont, PDFUnicode... | 535 | 25,490 |
PDFMathTranslate | pdf2zh/pdf2zh.py | .py | #!/usr/bin/env python3
"""A command line tool for extracting text and images from PDF and
output it to plain text, html, xml or tags.
"""
from __future__ import annotations
import argparse
import logging
import os
import sys
from string import Template
from typing import List, Optional
from pdf2zh import __version__... | 530 | 14,956 |
PDFMathTranslate | pdf2zh/translator.py | .py | import html
import json
import logging
import os
import re
import unicodedata
from copy import copy
from string import Template
from typing import cast
import deepl
import ollama
import openai
import requests
import xinference_client
from azure.ai.translation.text import TextTranslationClient
from azure.core.credential... | 1,199 | 40,392 |
PDFMathTranslate | pdf2zh/high_level.py | .py | """Functions that can be used for the most common use-cases for pdf2zh.six"""
import asyncio
import io
import os
import re
import sys
import tempfile
import logging
from asyncio import CancelledError
from pathlib import Path
from string import Template
from typing import Any, BinaryIO, List, Optional, Dict
import num... | 436 | 13,911 |
PDFMathTranslate | pdf2zh/converter_docx.py | .py | """Convert doc/docx files to PDF using LibreOffice headless."""
import logging
import shutil
import subprocess
import tempfile
from pathlib import Path
logger = logging.getLogger(__name__)
SUPPORTED_EXTENSIONS = {".doc", ".docx"}
def is_convertible(filename: str) -> bool:
return Path(filename).suffix.lower() i... | 51 | 1,514 |
PDFMathTranslate | pdf2zh/config.py | .py | import json
from pathlib import Path
from threading import RLock # 改成 RLock
import os
import copy
class ConfigManager:
_instance = None
_lock = RLock() # 用 RLock 替换 Lock,允许在同一个线程中重复获取锁
@classmethod
def get_instance(cls):
"""获取单例实例"""
# 先判断是否存在实例,如果不存在再加锁进行初始化
if cls._instanc... | 215 | 8,077 |
PDFMathTranslate | pdf2zh/mcp_server.py | .py | from mcp.server import Server
from mcp.server.fastmcp import FastMCP, Context
from mcp.server.sse import SseServerTransport
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.routing import Mount, Route
from pdf2zh import translate_stream
from pdf2zh.converter_docx import... | 123 | 3,956 |
PDFMathTranslate | pdf2zh/cache.py | .py | import logging
import os
import json
from peewee import Model, SqliteDatabase, AutoField, CharField, TextField, SQL
from typing import Optional
# we don't init the database here
db = SqliteDatabase(None)
logger = logging.getLogger(__name__)
class _TranslationCache(Model):
id = AutoField()
translate_engine = ... | 142 | 4,453 |
PDFMathTranslate | pdf2zh/backend.py | .py | from flask import Flask, request, send_file
from celery import Celery, Task
from celery.result import AsyncResult
from pdf2zh import translate_stream
import tqdm
import json
import io
from string import Template
from pdf2zh.doclayout import ModelInstance
from pdf2zh.config import ConfigManager
flask_app = Flask("pdf2z... | 101 | 2,912 |
PDFMathTranslate | pdf2zh/kernel/legacy.py | .py | """Fast kernel adapter — wraps existing pdf2zh.high_level.translate()."""
from __future__ import annotations
import asyncio
import logging
from pathlib import Path
from typing import Any, Optional
from pdf2zh.kernel.protocol import TranslateRequest, TranslateResult
logger = logging.getLogger(__name__)
class Legac... | 92 | 2,701 |
PDFMathTranslate | pdf2zh/kernel/v2_bridge.py | .py | """v2 bridge — convert v1 TranslateRequest to v2 CLI args + env vars.
This is the only translation layer between the v1 protocol and the v2
(pdf2zh_next) CLI. v2 handles all its own config parsing, so we just
need to produce CLI args and environment variables.
"""
from __future__ import annotations
import dataclass... | 193 | 5,815 |
PDFMathTranslate | pdf2zh/kernel/__init__.py | .py | """Kernel package — hot-pluggable translation kernel registry."""
from pdf2zh.kernel.registry import KernelRegistry
from pdf2zh.kernel.legacy import LegacyKernel
from pdf2zh.kernel.precise import PreciseKernel
# Always register both kernels.
# PreciseKernel.is_available() returns False if submodule/venv not set up.
K... | 13 | 432 |
PDFMathTranslate | pdf2zh/kernel/registry.py | .py | """Thread-safe kernel registry for hot-pluggable kernel switching."""
from __future__ import annotations
import threading
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pdf2zh.kernel.protocol import KernelProtocol
class KernelRegistry:
_lock = threading.RLock()
_active: KernelProtocol | None =... | 60 | 1,771 |
PDFMathTranslate | pdf2zh/kernel/protocol.py | .py | """Kernel protocol — unified interface for translation kernels."""
from __future__ import annotations
import asyncio
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Optional, Protocol, runtime_checkable
@dataclass
class TranslateRequest:
"""Unified translation request b... | 66 | 1,633 |
PDFMathTranslate | pdf2zh/kernel/v2_worker.py | .py | #!/usr/bin/env python3
"""Subprocess worker — runs pdf2zh_next translation in an isolated venv.
Protocol:
- stdin: JSON array of CLI args (e.g. ["file.pdf", "--lang-out", "zh", "--openai"])
- stdout: JSON result (last line, after all progress events)
- stderr: JSON-lines progress events and log output
This scr... | 121 | 4,414 |
PDFMathTranslate | pdf2zh/kernel/precise.py | .py | """Precise kernel adapter — runs pdf2zh_next in an isolated subprocess/venv."""
from __future__ import annotations
import asyncio
import json
import logging
import os
import subprocess
import sys
from pathlib import Path
from typing import Any, Optional
from pdf2zh.kernel.v2_bridge import request_to_cli_args, reques... | 250 | 8,210 |
PDFMathTranslate | test/test_translator.py | .py | import unittest
from textwrap import dedent
from unittest import mock
from ollama import ResponseError as OllamaResponseError
from pdf2zh import cache
from pdf2zh.config import ConfigManager
from pdf2zh.translator import BaseTranslator, OllamaTranslator, OpenAIlikedTranslator
# Since it is necessary to test whether ... | 225 | 8,396 |
PDFMathTranslate | test/test_converter.py | .py | import unittest
from unittest.mock import Mock, patch, MagicMock
from pdfminer.layout import LTPage, LTChar, LTLine
from pdfminer.pdfinterp import PDFResourceManager
from pdf2zh.converter import PDFConverterEx, TranslateConverter
class TestPDFConverterEx(unittest.TestCase):
def setUp(self):
self.rsrcmgr =... | 111 | 3,676 |
PDFMathTranslate | test/test_kernel.py | .py | """Tests for the kernel abstraction layer."""
import sys
import unittest
from pathlib import Path
from unittest.mock import patch, MagicMock
# Ensure the project root is on the path
PROJECT_ROOT = Path(__file__).resolve().parent.parent
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
... | 704 | 25,044 |
PDFMathTranslate | test/test_doclayout.py | .py | import unittest
from unittest.mock import patch, MagicMock
import numpy as np
from pdf2zh.doclayout import (
OnnxModel,
YoloResult,
YoloBox,
)
class TestOnnxModel(unittest.TestCase):
@patch("onnx.load")
@patch("onnxruntime.InferenceSession")
def setUp(self, mock_inference_session, mock_onnx_lo... | 106 | 3,470 |
PDFMathTranslate | test/test_cli.py | .py | import importlib
import sys
import unittest
class TestCliVersion(unittest.TestCase):
def tearDown(self):
for module_name in [
"pdf2zh",
"pdf2zh.pdf2zh",
"pdf2zh.high_level",
"pdf2zh.doclayout",
]:
sys.modules.pop(module_name, None)
d... | 38 | 1,112 |
PDFMathTranslate | test/test_cache.py | .py | import unittest
from pdf2zh import cache
class TestCache(unittest.TestCase):
def setUp(self):
self.test_db = cache.init_test_db()
def tearDown(self):
# Clean up
cache.clean_test_db(self.test_db)
def test_basic_set_get(self):
"""Test basic set and get operations"""
... | 212 | 8,319 |
jax | build_wheel.py | .py | # Copyright 2025 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 130 | 3,407 |
jax | setup.py | .py | # Copyright 2018 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 152 | 5,245 |
jax | conftest.py | .py | # Copyright 2021 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 110 | 4,670 |
jax | jax_plugins/rocm/rocm_version.py | .py | # Copyright 2026 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 53 | 1,661 |
jax | jax_plugins/rocm/setup.py | .py | # Copyright 2024 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 81 | 2,573 |
jax | jax_plugins/rocm/__init__.py | .py | # Copyright 2024 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 121 | 3,988 |
jax | jax_plugins/rocm/plugin_setup.py | .py | # Copyright 2024 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 100 | 3,332 |
jax | jax_plugins/cuda/setup.py | .py | # Copyright 2023 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 68 | 2,071 |
jax | jax_plugins/cuda/__init__.py | .py | # Copyright 2023 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 406 | 14,854 |
jax | jax_plugins/cuda/plugin_setup.py | .py | # Copyright 2023 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | 112 | 4,549 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.