Files
ola5doc/content/.stversions/leo-martin/sources/un-premier-essai-avec-pattern~20171216-160058.py
T

30 lines
877 B
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 de la phrase'''
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 )
for phrase in split( texte ):
print "structure, phrase :"
print phrase.__dict__.keys()
print "structure, mot :"
print phrase.words[0].__dict__.keys()
print ""
for mot in phrase.words:
# print mot.__dict__.keys()
print "---"
imprimer_structure_mot( mot )
# imprimer_la_structure_de_la_phrase( phrase.words[0] )