This commit is contained in:
xxupiano 2021-09-25 17:09:16 +08:00
parent cda56a6ace
commit d2c7e7eb15
54 changed files with 31 additions and 34 deletions

View File

@ -80,24 +80,14 @@ DeepKE 提供了多种知识抽取模型。
2. NER
数据为txt文件
中文样式范例为:
数据为txt文件样式范例为
| Sentence | Person | Location | Organization |
| :----------------------------------------------------------: | :------------------------: | :----------: | :----------------------------: |
| :----------------------------------------------------------: | :------------------------: | :----------: | :----------------------------: |
| 本报北京9月4日讯记者杨涌报道部分省区人民日报宣传发行工作座谈会9月3日在4日在京举行。 | 杨涌 | 北京,京 | 人民日报 |
| 《红楼梦》是中央电视台和中国电视剧制作中心根据中国古典文学名著《红楼梦》摄制于1987年的一部古装连续剧由王扶林导演周汝昌、王蒙、周岭等多位红学家参与制作。 | 王扶林,周汝昌,王蒙,周岭 | / | 中央电视台,中国电视剧制作中心 |
| 秦始皇兵马俑位于陕西省西安市1961年被国务院公布为第一批全国重点文物保护单位是世界八大奇迹之一。 | 秦始皇 | 陕西省西安市 | 国务院 |
英文样式范例为:
| Sentence | Person | Location | Organization | Miscellaneous |
| :----------------------------------------------------------: | :----------------------------------: | :---------------: | :-------------------------: | :-------------------: |
| Australian Tom Moody took six for 82 but Chris Adams, 123, and Tim O'Gorman, 109, took Derbyshire to 471 and a first innings lead of 233. | Tom Moody, Chris Adams, Tim O'Gorman | / | Derbysire | Australian |
| Irene, a master student in Zhejiang University, Hangzhou, is traveling in Warsaw for Chopin Music Festival. | Irene | Hangzhou, Warsaw | Zhejiang University | Chopin Music Festival |
| It was one o'clock when we left Lauriston Gardens and Sherlock Holmes led me to Metropolitan Police Service. | Sherlock Holmes | Lauriston Gardens | Metropolitan Police Service | / |
具体流程请进入详细的README中
**[STANDARD](https://github.com/zjunlp/deepke/blob/test_new_deepke/example/ner/standard)**

View File

@ -1,6 +1,6 @@
# 快速上手
## 快速上手
## 环境依赖
### 环境依赖
> python >= 3.7
@ -9,10 +9,11 @@
- seqeval==0.0.5
- tqdm==4.31.1
- nltk==3.4.5
- deepke
## 克隆代码
### 克隆代码
```
git clone git@github.com:zjunlp/DeepKE.git
@ -20,7 +21,7 @@ git clone git@github.com:zjunlp/DeepKE.git
## 使用pip安装
### 使用pip安装
首先创建python虚拟环境再进入虚拟环境
@ -28,9 +29,9 @@ git clone git@github.com:zjunlp/DeepKE.git
## 使用数据进行训练预测
### 使用数据进行训练预测
- 存放数据:在`data`文件夹下存放数据。主要有三个文件:
- 存放数据:在`data`文件夹下存放数据。主要有三个文件:
- `train.txt`:存放训练数据集
- `valid.txt`:存放验证数据集
- `test.txt`:存放测试数据集
@ -40,7 +41,9 @@ git clone git@github.com:zjunlp/DeepKE.git
- 进行预测 ```python predict.py```
## 模型内容
BERT
### 模型内容
1、BERT

View File

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

View File

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

View File

@ -0,0 +1,2 @@
from .BasicNer import Ner
from .InferBert import Ner

View File

@ -0,0 +1,3 @@
from .dataset import *
from .preprocess import *
from .trainer import *

View File

@ -2,16 +2,13 @@ class InputExample(object):
"""A single training/test example for simple sequence classification."""
def __init__(self, guid, text_a, text_b=None, label=None):
"""Constructs a InputExample.
Args:
guid: Unique id for the example.
text_a: string. The untokenized text of the first sequence. For single
sequence tasks, only this sequence must be specified.
text_b: (Optional) string. The untokenized text of the second sequence.
Only must be specified for sequence pair tasks.
label: (Optional) string. The label of the example. This should be
specified for train and dev examples, but not for test examples.
"""
Constructs a InputExample.
Args:
guid(string): Unique id for the example.
text_a(string): The untokenized text of the first sequence. For single sequence tasks, only this sequence must be specified.
text_b(string, optional): The untokenized text of the second sequence. Only must be specified for sequence pair tasks.
label(string, optional): The label of the example. This should be specified for train and dev examples, but not for test examples.
"""
self.guid = guid
self.text_a = text_a

View File

@ -1,6 +1,6 @@
import sys
sys.path.append("..")
from models.BERTNER import Ner
from models.InferBert import Ner
model = Ner("out_ner/")
text= "Irene, a master student in Zhejiang University, Hangzhou, is traveling in Warsaw for Chopin Music Festival."

View File

@ -23,7 +23,7 @@ from seqeval.metrics import classification_report
from dataset import *
from preprocess import *
sys.path.append("..")
from models.NER import Ner
from tools.BasicNer import Ner
def main():