Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


NLTK Phyton ejercicio chunck, Ejercicios de Filología Inglesa

Asignatura: Nuevas Tecnologias Aplicadas a la Lingüistica., Profesor: MªAngeles Zarcos, Carrera: Filología Inglesa, Universidad: UCA

Tipo: Ejercicios

2014/2015

Subido el 29/07/2015

rgrtg
rgrtg 🇪🇸

4.2

(189)

38 documentos

1 / 2

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on
win32
Type "copyright", "credits" or "license()" for more information.
>>> import nltk, re, pprint
>>> sentence = ["the", "DT"), ("girl", "NN"), ("is", "VBD"), ("at", "IN""), ("the", "DT"),
("door", "NN")]
SyntaxError: invalid syntax
>>> sentence = [("the", "DT"), ("girl", "NN"), ("is", "VBD"), ("at", "IN"), ("the", "DT"),
("door", "NN")]
>>> grammar = "NP: {<DT>?<JJ>*<NN>}"
>>> cp = nltk.RegexpParser(grammar)
>>> result = cp.parse(sentence)
>>> print result
SyntaxError: Missing parentheses in call to 'print'
>>> print (result)
(S (NP the/DT girl/NN) is/VBD at/IN (NP the/DT door/NN))
>>> result.draw()
pf2

Vista previa parcial del texto

¡Descarga NLTK Phyton ejercicio chunck y más Ejercicios en PDF de Filología Inglesa solo en Docsity!

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win Type "copyright", "credits" or "license()" for more information.

import nltk, re, pprint sentence = ["the", "DT"), ("girl", "NN"), ("is", "VBD"), ("at", "IN""), ("the", "DT"), ("door", "NN")]

SyntaxError: invalid syntax

sentence = [("the", "DT"), ("girl", "NN"), ("is", "VBD"), ("at", "IN"), ("the", "DT"), ("door", "NN")] grammar = "NP: {

?*}" cp = nltk.RegexpParser(grammar) result = cp.parse(sentence) print result

SyntaxError: Missing parentheses in call to 'print'

print (result) (S (NP the/DT girl/NN) is/VBD at/IN (NP the/DT door/NN)) result.draw()