cdleong commited on
Commit
293b978
1 Parent(s): 10bed1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -10,22 +10,22 @@ st.write("Try typing your language below! Accepts either codes like `eng`/`en`,
10
  # https://docs.streamlit.io/library/api-reference/write-magic/st.write
11
  langtext = st.text_input("Language Code/Tag Lookup using langcodes", "english").strip()
12
 
13
- st.write("Checking whether the tag is valid. That is, the language, script, territory, and variants (if present) are all tags that have meanings assigned by IANA.")
14
 
15
  if langcodes.tag_is_valid(langtext):
16
- st.write(f"...True! '{langtext}' parses meaningfully as a language tag according to IANA.")
17
  else:
18
- st.write(f"...False! '{langtext}' doesn't parse meaningfully as a language tag according to IANA, some of its subcomponents may be invalid or it might be a natural language description.")
19
 
20
 
21
  try:
22
  lang = langcodes.Language.get(langtext)
23
  # st.write(f"{lang} is the BCP-47 tag.")
24
  if "unknown" in lang.display_name().lower():
25
- st.write(f"Attempting to lookup the code directly gives us '{lang.display_name()}', attempting to search for it as a natural language string.")
26
  lang = None
27
  except langcodes.LanguageTagError as e:
28
- st.write(f"Could not lookup code directly, attempting to search for it as a natural language string.")
29
  lang = None
30
 
31
 
@@ -34,11 +34,11 @@ if lang is None:
34
  try:
35
  found = langcodes.find(langtext)
36
  lang = found
37
- st.write(f"natural language search found the following BCP-47 tag: {lang}")
38
  except LookupError as e:
39
- st.write(f"Unable to look up language code.")
40
- st.write(f"Try also: https://r12a.github.io/app-subtags/")
41
- st.write(f"Try also: https://glottolog.org/glottolog?search={langtext}")
42
  lang = None
43
 
44
 
 
10
  # https://docs.streamlit.io/library/api-reference/write-magic/st.write
11
  langtext = st.text_input("Language Code/Tag Lookup using langcodes", "english").strip()
12
 
13
+ st.write("* Checking whether the tag is valid. That is, the language, script, territory, and variants (if present) are all tags that have meanings assigned by IANA.")
14
 
15
  if langcodes.tag_is_valid(langtext):
16
+ st.write(f"* ...True! '{langtext}' parses meaningfully as a language tag according to IANA.")
17
  else:
18
+ st.write(f"* ...False! '{langtext}' doesn't parse meaningfully as a language tag according to IANA, some of its subcomponents may be invalid or it might be a natural language description.")
19
 
20
 
21
  try:
22
  lang = langcodes.Language.get(langtext)
23
  # st.write(f"{lang} is the BCP-47 tag.")
24
  if "unknown" in lang.display_name().lower():
25
+ st.write(f"* Attempting to lookup the code directly gives us '{lang.display_name()}', attempting to search for it as a natural language string.")
26
  lang = None
27
  except langcodes.LanguageTagError as e:
28
+ st.write(f"* Could not lookup code directly, attempting to search for it as a natural language string.")
29
  lang = None
30
 
31
 
 
34
  try:
35
  found = langcodes.find(langtext)
36
  lang = found
37
+ st.write(f"* Natural language search found the following BCP-47 tag: {lang}")
38
  except LookupError as e:
39
+ st.write(f"Unable to look up language code. But all hope is not lost...")
40
+ st.write(f"* You can also try https://r12a.github.io/app-subtags/")
41
+ st.write(f"* Or possibly https://glottolog.org/glottolog?search={langtext}")
42
  lang = None
43
 
44