This commit is contained in:
tlk-dsg 2021-09-17 17:49:28 +08:00
commit cfb7b1c987
111 changed files with 87 additions and 43 deletions

View File

@ -84,7 +84,17 @@ DeepKE 提供了多种知识抽取模型。
2. NER 2. NER
数据为txt文件样式范例为 数据为txt文件
中文样式范例为:
| Sentence | Person | Location | Organization |
| :----------------------------------------------------------: | :------------------------: | :----------: | :----------------------------: |
| 本报北京9月4日讯记者杨涌报道部分省区人民日报宣传发行工作座谈会9月3日在4日在京举行。 | 杨涌 | 北京,京 | 人民日报 |
| 《红楼梦》是中央电视台和中国电视剧制作中心根据中国古典文学名著《红楼梦》摄制于1987年的一部古装连续剧由王扶林导演周汝昌、王蒙、周岭等多位红学家参与制作。 | 王扶林,周汝昌,王蒙,周岭 | / | 中央电视台,中国电视剧制作中心 |
| 秦始皇兵马俑位于陕西省西安市1961年被国务院公布为第一批全国重点文物保护单位是世界八大奇迹之一。 | 秦始皇 | 陕西省西安市 | 国务院 |
英文样式范例为:
| Sentence | Person | Location | Organization | Miscellaneous | | Sentence | Person | Location | Organization | Miscellaneous |
| :----------------------------------------------------------: | :----------------------------------: | :---------------: | :-------------------------: | :-------------------: | | :----------------------------------------------------------: | :----------------------------------: | :---------------: | :-------------------------: | :-------------------: |

View File

@ -4,12 +4,14 @@ import torch
import logging import logging
import hydra import hydra
from hydra import utils from hydra import utils
from deepke.ae_st_tools import Serializer from deepke.attribution_extraction.standard.tools import Serializer
from deepke.ae_st_tools import _serialize_sentence, _convert_tokens_into_index, _add_pos_seq, _handle_attribute_data from deepke.attribution_extraction.standard.tools import _serialize_sentence, _convert_tokens_into_index, _add_pos_seq, _handle_attribute_data
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
from deepke.ae_st_utils import load_pkl, load_csv from deepke.attribution_extraction.standard.utils import load_pkl, load_csv
import deepke.ae_st_models as models import deepke.attribution_extraction.standard.models as models
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -11,9 +11,9 @@ from torch.utils.tensorboard import SummaryWriter
# self # self
import sys import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
import deepke.ae_st_models as models import deepke.attribution_extraction.standard.models as models
from deepke.ae_st_tools import preprocess , CustomDataset, collate_fn ,train, validate from deepke.attribution_extraction.standard.tools import preprocess , CustomDataset, collate_fn ,train, validate
from deepke.ae_st_utils import manual_seed, load_pkl from deepke.attribution_extraction.standard.utils import manual_seed, load_pkl
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

20
setup.py Normal file
View File

@ -0,0 +1,20 @@
from setuptools import setup, find_packages
setup(
name='deepke', # 打包后的包文件名
version='0.2.24', #版本号
keywords=["pip", "RE","NER","AE"], # 关键字
description='DeepKE 是基于 Pytorch 的深度学习中文关系抽取处理套件。', # 说明
long_description="client", #详细说明
license="Apache-2.0 License", # 许可
url='https://github.com/zjunlp/deepke',
author='ZJUNLP',
author_email='xx2020@zju.edu.cn',
include_package_data=True,
platforms="any",
package_dir={"": "src"},
packages=find_packages("src"),
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
)

2
src/deepke/__init__.py Normal file
View File

@ -0,0 +1,2 @@
from .attribution_extraction import *
from .relation_extraction import *

View File

@ -0,0 +1 @@
from .standard import *

View File

@ -0,0 +1,4 @@
from .models import *
from .module import *
from .tools import *
from .utils import *

View File

@ -1,6 +1,6 @@
import torch.nn as nn import torch.nn as nn
from . import BasicModule from . import BasicModule
from module import Embedding, RNN from ..module import Embedding, RNN
class BiLSTM(BasicModule): class BiLSTM(BasicModule):

View File

@ -1,9 +1,9 @@
import torch import torch
from . import BasicModule from . import BasicModule
from module import Embedding, CNN from ..module import Embedding, CNN
from module import Capsule as CapsuleLayer from ..module import Capsule as CapsuleLayer
from utils import seq_len_to_mask, to_one_hot from ..utils import seq_len_to_mask, to_one_hot
class Capsule(BasicModule): class Capsule(BasicModule):

View File

