我有一篇有几个字的课文。我要删除所有派生词的扩展名。例如,我想删除extensions-ed-ing并保留初始动词。如果我有verifying或verified to keep verify f.e.我在python中找到了一个方法strip,它从字符串的开头或结尾删除了一个特定的字符串,但这不是我想要的。在python中有没有这样的库?在
我试着执行post中的代码,我注意到有几个单词出现了一个奇怪的删减。例如,我有下面的文字We goin all the way βπƒβ΅οΈβ΅οΈ
Think ive caught on to a really good song ! Im writing π
Lookin back on the stuff i did when i was lil makes me laughh π‚
I sneezed on the beat and the beat got sicka
#nashnewvideo http://t.co/10cbUQswHR
Homee βοΈβοΈβοΈπ΄
So much respect for this man , truly amazing guy βοΈ @edsheeran
http://t.co/DGxvXpo1OM"
What a day ..
RT @edsheeran: Having some food with @ShawnMendes
#VoiceSave christina π
Im gunna make the βοΈ sign my signature pose
You all are so beautiful .. π soooo beautiful
Thought that was a really awesome quote
Beautiful things don't ask for attention"""
在使用了以下代码之后(我还删除了非拉丁字符和url)
^{pr2}$
例如,它对美的修饰,对真实的引用。我的代码如下:reader = csv.reader(f)
print doc
for row in reader:
text = re.sub(r"(?:\@|https?\://)\S+", "", row[2])
filter(lambda x: x in string.printable, text)
out = text.translate(string.maketrans("",""), string.punctuation)
out = re.sub("[\W\d]", " ", out.strip())
word_list = out.split()
str1 = ""
for verb in word_list:
verb = verb.lower()
verb = nltk.stem.porter.PorterStemmer().stem_word(verb)
str1 = str1+" "+verb+" "
list.append(str1)
str1 = "\n"