1 / 10

LINGUISTICA GENERALE E COMPUTAZIONALE, PARTE 2

LINGUISTICA GENERALE E COMPUTAZIONALE, PARTE 2. Lezione 4: Capitolo 3, parte prima ( Trattamento di testi ). Operazioni da eseguire ogni volta. >>> from __future__ import division >>> import nltk , re, pprint. Accesso a web via URL. >>> from urllib import urlopen

Download Presentation

LINGUISTICA GENERALE E COMPUTAZIONALE, PARTE 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LINGUISTICA GENERALE E COMPUTAZIONALE, PARTE 2 Lezione 4: Capitolo 3, parte prima (Trattamentoditesti)

  2. Operazionidaeseguireognivolta >>> from __future__ import division >>> import nltk, re, pprint

  3. Accesso a web via URL >>> from urllib import urlopen >>> url = "http://www.gutenberg.org/files/2554/2554.txt" >>> raw = urlopen(url).read() >>> type(raw) <type 'str'> >>> len(raw) 1176831 >>> raw[:75] 'The Project Gutenberg EBook of Crime and Punishment, by Fyodor Dostoevsky\r\n'

  4. Tokenizzazione >>> tokens = nltk.word_tokenize(raw) >>> type(tokens) <type 'list'> >>> len(tokens) 255809 >>> tokens[:10] ['The', 'Project', 'Gutenberg', 'EBook', 'of', 'Crime', 'and', 'Punishment', ',', 'by']

  5. Apriredocumentilocali >>> import os >>> os.listdir('.') >>> f = open('document.txt')

  6. Tipi didocumenti • HTML (p.81) • PDF (p. 85)

  7. Operazionisustringhe • P.87-92

  8. Espressioniregolari • import re • re.search()

  9. Normalizzazioneetokenizzazioneusandoespressioniregolari

  10. Unicode

More Related