Spaces:
Sleeping
Sleeping
aboltachka
commited on
Commit
•
6cac978
1
Parent(s):
ddfbcd5
Upload app.py
Browse files
app.py
CHANGED
@@ -395,24 +395,24 @@ def rr_detector(title_raw, abstract_raw):
|
|
395 |
df_group = df_group[['type', 'term', 'freq']]
|
396 |
|
397 |
df_blackball = pd.DataFrame(list(blackball_count.items()), columns=['term', 'freq'])
|
398 |
-
df_blackball['type'] = '
|
399 |
df_blackball = df_blackball[['type', 'term', 'freq']]
|
400 |
|
401 |
df_details = pd.concat([df_group, df_issue, df_blackball], ignore_index=True)
|
402 |
issue_default = {'type': 'ISSUE', 'term': '', 'freq': ''}
|
403 |
group_default = {'type': 'GROUP', 'term': '', 'freq': ''}
|
404 |
-
blackball_default = {'type': '
|
405 |
df_details.loc[len(df_details)] = issue_default
|
406 |
df_details.loc[len(df_details)] = group_default
|
407 |
df_details.loc[len(df_details)] = blackball_default
|
408 |
-
df_details = df_details.sort_values(by='type', ascending=
|
409 |
|
410 |
#TEXT ANALYSIS
|
411 |
#Dictionary with issue, topic, and blackball keywords
|
412 |
-
keywords_dict = {"issue": [], "group": [], "
|
413 |
keywords_dict["issue"].extend(issue_count.keys())
|
414 |
keywords_dict["group"].extend(group_count.keys())
|
415 |
-
keywords_dict["
|
416 |
|
417 |
combined_text = f"TITLE:\n{title_raw} \n \nABSTRACT:\n{abstract_raw}"
|
418 |
|
@@ -449,7 +449,7 @@ def rr_detector(title_raw, abstract_raw):
|
|
449 |
#Explanation
|
450 |
unique_group_str = ', '.join(unique_group)
|
451 |
unique_issue_str = ', '.join(unique_issue)
|
452 |
-
answer = "This paper can be considered race-related, as it mentions at least one group keyword in the title. Or it mentions at least one group keyword AND at least one issue keyword in the title or abstract (excluding the last sentence). Furthermore, the algorithm does not identify any
|
453 |
else:
|
454 |
|
455 |
if len(blackball_count) > 0:
|
@@ -457,7 +457,7 @@ def rr_detector(title_raw, abstract_raw):
|
|
457 |
output_image = os.path.join(dirname, 'images/no.png')
|
458 |
#Explanation
|
459 |
unique_blackball_str = ', '.join(blackball_count)
|
460 |
-
answer = "This paper cannot be considered race-related, as it includes the
|
461 |
else:
|
462 |
#Result
|
463 |
output_image = os.path.join(dirname, 'images/no.png')
|
@@ -466,7 +466,7 @@ def rr_detector(title_raw, abstract_raw):
|
|
466 |
#Details
|
467 |
if len(issue_count.keys()) == 0 and len(group_count.keys()) == 0 and len(blackball_count.keys()) == 0 :
|
468 |
data = {
|
469 |
-
"type": ["
|
470 |
"term": ["term1", "term2", "term3"],
|
471 |
"freq": [0, 0, 0]
|
472 |
}
|
@@ -524,7 +524,7 @@ title_prompt = """
|
|
524 |
description_prompt = """
|
525 |
<p>This app is supplementary material to the <strong>"Race-related Research in Economics" paper</strong>, where we examine how academic economists contribute to discussions about racial justice and enduring economic disparities among different racial and ethnic groups. Specifically, we analyze the production of race-related research in Economics. Our study is based on the analysis of a corpus of 250,000 economics publications from 1960 to 2020, employing an algorithmic approach to classify race-related publications. <strong>This app enables users to verify whether their research can be categorized as race-related based on our algorithm</strong>.</p>
|
526 |
|
527 |
-
<p>If you would like our algorithm to classify your research, please submit the title and abstract of your paper. By default, the title and abstract of
|
528 |
|
529 |
"""
|
530 |
|
@@ -534,8 +534,8 @@ description_prompt = """
|
|
534 |
# APP LAUNCH
|
535 |
#####################
|
536 |
|
537 |
-
title_smpl = "
|
538 |
-
abstract_smpl = "
|
539 |
|
540 |
|
541 |
demo = gr.Interface(fn=rr_detector, inputs=[
|
@@ -564,7 +564,7 @@ demo = gr.Interface(fn=rr_detector, inputs=[
|
|
564 |
),
|
565 |
gr.HighlightedText(
|
566 |
label="Text Analysis",
|
567 |
-
color_map = {'group': 'blue', 'issue': 'green', '
|
568 |
),
|
569 |
], theme='Jameswiller/Globe', title = title_prompt, description = description_prompt, allow_flagging = 'auto')
|
570 |
|
|
|
395 |
df_group = df_group[['type', 'term', 'freq']]
|
396 |
|
397 |
df_blackball = pd.DataFrame(list(blackball_count.items()), columns=['term', 'freq'])
|
398 |
+
df_blackball['type'] = 'EXCEPTION'
|
399 |
df_blackball = df_blackball[['type', 'term', 'freq']]
|
400 |
|
401 |
df_details = pd.concat([df_group, df_issue, df_blackball], ignore_index=True)
|
402 |
issue_default = {'type': 'ISSUE', 'term': '', 'freq': ''}
|
403 |
group_default = {'type': 'GROUP', 'term': '', 'freq': ''}
|
404 |
+
blackball_default = {'type': 'EXCEPTION', 'term': '', 'freq': ''}
|
405 |
df_details.loc[len(df_details)] = issue_default
|
406 |
df_details.loc[len(df_details)] = group_default
|
407 |
df_details.loc[len(df_details)] = blackball_default
|
408 |
+
df_details = df_details.sort_values(by='type', ascending=True)
|
409 |
|
410 |
#TEXT ANALYSIS
|
411 |
#Dictionary with issue, topic, and blackball keywords
|
412 |
+
keywords_dict = {"issue": [], "group": [], "exception": []}
|
413 |
keywords_dict["issue"].extend(issue_count.keys())
|
414 |
keywords_dict["group"].extend(group_count.keys())
|
415 |
+
keywords_dict["exception"].extend(blackball_count.keys())
|
416 |
|
417 |
combined_text = f"TITLE:\n{title_raw} \n \nABSTRACT:\n{abstract_raw}"
|
418 |
|
|
|
449 |
#Explanation
|
450 |
unique_group_str = ', '.join(unique_group)
|
451 |
unique_issue_str = ', '.join(unique_issue)
|
452 |
+
answer = "This paper can be considered race-related, as it mentions at least one group keyword in the title. Or it mentions at least one group keyword AND at least one issue keyword in the title or abstract (excluding the last sentence). Furthermore, the algorithm does not identify any exception phrases in the title and abstract provided."
|
453 |
else:
|
454 |
|
455 |
if len(blackball_count) > 0:
|
|
|
457 |
output_image = os.path.join(dirname, 'images/no.png')
|
458 |
#Explanation
|
459 |
unique_blackball_str = ', '.join(blackball_count)
|
460 |
+
answer = "This paper cannot be considered race-related, as it includes the exception phrase(s), such as: " + unique_blackball_str + "."
|
461 |
else:
|
462 |
#Result
|
463 |
output_image = os.path.join(dirname, 'images/no.png')
|
|
|
466 |
#Details
|
467 |
if len(issue_count.keys()) == 0 and len(group_count.keys()) == 0 and len(blackball_count.keys()) == 0 :
|
468 |
data = {
|
469 |
+
"type": ["EXCEPTION", "ISSUE", "GROUP"],
|
470 |
"term": ["term1", "term2", "term3"],
|
471 |
"freq": [0, 0, 0]
|
472 |
}
|
|
|
524 |
description_prompt = """
|
525 |
<p>This app is supplementary material to the <strong>"Race-related Research in Economics" paper</strong>, where we examine how academic economists contribute to discussions about racial justice and enduring economic disparities among different racial and ethnic groups. Specifically, we analyze the production of race-related research in Economics. Our study is based on the analysis of a corpus of 250,000 economics publications from 1960 to 2020, employing an algorithmic approach to classify race-related publications. <strong>This app enables users to verify whether their research can be categorized as race-related based on our algorithm</strong>.</p>
|
526 |
|
527 |
+
<p>If you would like our algorithm to classify your research, please submit the title and abstract of your paper. By default, the title and abstract of Bertrand and Mullainathan (2004) are provided, and you can verify whether it is a race-related research.</p>
|
528 |
|
529 |
"""
|
530 |
|
|
|
534 |
# APP LAUNCH
|
535 |
#####################
|
536 |
|
537 |
+
title_smpl = "Are Emily and Greg More Employable Than Lakisha and Jamal? A Field Experiment on Labor Market Discrimination"
|
538 |
+
abstract_smpl = "We study race in the labor market by sending fictitious resumes to help-wanted ads in Boston and Chicago newspapers. To manipulate perceived race, resumes are randomly assigned African-American- or White-sounding names. White names receive 50 percent more callbacks for interviews. Callbacks are also more responsive to resume quality for White names than for African-American ones. The racial gap is uniform across occupation, industry, and employer size. We also find little evidence that employers are inferring social class from the names. Differential treatment by race still appears to still be prominent in the U. S. labor market."
|
539 |
|
540 |
|
541 |
demo = gr.Interface(fn=rr_detector, inputs=[
|
|
|
564 |
),
|
565 |
gr.HighlightedText(
|
566 |
label="Text Analysis",
|
567 |
+
color_map = {'group': 'blue', 'issue': 'green', 'exception': 'red'}
|
568 |
),
|
569 |
], theme='Jameswiller/Globe', title = title_prompt, description = description_prompt, allow_flagging = 'auto')
|
570 |
|