""" Computerlinguistische
Gelegenheitsprogrammierung """
venue = "StuTS 56, November 2014, Hamburg"
author = {name: "Esther Seyffarth",
mail: "esther.seyffarth@gmail.com",
twitter: "@ojahnn",
blog: "www.enigmabrot.de"}
1
2
3
4
5
6
7
8
17.11.2014 StuTS 56, Esther Seyffarth 2
content.append("Einleitung: Voraussetzungen")
content.append("Beispielprojekte")
content.append("NaNoGenMo")
content.append("Diskussion")
content = [] # Inhalt des Vortrags
"""Einleitung: Voraussetzungen"""
17.11.2014 StuTS 56, Esther Seyffarth 3
Grundkenntnisse im Programmieren
• Grundkenntnisse in Natural
Language Processing:
• Dateien lesen und schreiben
• Strings bearbeiten
• Tokenisierung, POS-Tagging, Statistik,
N-Gramme…
Ideen für Projekte
• Inspiration durch Diskussionen in
Communities: Twitter, Foren,
Meatspace…
• Tagungen: TaCOS, CLUNC, StuTS…
• Blogs, Seminare, Vorträge,
Podcasts…
"""Beispielprojekte""" # Twitterbots
17.11.2014 StuTS 56, Esther Seyffarth 4
"""Beispielprojekte""" # Twitterbots
17.11.2014 StuTS 56, Esther Seyffarth 5
17.11.2014 StuTS 56, Esther Seyffarth 6
"""Beispielprojekte""" # Twitterbots
17.11.2014 StuTS 56, Esther Seyffarth 7
"""Beispielprojekte""" # Twitterbots
• Verwendetes Modul: Tweepy
• Wichtig: Unbedingt eine Verzögerung einbauen!
• Code verfügbar unter:
https://github.com/ojahnn/stuts56/tree/master/YouKnowWhatBot
17.11.2014 StuTS 56, Esther Seyffarth 8
"""Beispielprojekte""" # Twitterbots
17.11.2014 StuTS 56, Esther Seyffarth 9
"""Beispielprojekte""" # CMU Dict,
Machine
Shakespeare
• CMU Dictionary:
a machine-readable
pronunciation dictionary for
North American English that
contains over 125,000 words
and their transcriptions
http://www.speech.cs.cmu.edu/cgi
-bin/cmudict
17.11.2014 StuTS 56, Esther Seyffarth 10
"""Beispielprojekte""" # CMU Dict
EXAMINED IH0 G Z AE1 M AH0 N D
EXAMINER IH0 G Z AE1 M AH0 N ER0
EXAMINER'S EH0 G Z AE1 M AH0 N ER0 Z
EXAMINERS IH0 G Z AE1 M IH0 N ER0 Z
EXAMINERS' IH0 G Z AE1 M IH0 N ER0 Z
EXAMINES IH0 G Z AE1 M AH0 N Z
EXAMINING IH0 G Z AE1 M IH0 N IH0 NG
EXAMPLE IH0 G Z AE1 M P AH0 L
EXAMPLES IH0 G Z AE1 M P AH0 L Z
EXAMS IH0 G Z AE1 M Z
EXAR EH1 K S ER0
EXASPERATE IH0 G Z AE1 S P ER0 EY2 T
39518
39519
39520
39521
39522
39523
39524
39525
39526
39527
39528
39529
Mit so einem Datensatz müsste es doch möglich sein, automatisch zu dichten…
• Alle 153 Shakespeare-Sonette einlesen und mithilfe
des CMU Dictionary nach Endreimen sortieren
• Zufällige Kombination sich reimender Zeilen zu
einem neuen Gedicht zusammensetzen
• …
17.11.2014 StuTS 56, Esther Seyffarth 11
"""Beispielprojekte""" # Machine Shakespeare
Why Is My Verse So Barren Of New Pride?
That You Were Once Unkind Befriends Me Now.
O, For My Sake Do You With Fortune Chide
When Forty Winters Shall Besiege Thy Brow.
What Is Your Substance, Whereof Are You Made?
Unthrifty Loveliness, Why Dost Thou Spend,
Whilst I Alone Did Call Upon Thy Aid?
Being Your Slave, What Should I Do But Tend?
Where Art Thou, Muse, That Thou Forget'st So Long?
Thy Glass Will Show Thee How Thy Beauties Wear.
O! Call Not Me To Justify The Wrong!
Alas! 'Tis True, I Have Gone Here And There.
O Me! What Eyes Hath Love Put In My Head?
Weary With Toil, I Haste Me To My Bed.
17.11.2014 StuTS 56, Esther Seyffarth 12
76
120
111
2
53
4
79
57
100
77
139
110
148
37
"""Beispielprojekte""" # Machine Shakespeare
17.11.2014 StuTS 56, Esther Seyffarth 13
• Siehe hierzu auch:
• http://www.garysieling.com/blog/rhyming-with-nlp-and-shakespeare
(Ersetzung der Endreime durch andere, passende Wörter)
• http://gnoetrydaily.wordpress.com/2010/08/23/break-bear-presenteth-pos-sonnet-line-
templates/
(POS-basierter Sonettgenerator ohne Reime)
"""Beispielprojekte""" # Machine Shakespeare
17.11.2014 StuTS 56, Esther Seyffarth 14
"""Beispielprojekte""" # Gronseuns
17.11.2014 StuTS 56, Esther Seyffarth 15
• Buchstaben-N-Gramme als charakteristisches Merkmal einer Einzelsprache
• Statistik auslesen aus Wikipedia-Artikeln
"""Beispielprojekte""" # Gronseuns
Wenn wir Texten anhand ihrer
Buchstaben-N-Gramme die richtige
Sprache zuordnen können…
… dann können wir doch sicher auch
neue Texte generieren, solange wir uns
an die statistischen Vorgaben der
jeweiligen Sprache halten?
17.11.2014 StuTS 56, Esther Seyffarth 16
• "Druchlauchere von keln dienempfungelungter zurn Komme ineteritzt."
• "Surs qui bille gue, l'étant etiqui l'hieur férimenté abes peupe ger les; il
voire vitivec le, de bes leva ne te l'emeuvec Émie."
• "Zicats eeng. De onden heeg geze bilgezekallubs. Buurcen een Nieuwet-
Werleid Amstadstade KLM."
• "Majoin the was fider of a le oven thavout was ition helet, thation he clas
servativeat be Prip, aliame Mary ould's elso broaccer tonfluent."
"""Beispielprojekte""" # Gronseuns
17.11.2014 StuTS 56, Esther Seyffarth 17
• "Druchlauchere von keln dienempfungelungter zurn Komme ineteritzt."
• "Surs qui bille gue, l'étant etiqui l'hieur férimenté abes peupe ger les; il
voire vitivec le, de bes leva ne te l'emeuvec Émie."
• "Zicats eeng. De onden heeg geze bilgezekallubs. Buurcen een Nieuwet-
Werleid Amstadstade KLM."
• "Majoin the was fider of a le oven thavout was ition helet, thation he clas
servativeat be Prip, aliame Mary ould's elso broaccer tonfluent."
# de
# fr
# nl
# en
"""Beispielprojekte""" # Gronseuns
17.11.2014 StuTS 56, Esther Seyffarth 18
"""Beispielprojekte""" # Textonyme
17.11.2014 StuTS 56, Esther Seyffarth 19
• Automatisches Finden von Textonympaaren oder –
gruppen
• Als Korpus z. B. wieder Wikipedia verwenden
• Für jedes Wort die Tastenfolge bestimmen, mit der
es in T9 geschrieben wird; dann Wörter nach ihren
Zahlencodes sortieren
• Beispielpaare:
• any/cow, year/webs, defeat/effect
• Beruf/beste, Kaiser/Jahres, weihte/zeigte
"""Beispielprojekte""" # Textonyme
17.11.2014 StuTS 56, Esther Seyffarth 20
He inches me up, age-rating ambient hate.
If images of us aid saving ancient gate
sites, they win asserted summer blood, soft done.
River! View who arrested stones alone. Poet food...
Slaves noted cape-serving good. Line: none.
Plates moved, bare, resting, home. Kind mood.
"""Beispielprojekte""" # Textonyme
17.11.2014 StuTS 56, Esther Seyffarth 21
He inches me up, age-rating ambient hate.
If images of us aid saving ancient gate
43 462437 63 87 243 728464 2624368 4283
sites, they win asserted summer blood, soft done.
River! View who arrested stones alone. Poet food...
74837 8439 946 27737833 786637 25663 7638 3663
Slaves noted cape-serving good. Line: none.
Plates moved, bare, resting, home. Kind mood.
752837 66833 2273 7378464 4663 5463 6663
"""Beispielprojekte""" # Textonyme
17.11.2014 StuTS 56, Esther Seyffarth 22
"""NaNoGenMo""" # National Novel
Generation Month
17.11.2014 StuTS 56, Esther Seyffarth 23
• Ein Projekt von Darius Kazemi
https://github.com/dariusk/NaNoGenMo-2014
"""NaNoGenMo""" # Buchgenerierung
17.11.2014 StuTS 56, Esther Seyffarth 24
• 50.000 Meows
https://github.com/dariusk/NaNoGenMo-2014/issues/50
• Generiertes Voynich-Manuskript
https://github.com/dariusk/NaNoGenMo-2014/issues/45
• How Hannah Solved The Twelve-Disk Tower of Hanoi
https://github.com/dariusk/NaNoGenMo-2014/issues/76
• Twide and Twejudice
https://github.com/dariusk/NaNoGenMo-2014/issues/51
"""NaNoGenMo""" # Highlights (1/2)
17.11.2014 StuTS 56, Esther Seyffarth 25
• Recipe Book Generator
https://github.com/dariusk/NaNoGenMo-2014/issues/87
• Generated Detective
https://github.com/dariusk/NaNoGenMo-2014/issues/70
• A diary of every minute of the day
https://github.com/dariusk/NaNoGenMo-2014/issues/89
• … und meine Beiträge:
https://github.com/dariusk/NaNoGenMo-2014/issues/46
"""NaNoGenMo""" # Highlights (2/2)
17.11.2014 StuTS 56, Esther Seyffarth 26
diskussion = input("Fragen, Anregungen, Ideen? ")
# Die Folien zum Herunterladen findet ihr unter http://www.enigmabrot.de/stuts56.pdf

