Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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
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':