cdleong commited on
Commit
7a00e93
1 Parent(s): d7bf3e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -64,6 +64,21 @@ def pull_obsolete_codes(iso_code):
64
  obsolete_codes[obsolete_code_name] = code
65
  return obsolete_codes
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  def try_searching_vachan_engine(langtext):
68
  results_list = []
69
  langtext_quoted = urllib.parse.quote(langtext)
@@ -81,6 +96,7 @@ if lang is not None:
81
  broader_tags = lang.broader_tags()
82
  results_from_vachan = try_searching_vachan_engine(langtext)
83
  standardized_tag = langcodes.standardize_tag(lang)
 
84
 
85
 
86
  st.write(f"## Results: probably use '{standardized_tag}'")
@@ -102,6 +118,8 @@ if lang is not None:
102
  st.write(f"Try also: https://r12a.github.io/app-subtags/?lookup={lang}, which will likely have links to Ethnologue, Wikipedia, and Character usage. You can also try searching for '{langtext}' there!")
103
 
104
  st.write(f"### Glottolog")
 
 
105
  st.write(f"https://glottolog.org/glottolog?search={t_variant} may be also of interest, with links to various resources including WALS, Wikidata, Odin, and OLAC. ")
106
  if t_variant != b_variant:
107
  st.write(f"If that doesn't work, try https://glottolog.org/glottolog?search={b_variant}, or put in a [custom search query](https://glottolog.org/glottolog)")
64
  obsolete_codes[obsolete_code_name] = code
65
  return obsolete_codes
66
 
67
+
68
+ def try_retrieving_glottolog_id(langtext):
69
+ languoid_id = ""
70
+ session = HTMLSession()
71
+ langtext_quoted = urllib.parse.quote(langtext)
72
+ query_url=f"https://glottolog.org/glottolog?search={langtext_quoted}"
73
+ glottolog_r= session.get(query_url)
74
+ returned_url = glottolog_r.html.url
75
+
76
+
77
+ if "languoid" in returned_url:
78
+ last_section = returned_url.split("/")[-1]
79
+ languoid_id = last_section
80
+ return languoid_id
81
+
82
  def try_searching_vachan_engine(langtext):
83
  results_list = []
84
  langtext_quoted = urllib.parse.quote(langtext)
96
  broader_tags = lang.broader_tags()
97
  results_from_vachan = try_searching_vachan_engine(langtext)
98
  standardized_tag = langcodes.standardize_tag(lang)
99
+ languoid_id = try_retrieving_glottolog_id(langtext)
100
 
101
 
102
  st.write(f"## Results: probably use '{standardized_tag}'")
118
  st.write(f"Try also: https://r12a.github.io/app-subtags/?lookup={lang}, which will likely have links to Ethnologue, Wikipedia, and Character usage. You can also try searching for '{langtext}' there!")
119
 
120
  st.write(f"### Glottolog")
121
+ if languoid_id:
122
+ st.write(f"**Glottolog Languoid ID:** Searching for '{langtext}' on Glottolog returns the following 'languoid ID': {languoid_id}")
123
  st.write(f"https://glottolog.org/glottolog?search={t_variant} may be also of interest, with links to various resources including WALS, Wikidata, Odin, and OLAC. ")
124
  if t_variant != b_variant:
125
  st.write(f"If that doesn't work, try https://glottolog.org/glottolog?search={b_variant}, or put in a [custom search query](https://glottolog.org/glottolog)")