여러 단어로 된 텍스트가 있습니다. 단어의 모든 파생 확장을 제거하고 싶습니다. 예를 들어 확장 기능 -ed -ing을 제거하고 초기 동사를 유지하려고합니다. 본인이 확인 또는 확인을 계속하는 경우 파이썬에서 메서드 스트립을 발견했습니다.이 스트립은 문자열의 처음이나 끝에서 특정 문자열을 제거하지만 정확히 원하는 것은 아닙니다. 파이썬에서 그런 일을하는 라이브러리가 있습니까?파이썬에서 단어 확장자를 제거하십시오.
나는 제안 된 게시물에서 코드를 수행하려고 시도했으며 여러 단어로 이상한 트리밍을 발견했습니다. 예를 들어, 나는 다음과 같은 텍스트
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"""
있어 그리고 다음 코드의 사용 후에는 beauti에 아름답고 인용 트림 예를 들어
we goin all the way
think ive caught on to a realli good song im write
lookin back on the stuff i did when i wa lil make me laughh
i sneez on the beat and the beat got sicka
nashnewvideo
home
so much respect for thi man truli amaz guy
what a day
rt have some food with
voicesav christina
im gunna make the sign my signatur pose
you all are so beauti soooo beauti
thought that wa a realli awesom quot
beauti thing dont ask for attent
(또한 나는 비 라틴 문자와 URL을 제거) 진짜로 realli에 말하십시오.
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"
네 줄기 내가 찾고 있던 단어입니다. 나는 제안 된 게시물의 예제를 시도했지만 심하게 말을 트리밍 것으로 나타났습니다. –