aliabd commited on
Commit
2203637
·
1 Parent(s): 96d7390

Upload with huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +6 -6
  2. __pycache__/run.cpython-36.pyc +0 -0
  3. app.py +23 -0
  4. screenshot.gif +0 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Gender Sentence Default Interpretation
3
- emoji: 🏢
4
- colorFrom: green
5
- colorTo: red
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