#!/usr/bin/python # -*- coding: utf-8 -*- #ma fonction def splitParagraphIntoSentences(paragraph): ''' break a paragraph into sentences and return a list ''' import re #pour repérer l'expression régulière prose = re.compile(r'drill') #sépare les phrases en se repérant le regex #sentenceList = prose.split(paragraph) return prose #appliquer le variable sentenceList with open("how_2_use_drill.txt", "r" ) as source: for line in source: sentences = splitParagraphIntoSentences(line) for s in sentences: print s.strip() # '''définir une fonction qui sépare les paragraphes # en phrases dans une list''' # def splitParagraphIntoSentences(paragraph): # #utiliser la librairie regex # import re # sentenceEnders = re.compile('[.!?]') # return sentenceEnders # with open("how_2_use_drill.txt", "r" ) as source: # for line in source: # sentences = splitParagraphIntoSentences(line) # for s in sentences: # print s.strip()