Upload with huggingface_hub
Browse files- README.md +6 -6
- __pycache__/run.cpython-36.pyc +0 -0
- app.py +23 -0
- screenshot.gif +0 -0
README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.3.1
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
+
title: gender_sentence_default_interpretation
|
| 4 |
+
emoji: 🔥
|
| 5 |
+
colorFrom: indigo
|
| 6 |
+
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
sdk_version: 3.3.1
|
| 9 |
+
|
| 10 |
app_file: app.py
|
| 11 |
pinned: false
|
| 12 |
---
|
|
|
|
|
|
__pycache__/run.cpython-36.pyc
ADDED
|
Binary file (1.04 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
male_words, female_words = ["he", "his", "him"], ["she", "hers", "her"]
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def gender_of_sentence(sentence):
|
| 7 |
+
male_count = len([word for word in sentence.split() if word.lower() in male_words])
|
| 8 |
+
female_count = len(
|
| 9 |
+
[word for word in sentence.split() if word.lower() in female_words]
|
| 10 |
+
)
|
| 11 |
+
total = max(male_count + female_count, 1)
|
| 12 |
+
return {"male": male_count / total, "female": female_count / total}
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn=gender_of_sentence,
|
| 17 |
+
inputs=gr.Textbox(value="She went to his house to get her keys."),
|
| 18 |
+
outputs="label",
|
| 19 |
+
interpretation="default",
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
demo.launch()
|
screenshot.gif
ADDED
|