How to use the prosodic.languages 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 / Text.py View on Github external
self.name = filename.split("/").pop().strip()
		else:
			fn=os.path.join(sys.path[0],'.directinput.txt')
			write(fn,filename.replace('//','\n\n').replace('/','\n'))
			self.filename=fn
			filename=fn
			self.name = '_directinput_'

		## set language
		if lang==None:
			if self.name[2]=="." and (self.name[0:2] in prosodic.dict):
				lang=self.name[0:2]
			elif prosodic.lang:
				lang=prosodic.lang
			else:
				lang=choose(prosodic.languages,"in what language is '"+self.name+"' written?")
				if not lang:
					lang=prosodic.languages[0]
					print "!! language choice not recognized. defaulting to: "+lang
				else:
					lang=lang.pop()
		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
github quadrismegistus / prosodic / prosodic / lib / Text.py View on Github external
def set_lang(self,filename):
		if not filename: return 'en'
		filename=os.path.basename(filename)
		import prosodic
		if self.isFromFile and len(filename)>2 and filename[2]=="." and (filename[0:2] in prosodic.dict):
			lang=filename[0:2]
		elif prosodic.lang:
			lang=prosodic.lang
		else:
			lang=choose(prosodic.languages,"in what language is '"+self.name+"' written?")
			if not lang:
				lang=prosodic.languages[0]
				print("!! language choice not recognized. defaulting to: "+lang)
			else:
				lang=lang.pop()

		if not lang in prosodic.dict:
			lang0=lang
			lang=prosodic.languages[0]
			print("!! language "+lang0+" not recognized. defaulting to: "+lang)

		return lang
github quadrismegistus / prosodic / prosodic / lib / Text.py View on Github external
import prosodic
		if self.isFromFile and len(filename)>2 and filename[2]=="." and (filename[0:2] in prosodic.dict):
			lang=filename[0:2]
		elif prosodic.lang:
			lang=prosodic.lang
		else:
			lang=choose(prosodic.languages,"in what language is '"+self.name+"' written?")
			if not lang:
				lang=prosodic.languages[0]
				print("!! language choice not recognized. defaulting to: "+lang)
			else:
				lang=lang.pop()

		if not lang in prosodic.dict:
			lang0=lang
			lang=prosodic.languages[0]
			print("!! language "+lang0+" not recognized. defaulting to: "+lang)

		return lang
github quadrismegistus / prosodic / prosodic / lib / Text.py View on Github external
if self.name[2]=="." and (self.name[0:2] in prosodic.dict):
				lang=self.name[0:2]
			elif prosodic.lang:
				lang=prosodic.lang
			else:
				lang=choose(prosodic.languages,"in what language is '"+self.name+"' written?")
				if not lang:
					lang=prosodic.languages[0]
					print "!! language choice not recognized. defaulting to: "+lang
				else:
					lang=lang.pop()
		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':