How to use the prosodic.lib.entity.being.linelen 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 / entity.py View on Github external
assert len(xydict['x'])==len(xydict['y'])

				xs.append(x_avg)
				ys.append(y_avg)
				tsv+="\t".join(str(bb) for bb in [(posnum+1),len(xydict['x']),x_avg,y_avg,x_std,y_std])+"\n"


			ccmsg=""
			cc=None
			p=None
			try:
				from statlib import stats
				(cc,p)=stats.pearsonr(xs,ys)

				aa=makeminlength("    correlation coefficient: ",int(being.linelen/1.4))+str(cc)
				bb=makeminlength("    p-value: ",int(being.linelen/1.4))+str(p)

				tsv+=aa.strip().replace(":",":\t")+"\n"
				tsv+=bb.strip().replace(":",":\t")+"\n"

				for l in tsv.split("\n"):
					totaltsvs.append(textname+"_"+l)

				ccmsg+=aa+"\n"+bb+"\n"

			except:
				pass

			writeToFile(textname,init.pkey,tsv,extension="tsv")
			totaltsvs.append(tsv)
github quadrismegistus / prosodic / prosodic / lib / entity.py View on Github external
#doc=inspect.getdoc(attr)
			doc = attr.__doc__
			if not doc:
				doc=""
			#else:
			#	docsplit=[z for z in doc.replace("\r","\n").split("\n") if z]
			#	if len(docsplit)>1:
			#		doc = docsplit[0] + "\n" + makeminlength(" ",being.linelen) + "\n".join( makeminlength(" ",being.linelen)+"\t"+z for z in docsplit[1:])
			#	else:
			#		doc = docsplit[0]
			y=describe_func(attr)
			if not y:
				y=""
			else:
				y=", ".join(a+"="+str(b) for (a,b) in y)
			print makeminlength("."+x+"("+y+")",being.linelen),"\t", doc
			if showall: print
github quadrismegistus / prosodic / prosodic / lib / entity.py View on Github external
def query(self,query_string,toprint=False):
		"""Prints words matching the given query. Eg:   [-voice] (Syllable: (Onset: [+voice]) (Coda: [+voice]))"""
		qq=SearchTerm(query_string)
		matchcount=0
		matches=[]
		for word in self.words():
			for match in word.search(qq):
				matches.append(match)
				matchcount+=1
				if "Word" in str(type(match)):
					matchstr=""
				else:
					matchstr=str(match)
				if toprint:
					word.om(makeminlength(str(matchcount),int(being.linelen/6))+"\t"+makeminlength(str(word),int(being.linelen))+"\t"+matchstr)
		return matches
github quadrismegistus / prosodic / prosodic / lib / entity.py View on Github external
def query(self,query_string,toprint=False):
		"""Prints words matching the given query. Eg:   [-voice] (Syllable: (Onset: [+voice]) (Coda: [+voice]))"""
		qq=SearchTerm(query_string)
		matchcount=0
		matches=[]
		for word in self.words():
			for match in word.search(qq):
				matches.append(match)
				matchcount+=1
				if "Word" in str(type(match)):
					matchstr=""
				else:
					matchstr=str(match)
				if toprint:
					word.om(makeminlength(str(matchcount),int(being.linelen/6))+"\t"+makeminlength(str(word),int(being.linelen))+"\t"+matchstr)
		return matches
github quadrismegistus / prosodic / prosodic / lib / entity.py View on Github external
def dir(self,methods=True,showall=True):
		"""Show this object's attributes and methods."""
		import inspect
		#print "[attributes]"
		for k,v in sorted(self.__dict__.items()):
			if k.startswith("_"): continue
			print(makeminlength("."+k,being.linelen),"\t",v)

		if not methods:
			return

		entmethods=dir(entity)

		print()
		#print "[methods]"
		for x in [x for x in dir(self) if ("bound method "+self.classname() in str(getattr(self,x))) and not x.startswith("_")]:
			if (not showall) and (x in entmethods): continue

			attr=getattr(self,x)

			#print attr.__dict__
			#print dir(attr)