【发布时间】:2016-03-03 07:32:46
【问题描述】:
我想通过使用带有正则表达式的 NLTK 标记化来标记所有货币符号。
例如这是我的句子:
The price of it is $5.00.
The price of it is RM5.00.
The price of it is €5.00.
我使用了这种正则表达式模式:
pattern = r'''(['()""\w]+|\.+|\?+|\,+|\!+|\$?\d+(\.\d+)?%?)'''
tokenize_list = nltk.regexp_tokenize(sentence, pattern)
但正如我们所见,它只考虑 $。
我尝试按照What is regex for currency symbol? 中的说明使用\p{Sc},但它仍然不适合我。
【问题讨论】:
-
我尝试使用相同的方式,但仍然无法得到正确的答案。 @b3000
-
您能否展示您尝试使用
\p{Sc}以及为什么它不起作用?
标签: python regex nlp nltk tokenize