Giter Club home page Giter Club logo

Comments (10)

yyHaker avatar yyHaker commented on May 29, 2024 5

I found this question can be solved as below:

in utils.py change as follows:

def test_ner(results, path):
"""
Run perl script to evaluate model
"""
output_file = os.path.join(path, "ner_predict.utf8")
with open(output_file, "w", encoding='utf8') as f:
to_write = []
for block in results:
for line in block:
to_write.append(line + "\n")
to_write.append("\n")
f.writelines(to_write)
eval_lines = return_report(output_file)
return eval_lines

The reason is that only when you write the file use "utf8" can you open the file use "utf8", and it have nothing to do with the tensorflow version.

from chinesener.

lengxia avatar lengxia commented on May 29, 2024

请问你解决了吗?

from chinesener.

janesunflower avatar janesunflower commented on May 29, 2024

还没有,悲剧。

from chinesener.

yyHaker avatar yyHaker commented on May 29, 2024

What's wrong with it?My tensorflow is 1.4.

from chinesener.

lengxia avatar lengxia commented on May 29, 2024

@yyHaker ,good job, it help me solved this problem,thanks

from chinesener.

ylwctyt avatar ylwctyt commented on May 29, 2024

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 0: invalid start byte

2018-02-02 12:08:27,160 - log\train.log - INFO - iteration:1 step:1000/1044, NER loss: 5.380470
2018-02-02 12:08:36,132 - log\train.log - INFO - evaluate:dev
Traceback (most recent call last):
运行到这还是那个编码问题,你们遇到了吗?

from chinesener.

yyHaker avatar yyHaker commented on May 29, 2024

This is still the encoding problem, you can debug to find the encoding problem

from chinesener.

SanSLee avatar SanSLee commented on May 29, 2024

@yyHaker Thanks!

from chinesener.

LiXuanming avatar LiXuanming commented on May 29, 2024

This is a encoding problem. If you coding in Linux ,please trans the coding by Notepad++.But ,if you coding in Windows ,Please use this :
import codecs
with codecs.open(filename, 'r', 'utf-8') as f:
#this is your process

from chinesener.

 avatar commented on May 29, 2024

it is very easy. You just need to change the 'utf-8' to 'gbk' in the 'return_report' of 'utils.py'.

from chinesener.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.