Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#59 from 0YuanZhang0/seq_tag
Browse files Browse the repository at this point in the history
Seq tag
  • Loading branch information
xyzhou-puck authored Apr 27, 2020
2 parents 2c6d409 + 0e5d4c5 commit 1f6a3af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/sequence_tagging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Sequence Tagging,是一个序列标注模型,模型可用于实现,分词

#### 1.PaddlePaddle 安装

本项目依赖 PaddlePaddle 1.7 及以上版本和PaddleHub 1.0.0及以上版本 ,PaddlePaddle安装请参考官网 [快速安装](http://www.paddlepaddle.org/paddle#quick-start),PaddleHub安装参考 [PaddleHub](https://github.com/PaddlePaddle/PaddleHub)
本项目依赖 PaddlePaddle 1.8 及以上版本和PaddleHub 1.0.0及以上版本 ,PaddlePaddle安装请参考官网 [快速安装](http://www.paddlepaddle.org/paddle#quick-start),PaddleHub安装参考 [PaddleHub](https://github.com/PaddlePaddle/PaddleHub)

> Warning: GPU 和 CPU 版本的 PaddlePaddle 分别是 paddlepaddle-gpu 和 paddlepaddle,请安装时注意区别。
Expand Down
8 changes: 7 additions & 1 deletion examples/sequence_tagging/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io
import os
import sys
import six
import math
import argparse
import numpy as np
Expand Down Expand Up @@ -71,7 +72,12 @@ def main(args):
word_len = length[i]
word_ids = results[i][:word_len]
tags = [dataset.id2label_dict[str(id)] for id in word_ids]
f.write("\002".join(tags) + "\n")
if six.PY3:
tags = [bytes(tag, encoding="utf8") for tag in tags]
out = b"\002".join(tags) + b"\n"
f.write(out)
else:
f.write("\002".join(tags) + "\n")


if __name__ == '__main__':
Expand Down
1 change: 0 additions & 1 deletion examples/sequence_tagging/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import io
import os
import leveldb
import numpy as np
import shutil
from functools import partial
Expand Down

0 comments on commit 1f6a3af

Please sign in to comment.