Skip to content

Commit

Permalink
Dev (#2)
Browse files Browse the repository at this point in the history
* update test and travis

* fixed encoding error when opening file with python2
  • Loading branch information
DevRoss authored Sep 1, 2019
1 parent 58163ce commit 84a467c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: python
python:
- "2.7"
- "3.5"
- "3.6"
install:
Expand Down
4 changes: 2 additions & 2 deletions bert_slot_tokenizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# Created by Ross on 2019/7/31
import json

import io
from bert_slot_tokenizer.bert_tokenizer import tokenization


Expand Down Expand Up @@ -31,7 +31,7 @@ def __init__(self, vacab_file, do_lower_case=True):

@staticmethod
def parse_json(file):
with open(file, 'r', encoding='utf-8') as f:
with io.open(file, 'r', encoding='utf-8') as f:
data = json.load(f)

texts = []
Expand Down
4 changes: 2 additions & 2 deletions bert_slot_tokenizer/bert_tokenizer/tokenization.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import collections
import re
import unicodedata

import io
import six


Expand Down Expand Up @@ -134,7 +134,7 @@ def load_vocab(vocab_file):
index = 0

# with tf.gfile.GFile(vocab_file, "r") as reader: # modified here
with open(vocab_file, "r") as reader:
with io.open(vocab_file, "r", encoding='utf-8') as reader:
while True:
token = convert_to_unicode(reader.readline())
if not token:
Expand Down
2 changes: 1 addition & 1 deletion bert_slot_tokenizer/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__version__ = "0.2.0"
__version__ = "0.2.1"


def main():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def get_version():
main_file = os.path.join(CURDIR, "bert_slot_tokenizer", "main.py")
_version_re = re.compile(r"__version__\s+=\s+(?P<version>.*)")
with open(main_file, "r", encoding="utf8") as f:
with io.open(main_file, "r", encoding="utf8") as f:
match = _version_re.search(f.read())
version = match.group("version") if match is not None else '"unknown"'
return str(ast.literal_eval(version))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_import(self):

def test_project(self):

sc = SlotConverter('test_data/example_vocab.txt', do_lower_case=True)
sc = SlotConverter('tests/test_data/example_vocab.txt', do_lower_case=True)

if six.PY3:
token1, iob_slot1 = sc.convert2iob(UnitTests.test_case1['text'], UnitTests.test_case1['slots'])
Expand Down

0 comments on commit 84a467c

Please sign in to comment.