How to use the prosodic.config function in prosodic

To help you get started, we’ve selected a few prosodic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quadrismegistus / prosodic / prosodic / lib / Corpus.py View on Github external
def __init__(self,corpusRoot,lang=None,printout=None,corpusFiles="*.txt",phrasebreak=',;:.?!()[]{}<>',limWord=None):
		import prosodic
		## entity-shared attribtues

		self.lang=prosodic.config['lang'] if not lang else lang
		self.dict=prosodic.dict[self.lang]
		self.parent=False
		#self.foldername=corpusRoot.split("/").pop().strip()
		self.children=[]	# texts
		self.feats = {}
		self.featpaths={}
		self.finished = False
		self.config=prosodic.config
		self.meter=None
		if printout==None: printout=being.printout

		## corpus attributes
		self.corpusRoot = corpusRoot
		self.corpusFiles = corpusFiles
		self.name=os.path.split(os.path.abspath(self.corpusRoot))[-1]
		self.foldername=self.name
		self.dir_results = prosodic.dir_results

		## language may be **, ie, determinable by the first two character of the textfile ("en" for english, "fi" for finnish, etc)
		if not lang:
			lang=being.lang
		self.lang = lang

		## [loop] through filenames
github quadrismegistus / prosodic / prosodic / lib / Corpus.py View on Github external
def __init__(self,corpusRoot,lang=None,printout=None,corpusFiles="*.txt",phrasebreak=',;:.?!()[]{}<>',limWord=None):
		import prosodic
		## entity-shared attribtues

		self.lang=prosodic.config['lang'] if not lang else lang
		self.dict=prosodic.dict[self.lang]
		self.parent=False
		#self.foldername=corpusRoot.split("/").pop().strip()
		self.children=[]	# texts
		self.feats = {}
		self.featpaths={}
		self.finished = False
		self.config=prosodic.config
		self.meter=None
		if printout==None: printout=being.printout

		## corpus attributes
		self.corpusRoot = corpusRoot
		self.corpusFiles = corpusFiles
		self.name=os.path.split(os.path.abspath(self.corpusRoot))[-1]
		self.foldername=self.name
github quadrismegistus / prosodic / experiments / degroot / degroot.py View on Github external
def add_profile(text, dict, num_sylls, start):
	import prosodic
	prosodic.config['print_to_screen']=0
	for stanza in text.stanzas():
		try:
			if True in [line.broken for line in stanza.children]:
				continue
			
			for parse in [line.bestParse() for line in stanza.children]:
				if not parse:
					goodness=False
					break
			else:
				goodness=True
			
			if not goodness: continue
		except:
			continue
github quadrismegistus / prosodic / prosodic / lib / Meter.py View on Github external
'number_feet!=5/1'],
	'id': 'iambic_pentameter',
	'maxS': 2,
	'maxW': 2,
	'name': 'Iambic Pentameter',
	'splitheavies': 0}"""
	if 'Meter.Meter' in str(id.__class__): return id

	if not id: id='Meter_%s' % now()
	if not name: name = id + '['+' '.join(constraints)+']'

	config = locals()

	import prosodic
	if id in prosodic.config['meters']:
		return prosodic.config['meters'][id]


	if return_dict: return config
	return Meter(config)
github quadrismegistus / prosodic / prosodic / lib / Text.py View on Github external
try:
			self.dict=prosodic.dict[lang]
		except KeyError:
			lang0=lang
			lang=prosodic.languages[0]
			print "!! language "+lang0+" not recognized. defaulting to: "+lang
			self.dict=prosodic.dict[lang]
		self.lang=lang
		
		
		## create atomistic features
		self.featpaths={}
		self.__parses={}
		self.__bestparses={}
		self.phrasebreak_punct = unicode(",;:.?!()[]{}<>")
		self.phrasebreak=prosodic.config['linebreak'].strip()
		
		
		#if printout==None: printout=being.printout
		
		if self.phrasebreak=='line':
			pass
		elif self.phrasebreak.startswith("line"):
			self.phrasebreak_punct=unicode(self.phrasebreak.replace("line",""))
			self.phrasebreak='both'
		else:
			self.phrasebreak_punct=unicode(self.phrasebreak)
		
		
		self.limWord = limWord
		self.feats = {}
github quadrismegistus / prosodic / experiments / qclash.py View on Github external
from __future__ import division
import sys,clash,prosodic as p,rpyd2
p.config['print_to_screen']=0
c=p.Corpus(sys.argv[1])


def numclashes_aslist(ent,stressval=0.0):
	clashes=[]
	a=None
	for b in ent.syllables():
		if not a:
			a=b
			continue
		clashes+=[a.feature('prom.stress')==stressval and b.feature('prom.stress')==stressval]
		a=b
	return clashes

for t in c.texts():
	ld=[]
github quadrismegistus / prosodic / prosodic / lib / Text.py View on Github external
def init_text(self,lines_or_file):
		## create first stanza,line
		stanza = self.newchild()
		stanza.num=stanza_num=1
		line = stanza.newchild()	# returns a new Line, the child of Stanza
		line.num=line_num=1
		numwords = 0
		recentpunct=True
		import prosodic
		tokenizer=prosodic.config['tokenizer'].replace('\\\\','\\')

		## [loop] lines
		for ln in lines_or_file:
			if REPLACE_DASHES:
				for dash in DASHES:
					ln=ln.replace(dash,' '+dash+' ')
			ln=ln.strip()
			#print ln,type(ln)
			if self.limWord and numwords>self.limWord: break

			# split into words
			#print self.isUnicode
			toks = re.findall(tokenizer,ln.strip(),flags=re.UNICODE) if self.isUnicode else re.findall(tokenizer,ln.strip())
			#print toks
			#print tokenizer
			toks = [tok.strip() for tok in toks if tok.strip()]
github quadrismegistus / prosodic / prosodic / lib / entity.py View on Github external
def om(self,breath,conscious=True):
		"""
		Print the string passed via argument 'breath',
		and store the string for saving in prosodic.being.om.
		[accessed interactively using the '/save' command]
		(The string just prior to this one will remain available at prosodic.being.omm).		
		"""
		
		import prosodic
		if (not conscious) or bool(prosodic.config['print_to_screen']):
			being.om+=str(breath)+"\n"
			print self.u2s(breath)