Textverarbeitung mit Python

Quiz 2

Schreiben Sie bitte ein Programm, das die folgende Aufgabe löst und reichen Sie das Resultat bitte bei Miriam Butt per email ein.


Aufgabe: Schreiben Sie ein Programm, das das 1. Kapitel von Peter Pan nimmt und folgendes berechnet und dem User das Resultat der Berechnung kommuniziert.

  1. Die Gesamtanzahl der Funktionsworte/stopwords (mittels unten angegebener Stopliste)
  2. Die Gesamtanzahl der Inhaltsworte
  3. Die Gesamtanzahl alle Worte
  4. Den Prozentsatz von Funktionsworten, die nur einmal im Text vorkommen in Bezug auf die Anzahl der Funktionsworte.
  5. Den Prozentsatz von Inhaltsworten, die nur einmal im Text vorkommen in Bezug auf die Gesamtzahl der Worte.
  6. Die Anzahl der Inhaltsworte, die nur zweimal im Text vorkommen.
  7. Drucken Sie alle Inhaltsworte in alphabetisch umgekehrter Reihenfolge in eine Datei und sagen Sie dem User, wie diese Datei heisst.

Um den Prozentsatz zu errechnen benutzen Sie eine Formel wie: (zahl1/float(zahl2))*100

Stoplist from NLTK
['i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you',
'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his',
'himself', 'she', 'her', 'hers', 'herself', 'it', 'its', 'itself',
'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which',
'who', 'whom', 'this', 'that', 'these', 'those', 'am', 'is', 'are',
'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having',
'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if',
'or', 'because', 'as', 'until', 'while', 'of', 'at', 'by', 'for',
'with', 'about', 'against', 'between', 'into', 'through', 'during',
'before', 'after', 'above', 'below', 'to', 'from', 'up', 'down', 'in',
'out', 'on', 'off', 'over', 'under', 'again', 'further', 'then',
'once', 'here', 'there', 'when', 'where', 'why', 'how', 'all', 'any',
'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no',
'nor', 'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's',
't', 'can', 'will', 'just', 'don', 'should', 'now']


Ende