Bohui Zhang
commited on
Commit
·
bbdaf4d
1
Parent(s):
1c5a4fe
Upload the second version
Browse files
app.py
CHANGED
|
@@ -53,6 +53,7 @@ with gr.Blocks() as introduction_tab:
|
|
| 53 |
- [RDFShape](https://rdfshape.weso.es)
|
| 54 |
- [ShExStatements](https://shexstatements.toolforge.org)
|
| 55 |
- A similar toolkit can be found [here on Toolforge](https://tools-static.wmflabs.org/entityschema-generator/).
|
|
|
|
| 56 |
"""
|
| 57 |
)
|
| 58 |
|
|
@@ -72,21 +73,26 @@ with gr.Blocks() as generate_tab:
|
|
| 72 |
label="Name of the new EntitySchema",
|
| 73 |
placeholder="e.g., algorithm"
|
| 74 |
)
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
class_choices = gr.Radio(visible=False) # TODO: remove the label
|
| 83 |
threshold_slider = gr.Slider(
|
| 84 |
-
minimum=10, maximum=100, value=50, step=10, label="
|
| 85 |
info="Ignore all properties that are used on less than X% of items in the class for the initial "
|
| 86 |
-
"EntitySchema generation"
|
| 87 |
)
|
| 88 |
# extra_checkbox = gr.Checkbox(label="Permitting extra properties")
|
| 89 |
# TODO: remove EXTRA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
generate_btn = gr.Button(value="Generate EntitySchema")
|
| 91 |
gr.Markdown(
|
| 92 |
"""
|
|
@@ -104,7 +110,7 @@ with gr.Blocks() as generate_tab:
|
|
| 104 |
refine_chatbot = gr.Chatbot(
|
| 105 |
label="Chatbot",
|
| 106 |
value=[[None, None]],
|
| 107 |
-
height=
|
| 108 |
)
|
| 109 |
# chatbot_input = gr.Textbox(placeholder="Type your message here :)")
|
| 110 |
with gr.Row():
|
|
@@ -124,7 +130,7 @@ with gr.Blocks() as generate_tab:
|
|
| 124 |
with gr.Column():
|
| 125 |
# TODO: meaningful error messages
|
| 126 |
es_output = gr.Code(
|
| 127 |
-
lines=
|
| 128 |
label="EntitySchema",
|
| 129 |
interactive=True,
|
| 130 |
)
|
|
@@ -148,7 +154,7 @@ with gr.Blocks() as generate_tab:
|
|
| 148 |
|
| 149 |
generate_btn.click(
|
| 150 |
fn=entity_schema_generation,
|
| 151 |
-
inputs=[es_name, es_class, threshold_slider],
|
| 152 |
outputs=[es_output, es_json, refine_chatbot]
|
| 153 |
)
|
| 154 |
|
|
|
|
| 53 |
- [RDFShape](https://rdfshape.weso.es)
|
| 54 |
- [ShExStatements](https://shexstatements.toolforge.org)
|
| 55 |
- A similar toolkit can be found [here on Toolforge](https://tools-static.wmflabs.org/entityschema-generator/).
|
| 56 |
+
- [ShEx2 Simple Online Validator](https://shex-simple.toolforge.org/wikidata/packages/shex-webapp/doc/shex-simple.html?data=Endpoint:%20https://query.wikidata.org/sparql&hideData&manifest=[]&textMapIsSparqlQuery)
|
| 57 |
"""
|
| 58 |
)
|
| 59 |
|
|
|
|
| 73 |
label="Name of the new EntitySchema",
|
| 74 |
placeholder="e.g., algorithm"
|
| 75 |
)
|
| 76 |
+
es_class = gr.Textbox(
|
| 77 |
+
label="Item ID for class",
|
| 78 |
+
placeholder="e.g., Q8366",
|
| 79 |
+
info="Specify which class the new EntitySchema will cover. The tool will look at all items that "
|
| 80 |
+
"are an 'instance of' (P31) the class."
|
| 81 |
+
)
|
| 82 |
+
class_choices = gr.Radio(visible=False) # TODO: remove the label
|
|
|
|
| 83 |
threshold_slider = gr.Slider(
|
| 84 |
+
minimum=10, maximum=100, value=50, step=10, label="Cutoff",
|
| 85 |
info="Ignore all properties that are used on less than X% of items in the class for the initial "
|
| 86 |
+
"EntitySchema generation."
|
| 87 |
)
|
| 88 |
# extra_checkbox = gr.Checkbox(label="Permitting extra properties")
|
| 89 |
# TODO: remove EXTRA
|
| 90 |
+
property_type_checkboxes = gr.CheckboxGroup(
|
| 91 |
+
choices=[("WikibaseItem", "wikibase:WikibaseItem"), ("ExternalId", "wikibase:ExternalId")],
|
| 92 |
+
value=["wikibase:WikibaseItem"],
|
| 93 |
+
label="Property types",
|
| 94 |
+
info="Select the Wikidata datatypes of properties you want to encompass. Default: 'WikibaseItem'."
|
| 95 |
+
)
|
| 96 |
generate_btn = gr.Button(value="Generate EntitySchema")
|
| 97 |
gr.Markdown(
|
| 98 |
"""
|
|
|
|
| 110 |
refine_chatbot = gr.Chatbot(
|
| 111 |
label="Chatbot",
|
| 112 |
value=[[None, None]],
|
| 113 |
+
height=420,
|
| 114 |
)
|
| 115 |
# chatbot_input = gr.Textbox(placeholder="Type your message here :)")
|
| 116 |
with gr.Row():
|
|
|
|
| 130 |
with gr.Column():
|
| 131 |
# TODO: meaningful error messages
|
| 132 |
es_output = gr.Code(
|
| 133 |
+
lines=70,
|
| 134 |
label="EntitySchema",
|
| 135 |
interactive=True,
|
| 136 |
)
|
|
|
|
| 154 |
|
| 155 |
generate_btn.click(
|
| 156 |
fn=entity_schema_generation,
|
| 157 |
+
inputs=[es_name, es_class, threshold_slider, property_type_checkboxes],
|
| 158 |
outputs=[es_output, es_json, refine_chatbot]
|
| 159 |
)
|
| 160 |
|