24 lines
726 B
Python
24 lines
726 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
from pattern.fr import parse, split
|
|
|
|
texte = parse(u"Le chat joue au tennis.")
|
|
|
|
def imprimer_structure_mot ( mot ):
|
|
'''imprime la structure du mot'''
|
|
print 'index : ' + str( mot.index )
|
|
print 'string : ' + str( mot.string )
|
|
print '_custom_tags : ' + str( mot._custom_tags )
|
|
print 'sentence : ' + str( mot.sentence )
|
|
print 'pnp : ' + str( mot.pnp )
|
|
print 'chunk : ' + str( mot.chunk )
|
|
print 'lemma : ' + str( mot.lemma )
|
|
print 'type : ' + str( mot.type )
|
|
|
|
# pour chaque phrase dans le texte
|
|
for phrase in split( texte ):
|
|
# pour chaque mot dans la phrase
|
|
for mot in phrase.words:
|
|
print "---"
|
|
imprimer_structure_mot( mot )
|