cdleong commited on
Commit
bdc0541
1 Parent(s): 918f014

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import langcodes
3
  from requests_html import HTMLSession
4
  import urllib
 
5
 
6
 
7
  st.write("# Language code/tag search")
@@ -60,6 +61,14 @@ def pull_obsolete_codes(iso_code):
60
  obsolete_codes[obsolete_code_name] = code
61
  return obsolete_codes
62
 
 
 
 
 
 
 
 
 
63
 
64
  #st.write(f"langcodes found the following tag: {type(found)}") # a Language object
65
  if lang is not None:
@@ -67,6 +76,9 @@ if lang is not None:
67
  b_variant = lang.to_alpha3(variant='B')
68
  t_variant = lang.to_alpha3(variant='T')
69
  broader_tags = lang.broader_tags()
 
 
 
70
  st.write("## Results")
71
  st.write(f"Best-match BCP-47 tag for '{langtext}', according to the langcodes library: {lang}")
72
  st.write(f"Breakdown of tag components:")
@@ -86,7 +98,7 @@ if lang is not None:
86
  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)")
87
  st.write(f"https://glottolog.org/glottolog?search={urllib.parse.quote(langtext)} may pull up something as well.")
88
 
89
- st.write("## Older Codes")
90
 
91
  st.write(f"ISO 639-3 'alpha3' code, 'terminology' or 'T' variant (deprecated): {t_variant}")
92
  st.write(f"ISO 639-3 'alpha3' code, 'bibliographic' or 'B' variant (deprecated): {b_variant}")
@@ -105,7 +117,12 @@ if lang is not None:
105
  st.write(t_obsolete_codes)
106
  elif b_obsolete_codes:
107
  st.write(f"Obsolete codes from previous ISO-639 iterations, pulled from https://iso639-3.sil.org/code/{b_variant}:")
108
- st.write(b_obsolete_codes )
 
 
 
 
 
109
 
110
 
111
 
 
2
  import langcodes
3
  from requests_html import HTMLSession
4
  import urllib
5
+ import requests
6
 
7
 
8
  st.write("# Language code/tag search")
 
61
  obsolete_codes[obsolete_code_name] = code
62
  return obsolete_codes
63
 
64
+ def try_searching_vachan_engine(langtext):
65
+ results_list = []
66
+ langtext_quoted = urllib.parse.quote(langtext)
67
+ query_url = f"https://api.vachanengine.org/v2/languages?search_word={langtext_quoted}"
68
+ vachan_r= requests.get(query_url)
69
+ if vachan_r.status_code == 200:
70
+ results_list = vachan_r.json()
71
+ return results_list
72
 
73
  #st.write(f"langcodes found the following tag: {type(found)}") # a Language object
74
  if lang is not None:
 
76
  b_variant = lang.to_alpha3(variant='B')
77
  t_variant = lang.to_alpha3(variant='T')
78
  broader_tags = lang.broader_tags()
79
+ results_from_vachan = try_searching_vachan_engine(langtext)
80
+
81
+
82
  st.write("## Results")
83
  st.write(f"Best-match BCP-47 tag for '{langtext}', according to the langcodes library: {lang}")
84
  st.write(f"Breakdown of tag components:")
 
98
  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)")
99
  st.write(f"https://glottolog.org/glottolog?search={urllib.parse.quote(langtext)} may pull up something as well.")
100
 
101
+ st.write("## Older / Related Codes")
102
 
103
  st.write(f"ISO 639-3 'alpha3' code, 'terminology' or 'T' variant (deprecated): {t_variant}")
104
  st.write(f"ISO 639-3 'alpha3' code, 'bibliographic' or 'B' variant (deprecated): {b_variant}")
 
117
  st.write(t_obsolete_codes)
118
  elif b_obsolete_codes:
119
  st.write(f"Obsolete codes from previous ISO-639 iterations, pulled from https://iso639-3.sil.org/code/{b_variant}:")
120
+ st.write(b_obsolete_codes)
121
+
122
+
123
+ if results_from_vachan:
124
+ st.write("### Other potential matches, from Vachan Engine (experimental)")
125
+ st.write(results_from_vachan)
126
 
127
 
128