add Programming Launage search function
Browse files- app.py +49 -3
- awesome-japanese-nlp-resources-search.json +0 -0
app.py
CHANGED
@@ -12,27 +12,40 @@ def read_json(file_name):
|
|
12 |
|
13 |
json_file = "awesome-japanese-nlp-resources-search.json"
|
14 |
json_data = read_json(json_file)
|
15 |
-
data = {"project_name": [], "source": [], "description": []}
|
16 |
|
17 |
for data_json in json_data:
|
18 |
url = data_json["url"]
|
19 |
description = data_json["description"]
|
20 |
project_name = data_json["project_name"]
|
21 |
source = data_json["source"]
|
|
|
|
|
22 |
data["project_name"].append(f"[{project_name}]({url})")
|
23 |
data["source"].append(source)
|
24 |
data["description"].append(description)
|
|
|
25 |
|
26 |
data = pd.DataFrame(data)
|
27 |
|
28 |
|
29 |
-
def show_search_results(queries):
|
30 |
queries = queries.lower()
|
31 |
queries = queries.split()
|
32 |
|
33 |
df_search = data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
for query in queries:
|
35 |
contained_description = data["description"].str.contains(query)
|
|
|
36 |
contained_project_name = data["project_name"].str.contains(query)
|
37 |
df_search = df_search[contained_description | contained_project_name]
|
38 |
return df_search
|
@@ -49,10 +62,43 @@ with gr.Blocks() as demo:
|
|
49 |
query = gr.Textbox(
|
50 |
label="Search English or Japanese words", placeholder="llm"
|
51 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
df = gr.DataFrame(
|
53 |
value=data, type="pandas", datatype="markdown", height=1000
|
54 |
)
|
55 |
|
56 |
-
query.change(
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
demo.launch()
|
|
|
12 |
|
13 |
json_file = "awesome-japanese-nlp-resources-search.json"
|
14 |
json_data = read_json(json_file)
|
15 |
+
data = {"project_name": [], "source": [], "description": [], "languages": []}
|
16 |
|
17 |
for data_json in json_data:
|
18 |
url = data_json["url"]
|
19 |
description = data_json["description"]
|
20 |
project_name = data_json["project_name"]
|
21 |
source = data_json["source"]
|
22 |
+
languages = data_json["languages"]
|
23 |
+
|
24 |
data["project_name"].append(f"[{project_name}]({url})")
|
25 |
data["source"].append(source)
|
26 |
data["description"].append(description)
|
27 |
+
data["languages"].append(", ".join(languages))
|
28 |
|
29 |
data = pd.DataFrame(data)
|
30 |
|
31 |
|
32 |
+
def show_search_results(language_filter, queries):
|
33 |
queries = queries.lower()
|
34 |
queries = queries.split()
|
35 |
|
36 |
df_search = data
|
37 |
+
|
38 |
+
if language_filter:
|
39 |
+
regex_pattern = r"\b" + language_filter + r"\b"
|
40 |
+
df_search = df_search[
|
41 |
+
df_search["languages"].str.contains(
|
42 |
+
regex_pattern, case=False, regex=True, na=False
|
43 |
+
)
|
44 |
+
]
|
45 |
+
|
46 |
for query in queries:
|
47 |
contained_description = data["description"].str.contains(query)
|
48 |
+
|
49 |
contained_project_name = data["project_name"].str.contains(query)
|
50 |
df_search = df_search[contained_description | contained_project_name]
|
51 |
return df_search
|
|
|
62 |
query = gr.Textbox(
|
63 |
label="Search English or Japanese words", placeholder="llm"
|
64 |
)
|
65 |
+
languages = [
|
66 |
+
"Python",
|
67 |
+
"Jupyter Notebook",
|
68 |
+
"Java",
|
69 |
+
"C++",
|
70 |
+
"JavaScript",
|
71 |
+
"TypeScript",
|
72 |
+
"C#",
|
73 |
+
"Rust",
|
74 |
+
"Go",
|
75 |
+
"C",
|
76 |
+
"Kotlin",
|
77 |
+
"Ruby",
|
78 |
+
"Perl",
|
79 |
+
"Lua",
|
80 |
+
"PHP",
|
81 |
+
"Julia",
|
82 |
+
"R",
|
83 |
+
"Swift",
|
84 |
+
"Haskell",
|
85 |
+
"Scala",
|
86 |
+
]
|
87 |
+
|
88 |
+
language_selector = gr.Dropdown(
|
89 |
+
label="Programming Language",
|
90 |
+
choices=languages,
|
91 |
+
)
|
92 |
+
|
93 |
df = gr.DataFrame(
|
94 |
value=data, type="pandas", datatype="markdown", height=1000
|
95 |
)
|
96 |
|
97 |
+
query.change(
|
98 |
+
fn=show_search_results, inputs=[language_selector, query], outputs=df
|
99 |
+
)
|
100 |
+
language_selector.change(
|
101 |
+
fn=show_search_results, inputs=[language_selector, query], outputs=df
|
102 |
+
)
|
103 |
|
104 |
demo.launch()
|
awesome-japanese-nlp-resources-search.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|