Kyubyong / g2p

g2p: English Grapheme To Phoneme Conversion
Apache License 2.0
811 stars 128 forks source link

File ('homographs.en' ) is not closed after opening by construct_homograph_dictionary #13

Open antimora opened 4 years ago

antimora commented 4 years ago

File ('homographs.en' ) remains open after using it. Please consider using context manager to auto close as in this example: https://book.pythontips.com/en/latest/context_managers.html

The actual warning:

  File "/home/dev/.local/lib/python3.8/site-packages/g2p_en/g2p.py", line 35, in construct_homograph_dictionary
    for line in codecs.open(f, 'r', 'utf8').read().splitlines():
ResourceWarning: unclosed file <_io.BufferedReader name='/home/dev/.local/lib/python3.8/site-packages/g2p_en/homographs.en'>