标签: punctuation

SOLR在搜索时忽略逗号和其他标点符号

我想通过查询100000(或仅查询100,000)来搜索100,000和100000.
有可能像那样搜索.

执行此操作的目的是,用户可以在任何地方添加逗号或根本不添加逗号,但无论如何都应搜索字符串(100,000或100000)...

search solr punctuation

0
推荐指数
1
解决办法
2863
查看次数

使用 string.punctuation python 时出错

我尝试在 python 中使用 string.punctuation 函数。我在 python 3.5 版本中这样做。这是我的以下代码:

import string
def check(text):
    x=set(text.punctuation())
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

'str' object has no attribute 'punctuation'
Run Code Online (Sandbox Code Playgroud)

请帮助正确使用 this 的方法。我什至尝试使用 ispunct() 功能。

我尝试解决这个问题,如下面的链接所示,但无法弄清楚。

在 Python 中从字符串中去除标点符号的最佳方法

python string punctuation python-3.x

0
推荐指数
1
解决办法
7418
查看次数

如何从C中的字符串中删除逗号

假设我有一个"10,5,3"字符串如何摆脱逗号,所以字符串只是"10 5 3"?我应该使用strtok吗?

c string punctuation

0
推荐指数
1
解决办法
4023
查看次数

删除停用词和string.punctuation

我无法弄清楚为什么这不起作用:

import nltk
from nltk.corpus import stopwords
import string

with open('moby.txt', 'r') as f:
    moby_raw = f.read()
    stop = set(stopwords.words('english'))
    moby_tokens = nltk.word_tokenize(moby_raw)
    text_no_stop_words_punct = [t for t in moby_tokens if t not in stop or t not in string.punctuation]

    print(text_no_stop_words_punct)
Run Code Online (Sandbox Code Playgroud)

看着输出我有这个:

[...';', 'surging', 'from', 'side', 'to', 'side', ';', 'spasmodically', 'dilating', 'and', 'contracting',...]
Run Code Online (Sandbox Code Playgroud)

似乎标点符号仍在那里.我做错了什么?

python nltk punctuation

0
推荐指数
1
解决办法
5536
查看次数

标签 统计

punctuation ×4

python ×2

string ×2

c ×1

nltk ×1

python-3.x ×1

search ×1

solr ×1