47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
#!/usr/bin/env python
|
||
# -*- coding: utf-8 -*-
|
||
|
||
#from __future__ import unicode_literals
|
||
from pattern.fr import parse, split
|
||
|
||
|
||
texte_brut = u"Le petit chat rugit alors que l'esclave humain tarde à accomplir sa tâche de nourrissage du maître et seigneur."
|
||
texte_brut.encode('utf-8')
|
||
texte = parse( texte_brut )
|
||
|
||
|
||
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 "——————————"
|
||
print "mots :"
|
||
print phrase.words
|
||
print "——————————"
|
||
print "groupes de mots :"
|
||
print phrase.chunks
|
||
print "——————————"
|
||
print "structure, phrase :"
|
||
print phrase.__dict__.keys()
|
||
print "——————————"
|
||
print "structure, mot :"
|
||
print phrase.words[0].__dict__.keys()
|
||
print "——————————"
|
||
print "structure, chunk (groupe de mots) :"
|
||
print phrase.chunks[0].__dict__.keys()
|
||
'''
|
||
for mot in phrase.words:
|
||
# print mot.__dict__.keys()
|
||
print "---"
|
||
imprimer_structure_mot( mot )
|
||
# imprimer_la_structure_de_la_phrase( phrase.words[0] )
|
||
'''
|