88import re
99from contextlib import ExitStack
1010from importlib import metadata , resources
11- from typing import IO , Dict , List , Optional
11+ from typing import IO , Dict , Optional
1212
1313__version__ = metadata .version (__name__ )
1414
@@ -34,7 +34,7 @@ def _string(resource_name: str) -> str:
3434
3535def _entries (
3636 stream : IO [bytes ], comment_string : Optional [str ] = None
37- ) -> List [tuple [str , List [str ]]]:
37+ ) -> list [tuple [str , list [str ]]]:
3838 cmudict_entries = []
3939 for line in stream :
4040 parts = []
@@ -48,13 +48,13 @@ def _entries(
4848
4949
5050# pylint: disable-next=redefined-builtin
51- def dict () -> Dict [str , List [ List [str ]]]:
51+ def dict () -> Dict [str , list [ list [str ]]]:
5252 """
5353 Compatibility with NLTK.
5454 Returns the cmudict lexicon as a dictionary, whose keys are
5555 lowercase words and whose values are lists of pronunciations.
5656 """
57- default : Dict [str , List [ List [str ]]] = {}
57+ default : Dict [str , list [ list [str ]]] = {}
5858 for key , value in entries ():
5959 if key not in default :
6060 default [key ] = []
@@ -80,9 +80,9 @@ def license_string() -> str:
8080 return string
8181
8282
83- def phones () -> List [tuple [str , List [str ]]]:
83+ def phones () -> list [tuple [str , list [str ]]]:
8484 """Return a list of phones used in the main dict."""
85- cmu_phones : List [tuple [str , List [str ]]] = []
85+ cmu_phones : list [tuple [str , list [str ]]] = []
8686 for line in phones_stream ():
8787 parts = line .decode ("utf-8" ).strip ().split ()
8888 cmu_phones .append ((parts [0 ], parts [1 :]))
@@ -101,9 +101,9 @@ def phones_string() -> str:
101101 return string
102102
103103
104- def symbols () -> List [str ]:
104+ def symbols () -> list [str ]:
105105 """Return a list of symbols."""
106- cmu_symbols : List [str ] = []
106+ cmu_symbols : list [str ] = []
107107 for line in symbols_stream ():
108108 cmu_symbols .append (line .decode ("utf-8" ).strip ())
109109 return cmu_symbols
@@ -122,9 +122,9 @@ def symbols_string() -> str:
122122
123123
124124# pylint: disable-next=invalid-name
125- def vp () -> Dict [str , List [ List [str ]]]:
125+ def vp () -> Dict [str , list [ list [str ]]]:
126126 """Return a list of punctuation pronounciations."""
127- cmu_vp : Dict [str , List [ List [str ]]] = {}
127+ cmu_vp : Dict [str , list [ list [str ]]] = {}
128128 with vp_stream () as stream :
129129 for key , value in _entries (stream ):
130130 if not key in cmu_vp :
@@ -147,14 +147,14 @@ def vp_string() -> str:
147147
148148# The .entries(), .raw(), and .words() functions
149149# maintain compatability with NTLK.
150- def entries () -> List [tuple [str , List [str ]]]:
150+ def entries () -> list [tuple [str , list [str ]]]:
151151 """
152152 Compatibility with NLTK.
153153 Returns the cmudict lexicon as a list of entries
154154 containing (word, transcriptions) tuples.
155155 """
156156 with dict_stream () as stream :
157- cmu_entries : List [tuple [str , List [str ]]] = _entries (stream , "#" )
157+ cmu_entries : list [tuple [str , list [str ]]] = _entries (stream , "#" )
158158 return cmu_entries
159159
160160
@@ -167,7 +167,7 @@ def raw() -> str:
167167 return string
168168
169169
170- def words () -> List [str ]:
170+ def words () -> list [str ]:
171171 """
172172 Compatibility with NLTK.
173173 Returns a list of all words defined in the cmudict lexicon.
0 commit comments