Ejemplo n.º 1
0
#!/usr/bin/env python 3
# -*- coding: utf-8 -*-

#
# Copyright (c) 2020 Baidu.com, Inc. All Rights Reserved
#
"""
brief

Authors: panxu([email protected])
Date:    2020/05/15 10:50:00
"""
import logging
import os
from unittest import TestCase

from easytext.utils import log_util

ASSERT = TestCase()

# 设置 root, 放在 tests 中,是因为 easytext 是库,只有在 tests 的时候,涉及到数据存储
ROOT_PATH = os.path.join(os.path.dirname(__file__), "../..")

log_util.config(level=logging.INFO)
Ejemplo n.º 2
0
Authors: PanXu
Date:    2020/06/27 12:25:00
"""
import logging
from torch.utils.data import DataLoader

from easytext.data import ModelInputs
from easytext.utils.json_util import json2str
from easytext.utils import log_util

from ner.tests import ASSERT
from ner.data import NerModelCollate
from ner.data import VocabularyBuilder

log_util.config()


def test_ner_model_collate(conll2003_dataset, vocabulary):
    """
    测试 ner model collate
    :param conll2003_dataset: conll2003 数据集
    :param vocabulary: 在 conftest.py 中的 vocabulary 返回结果, 字典
    :return: None
    """

    token_vocab = vocabulary["token_vocabulary"]
    label_vocab = vocabulary["label_vocabulary"]

    vocabulary_builder = VocabularyBuilder(
        is_training=False,
Ejemplo n.º 3
0
#!/usr/bin/env python 3
# -*- coding: utf-8 -*-

#
# Copyright (c) 2021 PanXu, Inc. All Rights Reserved
#
"""
brief

Authors: PanXu
Date:    2021/08/14 11:54:00
"""

import logging
import os
from easytext.utils import log_util

# 设置 root, 用作数据路径访问,包括测试数据,训练数据等
ROOT_PATH = os.path.join(os.path.dirname(__file__), "../")

log_util.config(level=logging.DEBUG)