Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -59,35 +59,38 @@ def classify_text(text):
|
|
| 59 |
return output
|
| 60 |
|
| 61 |
# Example questions - mix of actual ESS data and generated diverse questions
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
| 64 |
["What is the highest level of education you have successfully completed?"],
|
| 65 |
["What is the highest level of education your mother successfully completed?"],
|
| 66 |
["How many years of full-time education have you completed?"],
|
| 67 |
|
| 68 |
-
# POLITICS
|
| 69 |
["Which party did you vote for in the last national election?"],
|
| 70 |
["Trust in country's parliament"],
|
| 71 |
["How satisfied are you with the way democracy works in your country?"],
|
| 72 |
["How much do you trust the legal system?"],
|
| 73 |
|
| 74 |
-
# HEALTH
|
| 75 |
["How satisfied are you with the healthcare system?"],
|
| 76 |
["Which health problems that you had in the last 12 months hampered you in your daily activities?"],
|
| 77 |
["How is your health in general - very good, good, fair, bad, or very bad?"],
|
| 78 |
|
| 79 |
-
# LABOUR AND EMPLOYMENT
|
| 80 |
["What best describes what you have been doing for the last 7 days - in paid work?"],
|
| 81 |
["Which description best describes the sort of work your mother did when you were 14?"],
|
| 82 |
["How many hours do you normally work per week in your main job?"],
|
| 83 |
["Are you a member of a trade union or similar organization?"],
|
| 84 |
|
| 85 |
-
# SOCIETY AND CULTURE
|
| 86 |
["How often do you pray apart from at religious services?"],
|
| 87 |
["How important is it to always behave properly and avoid doing anything people would say is wrong?"],
|
| 88 |
["Do you consider yourself as belonging to any particular religion or denomination?"],
|
| 89 |
|
| 90 |
-
# DEMOGRAPHY
|
| 91 |
["What is your age?"],
|
| 92 |
["What is your gender?"],
|
| 93 |
["What is your current legal marital status?"],
|
|
@@ -122,19 +125,35 @@ examples = [
|
|
| 122 |
["Do you rent or own your accommodation?"],
|
| 123 |
["How many rooms do you have for your household's use only?"],
|
| 124 |
|
| 125 |
-
# SOCIAL WELFARE
|
| 126 |
["Should the government reduce income differences?"],
|
| 127 |
["How satisfied are you with the state of social benefits in your country?"],
|
| 128 |
|
| 129 |
-
# TRANSPORT
|
| 130 |
["How long does your daily commute to work take?"],
|
| 131 |
["What is your main mode of transportation?"],
|
| 132 |
|
| 133 |
# SCIENCE AND TECHNOLOGY
|
| 134 |
["To what extent do you think scientific advances benefit society?"],
|
| 135 |
["How often do you use a smartphone or tablet?"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
]
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
# Custom CSS for Sikt branding using design tokens
|
| 139 |
custom_css = """
|
| 140 |
:root {
|
|
@@ -271,26 +290,26 @@ demo = gr.Interface(
|
|
| 271 |
categorizing them into subject areas. The model was trained on European Social Survey metadata
|
| 272 |
and can classify questions into <strong>19 categories</strong>:
|
| 273 |
</p>
|
| 274 |
-
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(
|
| 275 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 276 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 277 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 278 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 279 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 280 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 281 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 282 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 283 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 284 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 285 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 286 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 287 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 288 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 289 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 290 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 291 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 292 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 293 |
-
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.
|
| 294 |
</div>
|
| 295 |
</div>
|
| 296 |
|
|
|
|
| 59 |
return output
|
| 60 |
|
| 61 |
# Example questions - mix of actual ESS data and generated diverse questions
|
| 62 |
+
# Using exact category names from pydantic_classes.py
|
| 63 |
+
import random
|
| 64 |
+
|
| 65 |
+
all_examples = [
|
| 66 |
+
# EDUCATION
|
| 67 |
["What is the highest level of education you have successfully completed?"],
|
| 68 |
["What is the highest level of education your mother successfully completed?"],
|
| 69 |
["How many years of full-time education have you completed?"],
|
| 70 |
|
| 71 |
+
# POLITICS
|
| 72 |
["Which party did you vote for in the last national election?"],
|
| 73 |
["Trust in country's parliament"],
|
| 74 |
["How satisfied are you with the way democracy works in your country?"],
|
| 75 |
["How much do you trust the legal system?"],
|
| 76 |
|
| 77 |
+
# HEALTH
|
| 78 |
["How satisfied are you with the healthcare system?"],
|
| 79 |
["Which health problems that you had in the last 12 months hampered you in your daily activities?"],
|
| 80 |
["How is your health in general - very good, good, fair, bad, or very bad?"],
|
| 81 |
|
| 82 |
+
# LABOUR AND EMPLOYMENT
|
| 83 |
["What best describes what you have been doing for the last 7 days - in paid work?"],
|
| 84 |
["Which description best describes the sort of work your mother did when you were 14?"],
|
| 85 |
["How many hours do you normally work per week in your main job?"],
|
| 86 |
["Are you a member of a trade union or similar organization?"],
|
| 87 |
|
| 88 |
+
# SOCIETY AND CULTURE
|
| 89 |
["How often do you pray apart from at religious services?"],
|
| 90 |
["How important is it to always behave properly and avoid doing anything people would say is wrong?"],
|
| 91 |
["Do you consider yourself as belonging to any particular religion or denomination?"],
|
| 92 |
|
| 93 |
+
# DEMOGRAPHY (POPULATION, VITAL STATISTICS, AND CENSUSES)
|
| 94 |
["What is your age?"],
|
| 95 |
["What is your gender?"],
|
| 96 |
["What is your current legal marital status?"],
|
|
|
|
| 125 |
["Do you rent or own your accommodation?"],
|
| 126 |
["How many rooms do you have for your household's use only?"],
|
| 127 |
|
| 128 |
+
# SOCIAL WELFARE POLICY AND SYSTEMS
|
| 129 |
["Should the government reduce income differences?"],
|
| 130 |
["How satisfied are you with the state of social benefits in your country?"],
|
| 131 |
|
| 132 |
+
# TRANSPORT AND TRAVEL
|
| 133 |
["How long does your daily commute to work take?"],
|
| 134 |
["What is your main mode of transportation?"],
|
| 135 |
|
| 136 |
# SCIENCE AND TECHNOLOGY
|
| 137 |
["To what extent do you think scientific advances benefit society?"],
|
| 138 |
["How often do you use a smartphone or tablet?"],
|
| 139 |
+
|
| 140 |
+
# HISTORY
|
| 141 |
+
["What do you think about your country's colonial past?"],
|
| 142 |
+
["How important is it to preserve historical monuments?"],
|
| 143 |
+
|
| 144 |
+
# TRADE, INDUSTRY AND MARKETS
|
| 145 |
+
["Do you work in the private or public sector?"],
|
| 146 |
+
["How do you feel about free trade agreements?"],
|
| 147 |
+
|
| 148 |
+
# OTHER
|
| 149 |
+
["What are your thoughts on the future?"],
|
| 150 |
+
["How do you define quality of life?"],
|
| 151 |
]
|
| 152 |
|
| 153 |
+
# Shuffle and select 30 examples
|
| 154 |
+
random.seed(42) # For reproducibility
|
| 155 |
+
examples = random.sample(all_examples, min(30, len(all_examples)))
|
| 156 |
+
|
| 157 |
# Custom CSS for Sikt branding using design tokens
|
| 158 |
custom_css = """
|
| 159 |
:root {
|
|
|
|
| 290 |
categorizing them into subject areas. The model was trained on European Social Survey metadata
|
| 291 |
and can classify questions into <strong>19 categories</strong>:
|
| 292 |
</p>
|
| 293 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0.5rem; margin-top: 1rem;">
|
| 294 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π EDUCATION</span>
|
| 295 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">ποΈ POLITICS</span>
|
| 296 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π₯ HEALTH</span>
|
| 297 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">πΌ LABOUR AND EMPLOYMENT</span>
|
| 298 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π SOCIETY AND CULTURE</span>
|
| 299 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π° ECONOMICS</span>
|
| 300 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π§ PSYCHOLOGY</span>
|
| 301 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π₯ DEMOGRAPHY (POPULATION, VITAL STATISTICS, AND CENSUSES)</span>
|
| 302 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π HOUSING AND LAND USE</span>
|
| 303 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π± NATURAL ENVIRONMENT</span>
|
| 304 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">βοΈ LAW, CRIME AND LEGAL SYSTEMS</span>
|
| 305 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">πΊ MEDIA, COMMUNICATION AND LANGUAGE</span>
|
| 306 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π SOCIAL STRATIFICATION AND GROUPINGS</span>
|
| 307 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π€ SOCIAL WELFARE POLICY AND SYSTEMS</span>
|
| 308 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π TRANSPORT AND TRAVEL</span>
|
| 309 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">πͺ TRADE, INDUSTRY AND MARKETS</span>
|
| 310 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π¬ SCIENCE AND TECHNOLOGY</span>
|
| 311 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π HISTORY</span>
|
| 312 |
+
<span style="padding: 0.5rem; background: white; border-radius: 4px; font-size: 0.8rem; border-left: 3px solid #7d5da6;">π OTHER</span>
|
| 313 |
</div>
|
| 314 |
</div>
|
| 315 |
|