@ -1,10 +1,10 @@
import torch import torch
import torch.nn as nn import torch.nn as nn
from . import BasicModule from . import BasicModule
from module import Embedding from ..module import Embedding
from module import GCN as GCNBlock from ..module import GCN as GCNBlock
from utils import seq_len_to_mask from ..utils import seq_len_to_mask
class GCN(BasicModule): class GCN(BasicModule):

View File

@ -1,9 +1,9 @@
from torch import nn from torch import nn
from . import BasicModule from . import BasicModule
from module import RNN from ..module import RNN
from transformers import BertModel from transformers import BertModel
from utils import seq_len_to_mask from ..utils import seq_len_to_mask
class LM(BasicModule): class LM(BasicModule):

View File

@ -2,9 +2,9 @@ import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
from . import BasicModule from . import BasicModule
from module import Embedding, CNN from ..module import Embedding, CNN
from utils import seq_len_to_mask from ..utils import seq_len_to_mask
class PCNN(BasicModule): class PCNN(BasicModule):

View File

@ -1,9 +1,9 @@
import torch.nn as nn import torch.nn as nn
from . import BasicModule from . import BasicModule
from module import Embedding from ..module import Embedding
from module import Transformer as TransformerBlock from ..module import Transformer as TransformerBlock
from utils import seq_len_to_mask from ..utils import seq_len_to_mask
class Transformer(BasicModule): class Transformer(BasicModule):

View File

@ -3,7 +3,7 @@ from torch.utils.data import Dataset
import os import os
import sys import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
from deepke.utils import load_pkl from utils import load_pkl
def collate_fn(cfg): def collate_fn(cfg):

View File

@ -3,8 +3,8 @@ import logging
from collections import OrderedDict from collections import OrderedDict
from typing import List, Dict from typing import List, Dict
from transformers import BertTokenizer from transformers import BertTokenizer
from serializer import Serializer from .serializer import Serializer
from vocab import Vocab from .vocab import Vocab
import sys import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
from utils import save_pkl, load_csv from utils import save_pkl, load_csv

View File

@ -1,7 +1,7 @@
import torch import torch
import logging import logging
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from metrics import PRMetric from .metrics import PRMetric
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -0,0 +1 @@
from .standard import *

View File

Before

Width:  |  Height:  |  Size: 149 KiB

After

Width:  |  Height:  |  Size: 149 KiB

View File

Before

Width:  |  Height:  |  Size: 149 KiB

After

Width:  |  Height:  |  Size: 149 KiB

View File

@ -0,0 +1,4 @@
from .models import *
from .module import *
from .tools import *
from .utils import *

View File

@ -1,6 +1,6 @@
import torch.nn as nn import torch.nn as nn
from . import BasicModule from . import BasicModule
from module import Embedding, RNN from ..module import Embedding, RNN
class BiLSTM(BasicModule): class BiLSTM(BasicModule):

View File

@ -1,9 +1,9 @@
import torch import torch
from . import BasicModule from . import BasicModule
from module import Embedding, CNN from ..module import Embedding, CNN
from module import Capsule as CapsuleLayer from ..module import Capsule as CapsuleLayer
from utils import seq_len_to_mask, to_one_hot from ..utils import seq_len_to_mask, to_one_hot
class Capsule(BasicModule): class Capsule(BasicModule):

View File

@ -1,9 +1,9 @@
import torch import torch
import torch.nn as nn import torch.nn as nn
from . import BasicModule from . import BasicModule
from module import Embedding from ..module import Embedding
from module import GCN as GCNBlock from ..module import GCN as GCNBlock
from utils import seq_len_to_mask from ..utils import seq_len_to_mask
class GCN(BasicModule): class GCN(BasicModule):

View File

@ -1,8 +1,8 @@
from torch import nn from torch import nn
from . import BasicModule from . import BasicModule
from module import RNN from ..module import RNN
from transformers import BertModel from transformers import BertModel
from utils import seq_len_to_mask from ..utils import seq_len_to_mask
class LM(BasicModule): class LM(BasicModule):

View File

@ -2,8 +2,8 @@ import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
from . import BasicModule from . import BasicModule
from module import Embedding, CNN from ..module import Embedding, CNN
from utils import seq_len_to_mask from ..utils import seq_len_to_mask
class PCNN(BasicModule): class PCNN(BasicModule):

View File

@ -1,8 +1,8 @@
import torch.nn as nn import torch.nn as nn
from . import BasicModule from . import BasicModule
from module import Embedding from ..module import Embedding
from module import Transformer as TransformerBlock from ..module import Transformer as TransformerBlock
from utils import seq_len_to_mask from ..utils import seq_len_to_mask
class Transformer(BasicModule): class Transformer(BasicModule):

Some files were not shown because too many files have changed in this diff Show More