我使用吡咯烷酮来标记文本。通过默认设置,令牌中的任何空格(例如,电话号码、分数)都会被转换为U+00A0 (不破空间),编码为在UTF-8。我朗读我应该把normalizeSpace设置为False。我怎么才能用吡咯烷酮做这个呢?
下面是我使用的代码:
'''
From https://github.com/smilli/py-corenlp/blob/master/example.py
'''
from pycorenlp import StanfordCoreNLP
import pprint
if __name__ == '__main__':
nlp = StanfordCoreNLP('http://localhost:9000')
text = 'I ate 1 1/2 lobster'
output = nlp.annotate(text, properties={
'annotators': 'tokenize,ssplit',
'outputFormat': 'json',
'timeout': '50000',
'PTBTokenizer.normalizeSpace': 'false'
#'normalizeSpace': 'false'
})
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(output)
print("output['sentences'][0]['tokens'][2]: {0}".
format(output['sentences'][0]['tokens'][2]))输出包含u'word': u'1\xa01/2',这表明空格被非破缺的空格所取代,我不想这样做。
斯坦福核心NLP服务器的启动使用如下:
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer 9000我尝试在作为参数传递给properties的nlp.annotate()字典中添加以下内容,但没有成功
'tokenizer.normalizeSpace': 'false''tokenize.normalizeSpace': 'false''normalizeSpace': 'false''PTBTokenizer.normalizeSpace': 'false'发布于 2020-08-07 07:22:17
以下是使用它的方法:
“令牌化”选项:“normalizeSpace=False”
https://stackoverflow.com/questions/39155296
复制相似问题