|
import gradio as gr |
|
import random |
|
|
|
|
|
ipa_features = { |
|
'p': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '+', 'continuant': '-', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '-'}, |
|
'b': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '+', 'continuant': '-', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
't': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '+', 'anterior': '+', 'continuant': '-', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '-'}, |
|
'd': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '+', 'anterior': '+', 'continuant': '-', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
'k': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '-', 'continuant': '-', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '+', 'voice': '-'}, |
|
'g': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '-', 'continuant': '-', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '+', 'voice': '+'}, |
|
'tʃ': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '+', 'anterior': '-', 'continuant': '-', 'nasal': '-', 'strident': '+', 'lateral': '-', 'delayed release': '+', 'high': '-', 'voice': '-'}, |
|
'dʒ': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '+', 'anterior': '-', 'continuant': '-', 'nasal': '-', 'strident': '+', 'lateral': '-', 'delayed release': '+', 'high': '-', 'voice': '+'}, |
|
'f': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '+', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '-'}, |
|
'v': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '+', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
'θ': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '+', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '-'}, |
|
'ð': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '+', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
's': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '+', 'anterior': '+', 'continuant': '+', 'nasal': '-', 'strident': '+', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '-'}, |
|
'z': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '+', 'anterior': '+', 'continuant': '+', 'nasal': '-', 'strident': '+', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
'ʃ': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '+', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '+', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '-'}, |
|
'ʒ': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '+', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '+', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
'h': {'syllabic': '-', 'consonantal': '+', 'sonorant': '-', 'coronal': '-', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '-'}, |
|
'm': {'syllabic': '-', 'consonantal': '+', 'sonorant': '+', 'coronal': '-', 'anterior': '+', 'continuant': '-', 'nasal': '+', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
'n': {'syllabic': '-', 'consonantal': '+', 'sonorant': '+', 'coronal': '+', 'anterior': '+', 'continuant': '-', 'nasal': '+', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
'ŋ': {'syllabic': '-', 'consonantal': '+', 'sonorant': '+', 'coronal': '-', 'anterior': '-', 'continuant': '-', 'nasal': '+', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '+', 'voice': '+'}, |
|
'l': {'syllabic': '-', 'consonantal': '+', 'sonorant': '+', 'coronal': '+', 'anterior': '+', 'continuant': '-', 'nasal': '-', 'strident': '-', 'lateral': '+', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
'r': {'syllabic': '-', 'consonantal': '+', 'sonorant': '+', 'coronal': '+', 'anterior': '+', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '-', 'voice': '+'}, |
|
'j': {'syllabic': '-', 'consonantal': '-', 'sonorant': '+', 'coronal': '-', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '+', 'voice': '+'}, |
|
'w': {'syllabic': '-', 'consonantal': '-', 'sonorant': '+', 'coronal': '-', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'high': '+', 'voice': '+'} |
|
} |
|
|
|
|
|
def filter_symbols(syllabic, consonantal, sonorant, coronal, anterior, continuant, nasal, strident, lateral, delayed_release, voice): |
|
|
|
matching_symbols = [symbol for symbol, features in ipa_features.items() |
|
if (syllabic == 'ALL' or features['syllabic'] == syllabic) |
|
and (consonantal == 'ALL' or features['consonantal'] == consonantal) |
|
and (sonorant == 'ALL' or features['sonorant'] == sonorant) |
|
and (coronal == 'ALL' or features['coronal'] == coronal) |
|
and (anterior == 'ALL' or features['anterior'] == anterior) |
|
and (continuant == 'ALL' or features['continuant'] == continuant) |
|
and (nasal == 'ALL' or features['nasal'] == nasal) |
|
and (strident == 'ALL' or features['strident'] == strident) |
|
and (lateral == 'ALL' or features['lateral'] == lateral) |
|
and (delayed_release == 'ALL' or features['delayed release'] == delayed_release) |
|
and (voice == 'ALL' or features['voice'] == voice)] |
|
|
|
|
|
return f"/{', '.join(matching_symbols)}/" if matching_symbols else "No matching symbols." |
|
|
|
|
|
def interface(): |
|
with gr.Blocks() as app: |
|
gr.Markdown("### IPA Symbol Finder Based on Distinctive Features") |
|
|
|
|
|
syllabic = gr.Radio(label="Syllabic", choices=['ALL', '+', '-'], value='ALL') |
|
consonantal = gr.Radio(label="Consonantal", choices=['ALL', '+', '-'], value='ALL') |
|
voice = gr.Radio(label="Voice", choices=['ALL', '+', '-'], value='ALL') |
|
sonorant = gr.Radio(label="Sonorant", choices=['ALL', '+', '-'], value='ALL') |
|
coronal = gr.Radio(label="Coronal", choices=['ALL', '+', '-'], value='ALL') |
|
anterior = gr.Radio(label="Anterior", choices=['ALL', '+', '-'], value='ALL') |
|
continuant = gr.Radio(label="Continuant", choices=['ALL', '+', '-'], value='ALL') |
|
nasal = gr.Radio(label="Nasal", choices=['ALL', '+', '-'], value='ALL') |
|
strident = gr.Radio(label="Strident", choices=['ALL', '+', '-'], value='ALL') |
|
lateral = gr.Radio(label="Lateral", choices=['ALL', '+', '-'], value='ALL') |
|
delayed_release = gr.Radio(label="Delayed Release", choices=['ALL', '+', '-'], value='ALL') |
|
|
|
|
|
submit_button = gr.Button("Submit") |
|
|
|
|
|
output = gr.Textbox(label="Matching IPA Symbols", interactive=False) |
|
|
|
|
|
submit_button.click( |
|
fn=filter_symbols, |
|
inputs=[syllabic, consonantal, sonorant, coronal, anterior, continuant, nasal, strident, lateral, delayed_release, voice], |
|
outputs=output |
|
) |
|
|
|
return app |
|
|
|
|
|
app = interface() |
|
app.launch() |
|
|