Loading a Phone Collection
from phones import PhoneCollection
pc = PhoneCollection()
Getting all Phones in a Language¶
Let's first retrieve the first 5 phones in English.
As phoible uses ISO 639-3 language codes), we use .langs
with the "eng"
code to retrieve English phones.
# get 5 english phones
pc.langs("eng").values[:5]
We can also retrieve phones in multiple languages.
# get 5 english/german phones
pc.langs(["eng", "deu"]).values[:5]
Languages can be listed using lang_list
.
pc.lang_list[:5]
Getting a Specific Phone¶
Using .phones
, we can also retrieve specific phones.
pc.phones("aɪ").values
You can use .val
, if you want to get only one phone instead of a phone for each language.
pc.phones("aɪ").val
Using .vector
, the vector representation of the phone can be accessed.
pc.phones("aɪ").val.vector
As with languages, phones can be listed using phone_list
.
pc.langs("eng").phone_list[:5]
from phones.sources import PANPHON, PHOIBLE
pc_panphon = PhoneCollection(PANPHON)
Dialects¶
When using the PHOIBLE
source, dialects are not loaded per default. You can change this by using load_dialects
and specifying a specific dialect by using .dialects
.
pc_dialects = PhoneCollection(load_dialects=True)
pc_dialects.langs("eng").dialects("english (liverpool)").values[:5]
Some languages do not have a "standard" version and are only accessible when using load_dialects
, for example Asturian.
pc.langs("ast").values, pc_dialects.langs("ast").dialects("asturian (north-eastern)").values[:5]
You can list dialects using dialect_list
.
pc_dialects.langs("ast").dialect_list