Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

python - Mac Terminal freezes when processing syllables from word file

I am using a for loop to copy words syllabilized in a new text file from another text file. The terminal freezes after copying half of the words which are 100k where each in a line without showing any errors. What is happening with the system?

from syltippy import syllabize
from collections import Counter 


with open('espanol.txt', 'r', encoding = "ISO-8859-1") as DictEspanol, open('espanolSYLL.txt', 'w+') as DictEspanol2:
  
    for word in DictEspanol:
        word=str(word)
        syllables, stress = syllabize(word)
        DictEspanol2.write(u'-'.join(s if stress != i else s.upper() for (i, s) in enumerate(syllables)))
        DictEspanol2.write("
")
        
    DictEspanol2.close()
    print('DOONNEE')
with open('espanolSYLL.txt', 'rb') as DictEspanol2, open('espanolSYLL2.txt', 'w+') as DictEspanol3:  
    print('done')
    for word in DictEspanol2:
        print('done 2')
        Lettercount=word
        counter = Lettercount.count('-')
        print(counter)
        
        if counter == 2:
            print(word)
            DictEspanol3.write(word)
            DictEspanol3.write("
")

print('Donney Donney ')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...