Example #1
0
def teste(s):
    lista = TOK_PORT.tokenize(s)
    for e in lista:
	print e
    return lista
Example #2
0
def teste(s):
    lista = TOK_PORT.tokenize(s)
    for e in lista:
        print e
    return lista
Example #3
0
# For license information, see LICENSE.TXT
#
# $Id: ConstroiRUBT.py $

import cPickle, time
from nltk.tag import UnigramTagger,BigramTagger,TrigramTagger
from nltk.corpus import TaggedCorpusReader
from AnotaCorpus import abre_etiquetador,codifica_sentencas
from Toqueniza import TOK_PORT

# Exemplo extraído de "Recordações do Escrivão Isaias Caminha",
# de Lima Barreto
EXEMPLO='''Se os senhores algum dia quiserem encontrar um representante da grande nação brasileira, não o procurem nunca na sua residência. '''

#SENTENCA=codifica_sentencas([TOK_PORT.tokenize(EXEMPLO)])[0]
SENTENCA=TOK_PORT.tokenize(EXEMPLO.decode("utf-8"))

PARAMETROS={}

# A seguinte função foi extraída da p. 90 do seguinte livro:
# PERKINS, J.Python (2010). Text Processing with NLTK 2.0 Cookbook. 
# Birmingham, UK: Packt.
def backoff_tagger(train_sents, tagger_classes, backoff=None):
	for cls in tagger_classes:
		backoff = cls(train_sents, backoff=backoff)
	
	return backoff


def treina(expressao_regular,
               etiquetador,