|
import json |
|
|
|
import gradio as gr |
|
import pandas as pd |
|
|
|
|
|
def read_json(file_name): |
|
with open(file_name, "r") as f: |
|
json_data = json.load(f) |
|
return json_data |
|
|
|
|
|
json_file = "awesome-japanese-nlp-resources-search.json" |
|
json_data = read_json(json_file) |
|
data = {"project_name": [], "source": [], "description": []} |
|
|
|
for data_json in json_data: |
|
url = data_json["url"] |
|
description = data_json["description"] |
|
project_name = data_json["project_name"] |
|
source = data_json["source"] |
|
data["project_name"].append(f"[{project_name}]({url})") |
|
data["source"].append(source) |
|
data["description"].append(description) |
|
|
|
data = pd.DataFrame(data) |
|
|
|
|
|
def show_search_results(query): |
|
contained = data["description"].str.contains(query) |
|
df_search = data[contained] |
|
return df_search |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown( |
|
""" |
|
# Awesome Japanese NLP resources search π |
|
You can search for open-source software from [1000+ Japanese NLP repositories](https://github.com/taishi-i/awesome-japanese-nlp-resources). |
|
""" |
|
) |
|
|
|
query = gr.Textbox( |
|
label="Search English or Japanese words", placeholder="llm" |
|
) |
|
df = gr.DataFrame(type="pandas", datatype="markdown", height=1000) |
|
|
|
query.change(fn=show_search_results, inputs=query, outputs=df) |
|
|
|
demo.launch() |
|
|