Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
import prosodic
## load/write-load text
if os.path.exists(filename):
self.filename = filename
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
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
def __init__(self,token,syllables=None,sylls_text=[],broken=False,lang=None):
if syllables==None:
import prosodic
if lang==None:
lang=prosodic.lang
w=prosodic.dict[lang].get(token)[0]
if not len(w.__dict__):
self.broken=True
else:
for k,v in list(w.__dict__.items()):
setattr(self,k,v)
return
self.token = token.lower() # the case-sensitive, non-punctuation representation
self.punct = "" # the right-aligned punctuation (if any)
self.sylls_text=sylls_text # a list of strings, representing this word's syllabification
self.finished = False # finished parameter
self.children = syllables # pre-loaded Syllable objects
self.numSyll = len(syllables) # the number of syllables
self.broken=broken