aboltachka commited on
Commit
6cac978
1 Parent(s): ddfbcd5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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'] = 'WHITELIST'
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': 'WHITELIST', '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=False)
409
 
410
  #TEXT ANALYSIS
411
  #Dictionary with issue, topic, and blackball keywords
412
- keywords_dict = {"issue": [], "group": [], "whitelist": []}
413
  keywords_dict["issue"].extend(issue_count.keys())
414
  keywords_dict["group"].extend(group_count.keys())
415
- keywords_dict["whitelist"].extend(blackball_count.keys())
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 whitelist phrases in the title and abstract provided."
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 whitelist phrase(s), such as: " + unique_blackball_str + "."
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": ["WHITELIST", "ISSUE", "GROUP"],
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 our paper are provided, and you can verify whether it is a race-related research.</p>
528
 
529
  """
530
 
@@ -534,8 +534,8 @@ description_prompt = """
534
  # APP LAUNCH
535
  #####################
536
 
537
- title_smpl = "Race-related Research in Economics"
538
- abstract_smpl = "Issues of racial justice and persistent economic inequalities across racial and ethnic groups have risen to the top of public debate. The ability of academic economists to contribute to these debates in part depends on the production of race-related research in the profession. We study the issue combining information on a corpus of 250,000 publications in economics from 1960 to 2020 on which we use an algorithmic approach to classify race-related publications, constructing paths to publication for 22,000 NBER working papers between 1974 and 2015, and constructing the career prole of publications of 2800 economics faculty in US economics departments active in 2020/1. We present four new stylized facts on race-related research in economics. First, since 1960 less than 2% of publications in economics have been race related, with an uptick in such work since the mid 1990s. This represents a cumulative body of knowledge of 3801 race-related publications in economics since 1960. Second, the publications process provides little disincentive to produce race-related research: such work has similar or better publication outcomes as non race-related research. Third, Black faculty are significantly more likely to publish race-related work during their career. However, citations and H-indices are significantly lower for minority faculty as a whole. However, the citation penalty for Black faculty is partially offset for their race-related publications. Fourth, over later stages of the career life cycle, Black faculty become less likely to work on race-related topics. The timing of this change coincides with their career progression up the ranking of US academic departments. We draw together policy implications for the profession related to innovative areas of race-related research that economists can engage in, and processes to improve the selection and retention of minority faculty."
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', 'whitelist': 'red'}
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