jmLuis commited on
Commit
5847e15
1 Parent(s): f2c4379

Added table legend and link

Browse files
Files changed (1) hide show
  1. app.py +62 -13
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  from transformers import pipeline
3
  import html
4
 
5
- title = "MARISOL - Policy Issue Frame Classification"
6
 
7
  examples = [
8
  "Immigrants without HOPE need help entering college\n", #10
@@ -38,15 +38,64 @@ def classify(text):
38
  frame = pipe(paragraph)[0]["label"] + 1
39
  policyIssueFrame = code_frame_dict_toStr.get(frame, "Unknown Frame")
40
  results.extend([(paragraph, policyIssueFrame), ("\n\n", None)])
41
- return results
42
-
43
- demo = gr.Interface(
44
- fn=classify,
45
- inputs=gr.Textbox(lines=10, label="Input Text", placeholder="Insert article sentence here. Each sentence should be divided by line break to be classified separately..."),
46
- outputs=gr.HighlightedText(),
47
- title=title,
48
- examples=examples,
49
- allow_flagging="never",
50
- )
51
-
52
- demo.launch(share=True, debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from transformers import pipeline
3
  import html
4
 
5
+ title = "MARISOL - Policy Issue Frame Classification using fine-tuned RoBERTa"
6
 
7
  examples = [
8
  "Immigrants without HOPE need help entering college\n", #10
 
38
  frame = pipe(paragraph)[0]["label"] + 1
39
  policyIssueFrame = code_frame_dict_toStr.get(frame, "Unknown Frame")
40
  results.extend([(paragraph, policyIssueFrame), ("\n\n", None)])
41
+ return results
42
+
43
+ # demo = gr.Interface(
44
+ # fn=classify,
45
+ # inputs=gr.Textbox(lines=10, label="Input Text", placeholder="Insert article sentence here. Each sentence should be divided by line break to be classified separately..."),
46
+ # outputs=gr.HighlightedText(),
47
+ # title=title,
48
+ # examples=examples,
49
+ # allow_flagging="never",
50
+
51
+ # )
52
+
53
+ link_text = "Click here to visit Google"
54
+ link_url = "https://www.google.com"
55
+
56
+ def display_link():
57
+ return f'<a href="{link_url}" target="_blank">{link_text}</a>'
58
+
59
+ # Dummy input function, not used in this example
60
+ def dummy_input():
61
+ pass
62
+
63
+
64
+ values = [
65
+ ["1. Economic Frame", "Cost, benefits, or monetary/financial implications"],
66
+ ["2. Capacity and Resources Frame", "Lack of or availability of physical, geographical, spatial, human, and financial resources, or the capacity of existing systems and resources to implement policy goals."],
67
+ ["3. Morality Frame", "Policy objective or action that is compelled by religious doctrine or interpretation, duty, honor, righteousness, or any other sense of ethics or social responsibility"],
68
+ ["4. Fairness and Equality Frame", "Equality or inequality with which laws, punishment, rewards, and resources are applied or distributed. And the balance between the rights or interests"],
69
+ ["5. Constitutionality and Jurisprudence Frame", "The constraints imposed on or freedoms granted to individuals, government, and corporations via the Constitution, Bill of Rights, and other amendments, or judicial interpretation."],
70
+ ["6. Policy Prescription and Evaluation Frame", "Policies proposed for addressing an identified problem, and figuring out if certain policies will work"],
71
+ ["7. Law and Order, Crime and Justice Frame", "Policies in practice and their enforcement, incentives, and implications"],
72
+ ["8. Security and Defense Frame", "Security, threats to security, and protection of one’s person, family, in-group, nation, etc"],
73
+ ["9. Health and Safety Frame", "Healthcare access and effectiveness, illness, disease, sanitation, obesity, and mental health effects"],
74
+ ["10. Quality of Life Frame", "Effects of a policy on individuals’ wealth, mobility, access to resources, happiness, social structures, ease of day-to-day routines, quality of community life, etc"],
75
+ ["11. Cultural Identity Frame", "Social norms, trends, values, and customs constituting culture(s)"],
76
+ ["12. Public Opinion Frame", "References to general social attitudes"],
77
+ ["13. Political Frame", "Political considerations surrounding an issue"],
78
+ ["14. External Regulation and Reputation Frame", "Country’s external relations with other nation"],
79
+ ["15. Other", "Any frames that do not fit into the above categories"]
80
+ ]
81
+
82
+ with gr.Blocks() as demo:
83
+ with gr.Column():
84
+ gr.Interface(
85
+ fn=classify,
86
+ inputs=gr.Textbox(lines=10, label="Input Text", placeholder="Insert article sentence here. Each sentence should be divided by line break to be classified separately..."),
87
+ outputs=gr.HighlightedText(),
88
+ title=title,
89
+ examples=examples,
90
+ allow_flagging="never",)
91
+ gr.Dataframe(
92
+ value= values,
93
+ headers=["Policy Issue Frame", "Description"],
94
+ datatype=["str", "str"],
95
+ row_count=(15, "fixed"),
96
+ col_count=(2, "fixed"),
97
+ )
98
+ gr.HTML('<h2>Google colab <a href="https://colab.research.google.com/drive/1RtQNGbpY2sMtKTNzbZfdm1l_ScJ9pQkC?usp=sharing"> link for the Scraping Tool </a></h@>')
99
+
100
+ if __name__ == "__main__":
101
+ demo.launch(share=True, debug=True)