Computerlinguistische Gelegenheitsprogrammierung

  • 1.
    """ Computerlinguistische Gelegenheitsprogrammierung """ venue= "StuTS 56, November 2014, Hamburg" author = {name: "Esther Seyffarth", mail: "esther.seyffarth@gmail.com", twitter: "@ojahnn", blog: "www.enigmabrot.de"} 1 2 3 4 5 6 7 8
  • 2.
    17.11.2014 StuTS 56,Esther Seyffarth 2 content.append("Einleitung: Voraussetzungen") content.append("Beispielprojekte") content.append("NaNoGenMo") content.append("Diskussion") content = [] # Inhalt des Vortrags
  • 3.
    """Einleitung: Voraussetzungen""" 17.11.2014 StuTS56, Esther Seyffarth 3 Grundkenntnisse im Programmieren • Grundkenntnisse in Natural Language Processing: • Dateien lesen und schreiben • Strings bearbeiten • Tokenisierung, POS-Tagging, Statistik, N-Gramme… Ideen für Projekte • Inspiration durch Diskussionen in Communities: Twitter, Foren, Meatspace… • Tagungen: TaCOS, CLUNC, StuTS… • Blogs, Seminare, Vorträge, Podcasts…
  • 4.
  • 5.
  • 6.
    17.11.2014 StuTS 56,Esther Seyffarth 6 """Beispielprojekte""" # Twitterbots
  • 7.
    17.11.2014 StuTS 56,Esther Seyffarth 7 """Beispielprojekte""" # Twitterbots
  • 8.
    • Verwendetes Modul:Tweepy • Wichtig: Unbedingt eine Verzögerung einbauen! • Code verfügbar unter: https://github.com/ojahnn/stuts56/tree/master/YouKnowWhatBot 17.11.2014 StuTS 56, Esther Seyffarth 8 """Beispielprojekte""" # Twitterbots
  • 9.
    17.11.2014 StuTS 56,Esther Seyffarth 9 """Beispielprojekte""" # CMU Dict, Machine Shakespeare
  • 10.
    • CMU Dictionary: amachine-readable pronunciation dictionary for North American English that contains over 125,000 words and their transcriptions http://www.speech.cs.cmu.edu/cgi -bin/cmudict 17.11.2014 StuTS 56, Esther Seyffarth 10 """Beispielprojekte""" # CMU Dict EXAMINED IH0 G Z AE1 M AH0 N D EXAMINER IH0 G Z AE1 M AH0 N ER0 EXAMINER'S EH0 G Z AE1 M AH0 N ER0 Z EXAMINERS IH0 G Z AE1 M IH0 N ER0 Z EXAMINERS' IH0 G Z AE1 M IH0 N ER0 Z EXAMINES IH0 G Z AE1 M AH0 N Z EXAMINING IH0 G Z AE1 M IH0 N IH0 NG EXAMPLE IH0 G Z AE1 M P AH0 L EXAMPLES IH0 G Z AE1 M P AH0 L Z EXAMS IH0 G Z AE1 M Z EXAR EH1 K S ER0 EXASPERATE IH0 G Z AE1 S P ER0 EY2 T 39518 39519 39520 39521 39522 39523 39524 39525 39526 39527 39528 39529 Mit so einem Datensatz müsste es doch möglich sein, automatisch zu dichten…
  • 11.
    • Alle 153Shakespeare-Sonette einlesen und mithilfe des CMU Dictionary nach Endreimen sortieren • Zufällige Kombination sich reimender Zeilen zu einem neuen Gedicht zusammensetzen • … 17.11.2014 StuTS 56, Esther Seyffarth 11 """Beispielprojekte""" # Machine Shakespeare
  • 12.
    Why Is MyVerse So Barren Of New Pride? That You Were Once Unkind Befriends Me Now. O, For My Sake Do You With Fortune Chide When Forty Winters Shall Besiege Thy Brow. What Is Your Substance, Whereof Are You Made? Unthrifty Loveliness, Why Dost Thou Spend, Whilst I Alone Did Call Upon Thy Aid? Being Your Slave, What Should I Do But Tend? Where Art Thou, Muse, That Thou Forget'st So Long? Thy Glass Will Show Thee How Thy Beauties Wear. O! Call Not Me To Justify The Wrong! Alas! 'Tis True, I Have Gone Here And There. O Me! What Eyes Hath Love Put In My Head? Weary With Toil, I Haste Me To My Bed. 17.11.2014 StuTS 56, Esther Seyffarth 12 76 120 111 2 53 4 79 57 100 77 139 110 148 37 """Beispielprojekte""" # Machine Shakespeare
  • 13.
    17.11.2014 StuTS 56,Esther Seyffarth 13 • Siehe hierzu auch: • http://www.garysieling.com/blog/rhyming-with-nlp-and-shakespeare (Ersetzung der Endreime durch andere, passende Wörter) • http://gnoetrydaily.wordpress.com/2010/08/23/break-bear-presenteth-pos-sonnet-line- templates/ (POS-basierter Sonettgenerator ohne Reime) """Beispielprojekte""" # Machine Shakespeare
  • 14.
    17.11.2014 StuTS 56,Esther Seyffarth 14 """Beispielprojekte""" # Gronseuns
  • 15.
    17.11.2014 StuTS 56,Esther Seyffarth 15 • Buchstaben-N-Gramme als charakteristisches Merkmal einer Einzelsprache • Statistik auslesen aus Wikipedia-Artikeln """Beispielprojekte""" # Gronseuns Wenn wir Texten anhand ihrer Buchstaben-N-Gramme die richtige Sprache zuordnen können… … dann können wir doch sicher auch neue Texte generieren, solange wir uns an die statistischen Vorgaben der jeweiligen Sprache halten?
  • 16.
    17.11.2014 StuTS 56,Esther Seyffarth 16 • "Druchlauchere von keln dienempfungelungter zurn Komme ineteritzt." • "Surs qui bille gue, l'étant etiqui l'hieur férimenté abes peupe ger les; il voire vitivec le, de bes leva ne te l'emeuvec Émie." • "Zicats eeng. De onden heeg geze bilgezekallubs. Buurcen een Nieuwet- Werleid Amstadstade KLM." • "Majoin the was fider of a le oven thavout was ition helet, thation he clas servativeat be Prip, aliame Mary ould's elso broaccer tonfluent." """Beispielprojekte""" # Gronseuns
  • 17.
    17.11.2014 StuTS 56,Esther Seyffarth 17 • "Druchlauchere von keln dienempfungelungter zurn Komme ineteritzt." • "Surs qui bille gue, l'étant etiqui l'hieur férimenté abes peupe ger les; il voire vitivec le, de bes leva ne te l'emeuvec Émie." • "Zicats eeng. De onden heeg geze bilgezekallubs. Buurcen een Nieuwet- Werleid Amstadstade KLM." • "Majoin the was fider of a le oven thavout was ition helet, thation he clas servativeat be Prip, aliame Mary ould's elso broaccer tonfluent." # de # fr # nl # en """Beispielprojekte""" # Gronseuns
  • 18.
    17.11.2014 StuTS 56,Esther Seyffarth 18 """Beispielprojekte""" # Textonyme
  • 19.
    17.11.2014 StuTS 56,Esther Seyffarth 19 • Automatisches Finden von Textonympaaren oder – gruppen • Als Korpus z. B. wieder Wikipedia verwenden • Für jedes Wort die Tastenfolge bestimmen, mit der es in T9 geschrieben wird; dann Wörter nach ihren Zahlencodes sortieren • Beispielpaare: • any/cow, year/webs, defeat/effect • Beruf/beste, Kaiser/Jahres, weihte/zeigte """Beispielprojekte""" # Textonyme
  • 20.
    17.11.2014 StuTS 56,Esther Seyffarth 20 He inches me up, age-rating ambient hate. If images of us aid saving ancient gate sites, they win asserted summer blood, soft done. River! View who arrested stones alone. Poet food... Slaves noted cape-serving good. Line: none. Plates moved, bare, resting, home. Kind mood. """Beispielprojekte""" # Textonyme
  • 21.
    17.11.2014 StuTS 56,Esther Seyffarth 21 He inches me up, age-rating ambient hate. If images of us aid saving ancient gate 43 462437 63 87 243 728464 2624368 4283 sites, they win asserted summer blood, soft done. River! View who arrested stones alone. Poet food... 74837 8439 946 27737833 786637 25663 7638 3663 Slaves noted cape-serving good. Line: none. Plates moved, bare, resting, home. Kind mood. 752837 66833 2273 7378464 4663 5463 6663 """Beispielprojekte""" # Textonyme
  • 22.
    17.11.2014 StuTS 56,Esther Seyffarth 22 """NaNoGenMo""" # National Novel Generation Month
  • 23.
    17.11.2014 StuTS 56,Esther Seyffarth 23 • Ein Projekt von Darius Kazemi https://github.com/dariusk/NaNoGenMo-2014 """NaNoGenMo""" # Buchgenerierung
  • 24.
    17.11.2014 StuTS 56,Esther Seyffarth 24 • 50.000 Meows https://github.com/dariusk/NaNoGenMo-2014/issues/50 • Generiertes Voynich-Manuskript https://github.com/dariusk/NaNoGenMo-2014/issues/45 • How Hannah Solved The Twelve-Disk Tower of Hanoi https://github.com/dariusk/NaNoGenMo-2014/issues/76 • Twide and Twejudice https://github.com/dariusk/NaNoGenMo-2014/issues/51 """NaNoGenMo""" # Highlights (1/2)
  • 25.
    17.11.2014 StuTS 56,Esther Seyffarth 25 • Recipe Book Generator https://github.com/dariusk/NaNoGenMo-2014/issues/87 • Generated Detective https://github.com/dariusk/NaNoGenMo-2014/issues/70 • A diary of every minute of the day https://github.com/dariusk/NaNoGenMo-2014/issues/89 • … und meine Beiträge: https://github.com/dariusk/NaNoGenMo-2014/issues/46 """NaNoGenMo""" # Highlights (2/2)
  • 26.
    17.11.2014 StuTS 56,Esther Seyffarth 26 diskussion = input("Fragen, Anregungen, Ideen? ") # Die Folien zum Herunterladen findet ihr unter http://www.enigmabrot.de/stuts56.pdf