Skip to content

Commit ac88ae8

Browse files
authoredFeb 27, 2021
Merge pull request SeanLee97#24 from SeanLee97/feature/tensorflow2x
compatible with tensorflow 2.x
2 parents c3b882e + bfea49b commit ac88ae8

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[![pypi](https://img.shields.io/pypi/v/xmnlp?style=for-the-badge)](https://pypi.org/project/xmnlp/)
1212
[![pypi downloads](https://img.shields.io/pypi/dm/xmnlp?style=for-the-badge)](https://pypi.org/project/xmnlp/)
1313
[![python version](https://img.shields.io/badge/python-3.6,3.7,3.8-orange.svg?style=for-the-badge)]()
14-
[![tensorflow version](https://img.shields.io/badge/tensorflow-1.13,1.14,1.15-orange.svg?style=for-the-badge)]()
14+
[![tensorflow version](https://img.shields.io/badge/tensorflow-1.14+,2.x-orange.svg?style=for-the-badge)]()
1515
[![support os](https://img.shields.io/badge/os-linux%2C%20win%2C%20mac-yellow.svg?style=for-the-badge)]()
1616
[![GitHub license](https://img.shields.io/github/license/SeanLee97/xmnlp?style=for-the-badge)](https://github.com/SeanLee97/xmnlp/blob/master/LICENSE)
1717

@@ -47,7 +47,7 @@
4747
- [并行分词:seg_parallel](#usage-seg_parallel)
4848
- [词性标注:tag](#usage-tag)
4949
- [并行词性标注:tag_parallel](#usage-tag_parallel)
50-
- [命名体识别:ner](#usage-ner)
50+
- [命名体识别ner](#usage-ner)
5151
- [并行命名体识别:ner_parallel](#usage-ner_parallel)
5252
- [关键词提取:keyword](#usage-keyword)
5353
- [并行关键词提取:keyword_parallel](#usage-keyword_parallel)

‎requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
tokenizers>0.9.0,<=0.10.1
2-
tensorflow>=1.13.0,<2.0.0
2+
tensorflow>=1.14.0,<=2.4.1
33
numpy>=1.18.0,<1.20.1

‎xmnlp/checker/checker.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
import os
2323

2424
import numpy as np
25-
import tensorflow as tf
25+
try:
26+
import tensorflow.compat.v1 as tf
27+
except ImportError:
28+
import tensorflow as tf
2629
from tokenizers import BertWordPieceTokenizer
2730

2831
import xmnlp

‎xmnlp/lexical/lexical_model.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
import json
2424

2525
import numpy as np
26-
import tensorflow as tf
26+
try:
27+
import tensorflow.compat.v1 as tf
28+
except ImportError:
29+
import tensorflow as tf
2730
from tokenizers import BertWordPieceTokenizer
2831

2932
from xmnlp.utils import rematch

‎xmnlp/sentiment/sentiment_model.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
import os
1717

1818
import numpy as np
19-
import tensorflow as tf
19+
try:
20+
import tensorflow.compat.v1 as tf
21+
except ImportError:
22+
import tensorflow as tf
2023
from tokenizers import BertWordPieceTokenizer
2124

2225

0 commit comments

Comments
 (0)
Please sign in to comment.