def parse(self, meter=None): if not meter: from Meter import Meter, genDefault meter = genDefault() words = self.ents(cls='Word', flattenList=False) numSyll = 0 if not words: return None for word in words: if type(word) == type([]): for wrd in word: if wrd.isBroken(): #print wrd return None numSyll += word[0].getNumSyll() else: if word.isBroken(): return None numSyll += word.getNumSyll() self.__parses[meter] = meter.parse(words, numSyll) try: self.__bestparse[meter] = self.__parses[meter][0] except KeyError: self.__bestparse[meter] = None
def parse(self,meter=None): if not meter: from Meter import Meter,genDefault meter = genDefault() words=self.ents(cls='Word',flattenList=False) numSyll=0 if not words: return None for word in words: if type(word)==type([]): for wrd in word: if wrd.isBroken(): #print wrd return None numSyll+=word[0].getNumSyll() else: if word.isBroken(): return None numSyll+=word.getNumSyll() self.__parses[meter]=meter.parse(words,numSyll) try: self.__bestparse[meter]=self.__parses[meter][0] except KeyError: self.__bestparse[meter]=None
def parse(self,meter=None,arbiter='Line'): """Parse this text metrically.""" if not meter: from Meter import Meter,genDefault meter = genDefault() self.__parses[meter]=[] self.__bestparses[meter]=[] init=self if not hasattr(init,'meter_stats'): init.meter_stats={'lines':{},'positions':{},'texts':{}, '_ot':{},'_constraints':{}} if not hasattr(init,'bestparses'): init.bestparses=[] init.meter=meter init.meter_stats['_constraints']=sorted(init.meter.constraints) init.ckeys="\t".join(sorted([str(x) for x in init.meter.constraints])) ents=self.ents(arbiter) for ent in ents: ent.parse(meter,init=init) self.__parses[meter].append( ent.allParses(meter) ) self.__bestparses[meter].append( ent.bestParse(meter) ) #self.scansion_prepare(conscious=True) self.scansion(meter=meter,conscious=True)
def parse(self, meter=None, arbiter='Line'): """Parse this text metrically.""" if not meter: from Meter import Meter, genDefault meter = genDefault() self.__parses[meter] = [] self.__bestparses[meter] = [] init = self if not hasattr(init, 'meter_stats'): init.meter_stats = { 'lines': {}, 'positions': {}, 'texts': {}, '_ot': {}, '_constraints': {} } if not hasattr(init, 'bestparses'): init.bestparses = [] init.meter = meter init.meter_stats['_constraints'] = sorted(init.meter.constraints) init.ckeys = "\t".join(sorted([str(x) for x in init.meter.constraints])) ents = self.ents(arbiter) for ent in ents: ent.parse(meter, init=init) self.__parses[meter].append(ent.allParses(meter)) self.__bestparses[meter].append(ent.bestParse(meter)) #self.scansion_prepare(conscious=True) self.scansion(meter=meter, conscious=True)
def parse(self,meter=None,arbiter='Line'): """Parse this text metrically.""" if not meter: from Meter import Meter,genDefault meter = genDefault() self.__parses[meter]=[] self.__bestparses[meter]=[] ents=self.ents(arbiter) for ent in ents: ent.parse(meter) self.__parses[meter].append( ent.allParses(meter) ) self.__bestparses[meter].append( ent.bestParse(meter) ) #self.scansion_prepare(conscious=True) self.scansion(meter=meter,conscious=True)
def parse(self,meter=None,arbiter='Line'): """Parse this text metrically.""" if not meter: from Meter import Meter,genDefault meter = genDefault() self.__parses[meter]=[] self.__bestparses[meter]=[] ents=self.ents(arbiter) import prosodic for ent in ents: if len(ent.syllables())>prosodic.config['line_maxsylls']: continue if len(ent.syllables())<prosodic.config['line_minsylls']: continue ent.parse(meter) self.__parses[meter].append( ent.allParses(meter) ) self.__bestparses[meter].append( ent.bestParse(meter) ) #self.scansion_prepare(conscious=True) self.scansion(meter=meter,conscious=True)
def parse(self, meter=None, arbiter='Line'): """Parse this text metrically.""" if not meter: from Meter import Meter, genDefault meter = genDefault() self.__parses[meter] = [] self.__bestparses[meter] = [] ents = self.ents(arbiter) import prosodic for ent in ents: if len(ent.syllables()) > prosodic.config['line_maxsylls']: continue if len(ent.syllables()) < prosodic.config['line_minsylls']: continue ent.parse(meter) self.__parses[meter].append(ent.allParses(meter)) self.__bestparses[meter].append(ent.bestParse(meter)) #self.scansion_prepare(conscious=True) self.scansion(meter=meter, conscious=True)