Ich versuche Interpunktion aus dem Text unten zu entfernen. Ich konvertiere den Text in Unicode, um später mögliche Kodierungsprobleme zu vermeiden.übersetzen Funktion und Unicode-Konvertierung
import string
st = "I absolutely go incredibly far. Zach went fast over crab sand land.\n\nThis is a new paragraph. This is the second sentence in that paragraph. This exsquisite utterance is indubitably the third sentence of this fine text.\n\nPlagiarism detection can be operationalized by decomposing a document into natural sections, such as sentences, chapters, or topically related blocks, and analyzing the variance of stylometric features for these sections. In this regard the decision problems in Sect. 1.2 are of decreasing complexity: instances of AVFIND are comprised of both a selection problem (finding suspicious sections) and an AVOUTLIER problem; instances of AVBATCH are a restricted variant of AVOUTLIER since one has the additional knowledge that all elements of a batch are (or are not) outliers at the same time."
st = unicode(st, errors = 'ignore')
for word in st.split(' '):
wd = word.lower().translate(string.maketrans("",""), string.punctuation)
print wd
Allerdings verursacht die Übersetzungsfunktion unerklärlicherweise einen Fehler über die Anzahl der Argumente.
TypeError: translate() takes exactly one argument (2 given)
Das Entfernen des Unicode-Konvertierungsschritts stellt die korrekte Ausführung sicher, ist jedoch unabdingbar und ebenso die Übersetzungsfunktion. Wie kann ich mein Ziel fehlerfrei erreichen und beide Funktionen behalten?