Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- README.md +6 -5
- app.py +809 -0
- markdown.py +25 -0
- requirements.txt +4 -0
README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.28.3
|
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 |
+
title: 🖱️ Anotación de Clickbaits
|
3 |
+
emoji: 🖱️
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: gray
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.28.3
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,809 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
import huggingface_hub
|
7 |
+
from filelock import FileLock
|
8 |
+
|
9 |
+
|
10 |
+
from markdown import GUIDELINES,HEADER
|
11 |
+
|
12 |
+
|
13 |
+
os.makedirs("downloaded_data/data/train", exist_ok=True)
|
14 |
+
os.makedirs("downloaded_data/data/validation", exist_ok=True)
|
15 |
+
os.makedirs("downloaded_data/data/test", exist_ok=True)
|
16 |
+
|
17 |
+
def html_progress_bar(split: str):
|
18 |
+
|
19 |
+
if split == "0":
|
20 |
+
percentage = 0
|
21 |
+
elif split == "100":
|
22 |
+
percentage = 100
|
23 |
+
else:
|
24 |
+
total = 0
|
25 |
+
annotations = 0
|
26 |
+
dataset_dir = os.path.join("downloaded_data/data", split)
|
27 |
+
|
28 |
+
for filename in os.listdir(dataset_dir):
|
29 |
+
if not filename.endswith(".json"):
|
30 |
+
continue
|
31 |
+
with open(os.path.join(dataset_dir, filename), "r", encoding="utf8") as file:
|
32 |
+
data = json.load(file)
|
33 |
+
n = len(data["results"]["generalScore"])
|
34 |
+
total += 2
|
35 |
+
if n == 1:
|
36 |
+
annotations += 1
|
37 |
+
if n > 1:
|
38 |
+
annotations += 2
|
39 |
+
|
40 |
+
if total == 0:
|
41 |
+
percentage = 100
|
42 |
+
else:
|
43 |
+
percentage = (annotations / total) * 100
|
44 |
+
return f"""
|
45 |
+
<!DOCTYPE html>
|
46 |
+
<html lang="en">
|
47 |
+
<head>
|
48 |
+
<meta charset="UTF-8">
|
49 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
50 |
+
<title>Progress Bar</title>
|
51 |
+
<style>
|
52 |
+
.progress-container {{
|
53 |
+
width: 100%;
|
54 |
+
background-color: #ffffff;
|
55 |
+
}}
|
56 |
+
.progress-bar {{
|
57 |
+
width: {percentage}%;
|
58 |
+
height: 30px;
|
59 |
+
background-color: #d1fae5;
|
60 |
+
text-align: center;
|
61 |
+
line-height: 30px;
|
62 |
+
color: white;
|
63 |
+
}}
|
64 |
+
</style>
|
65 |
+
</head>
|
66 |
+
<body>
|
67 |
+
|
68 |
+
<div class="progress-container">
|
69 |
+
<div class="progress-bar">{percentage:.0f}%</div>
|
70 |
+
</div>
|
71 |
+
</body>
|
72 |
+
</html>
|
73 |
+
"""
|
74 |
+
|
75 |
+
|
76 |
+
class ExampleGetter:
|
77 |
+
def __init__(self):
|
78 |
+
# Download data from the Hugging Face Hub
|
79 |
+
huggingface_hub.snapshot_download(
|
80 |
+
"Iker/ClickbaitDetectorData",
|
81 |
+
repo_type="dataset",
|
82 |
+
token=os.environ.get("TOKEN") or True,
|
83 |
+
local_dir="./downloaded_data",
|
84 |
+
)
|
85 |
+
|
86 |
+
def get_example(self, split: str):
|
87 |
+
if split not in ["train", "validation", "test"]:
|
88 |
+
raise ValueError(
|
89 |
+
f"split must be one of 'train','validation','test'. Got {split}"
|
90 |
+
)
|
91 |
+
|
92 |
+
# Iterate over the dataset
|
93 |
+
dataset_dir = os.path.join("downloaded_data/data", split)
|
94 |
+
# Iterate over all json files in the directory
|
95 |
+
results_dictionary = {}
|
96 |
+
|
97 |
+
for filename in os.listdir(dataset_dir):
|
98 |
+
if not filename.endswith(".json"):
|
99 |
+
continue
|
100 |
+
with open(os.path.join(dataset_dir, filename)) as file:
|
101 |
+
data = json.load(file)
|
102 |
+
|
103 |
+
n = len(data["results"]["generalScore"])
|
104 |
+
if n in results_dictionary:
|
105 |
+
results_dictionary[n].append(filename)
|
106 |
+
else:
|
107 |
+
results_dictionary[n] = [filename]
|
108 |
+
|
109 |
+
if len(results_dictionary) == 0:
|
110 |
+
return (
|
111 |
+
"No hay ejemplos disponibles para anotar",
|
112 |
+
"No hay ejemplos disponibles para anotar",
|
113 |
+
"No hay ejemplos disponibles para anotar",
|
114 |
+
"No hay ejemplos disponibles para anotar",
|
115 |
+
"No hay ejemplos disponibles para anotar",
|
116 |
+
)
|
117 |
+
# Get a random example
|
118 |
+
min_n = min(results_dictionary.keys())
|
119 |
+
examples = results_dictionary[min_n]
|
120 |
+
choosen_file = random.choice(examples)
|
121 |
+
choosen_file = os.path.join(dataset_dir, choosen_file)
|
122 |
+
|
123 |
+
with open(choosen_file, "r", encoding="utf8") as file:
|
124 |
+
data = json.load(file)
|
125 |
+
|
126 |
+
return (
|
127 |
+
choosen_file,
|
128 |
+
data["title"],
|
129 |
+
data["content"],
|
130 |
+
data["gpt_title"],
|
131 |
+
data["gpt_summary"],
|
132 |
+
)
|
133 |
+
|
134 |
+
def update_example(
|
135 |
+
self,
|
136 |
+
file_name: str,
|
137 |
+
exageracion: int,
|
138 |
+
discrepancia: int,
|
139 |
+
promesas: int,
|
140 |
+
incompleto: int,
|
141 |
+
urgencia: int,
|
142 |
+
sensacionalismo: int,
|
143 |
+
manipulacion: int,
|
144 |
+
contexto: int,
|
145 |
+
generalScore: int,
|
146 |
+
summary: str,
|
147 |
+
title: str,
|
148 |
+
):
|
149 |
+
if file_name == "Pulsa ▶️":
|
150 |
+
return (
|
151 |
+
html_progress_bar("0"),
|
152 |
+
"Pulsa ▶️",
|
153 |
+
"Pulsa ▶️",
|
154 |
+
"Pulsa ▶️",
|
155 |
+
"Pulsa ▶️",
|
156 |
+
"Pulsa ▶️",
|
157 |
+
0,
|
158 |
+
0,
|
159 |
+
0,
|
160 |
+
0,
|
161 |
+
0,
|
162 |
+
0,
|
163 |
+
0,
|
164 |
+
0,
|
165 |
+
0,
|
166 |
+
)
|
167 |
+
if file_name == "No hay ejemplos disponibles para anotar":
|
168 |
+
return (
|
169 |
+
html_progress_bar("100"),
|
170 |
+
"No hay ejemplos disponibles para anotar",
|
171 |
+
"No hay ejemplos disponibles para anotar",
|
172 |
+
"No hay ejemplos disponibles para anotar",
|
173 |
+
"No hay ejemplos disponibles para anotar",
|
174 |
+
"No hay ejemplos disponibles para anotar",
|
175 |
+
0,
|
176 |
+
0,
|
177 |
+
0,
|
178 |
+
0,
|
179 |
+
0,
|
180 |
+
0,
|
181 |
+
0,
|
182 |
+
0,
|
183 |
+
0,
|
184 |
+
)
|
185 |
+
# Update the example with the new scores
|
186 |
+
split = file_name.split("/")[2]
|
187 |
+
file_path = file_name
|
188 |
+
|
189 |
+
# Filelock
|
190 |
+
with FileLock(file_path + ".lock"):
|
191 |
+
with open(file_path, "r", encoding="utf8") as file:
|
192 |
+
data = json.load(file)
|
193 |
+
|
194 |
+
data["gpt_summary"] = summary
|
195 |
+
data["gpt_title"] = title
|
196 |
+
|
197 |
+
data["results"]["exageracion"].append(exageracion)
|
198 |
+
data["results"]["discrepancia"].append(discrepancia)
|
199 |
+
data["results"]["promesas"].append(promesas)
|
200 |
+
data["results"]["incompleto"].append(incompleto)
|
201 |
+
data["results"]["urgencia"].append(urgencia)
|
202 |
+
data["results"]["sensacionalismo"].append(sensacionalismo)
|
203 |
+
data["results"]["contexto"].append(contexto)
|
204 |
+
data["results"]["manipulacion"].append(manipulacion)
|
205 |
+
data["results"]["generalScore"].append(generalScore)
|
206 |
+
|
207 |
+
with open(file_path, "w", encoding="utf8") as file:
|
208 |
+
json.dump(data, file, indent=4, ensure_ascii=False)
|
209 |
+
|
210 |
+
# Update the example in the hub
|
211 |
+
huggingface_hub.upload_file(
|
212 |
+
repo_id="Iker/ClickbaitDetectorData",
|
213 |
+
repo_type="dataset",
|
214 |
+
token=os.environ.get("TOKEN") or True,
|
215 |
+
path_in_repo="/".join(file_path.split("/")[1:]),
|
216 |
+
path_or_fileobj=file_path,
|
217 |
+
)
|
218 |
+
|
219 |
+
file_name, title, content, gpt_title, gpt_summary = self.get_example(split)
|
220 |
+
return (
|
221 |
+
html_progress_bar(split),
|
222 |
+
file_name,
|
223 |
+
title,
|
224 |
+
content,
|
225 |
+
gpt_title,
|
226 |
+
gpt_summary,
|
227 |
+
0,
|
228 |
+
0,
|
229 |
+
0,
|
230 |
+
0,
|
231 |
+
0,
|
232 |
+
0,
|
233 |
+
0,
|
234 |
+
0,
|
235 |
+
0,
|
236 |
+
)
|
237 |
+
|
238 |
+
def start_train(self):
|
239 |
+
file_name, title, content, gpt_title, gpt_summary = self.get_example("train")
|
240 |
+
return (
|
241 |
+
html_progress_bar("train"),
|
242 |
+
file_name,
|
243 |
+
title,
|
244 |
+
content,
|
245 |
+
gpt_title,
|
246 |
+
gpt_summary,
|
247 |
+
0,
|
248 |
+
0,
|
249 |
+
0,
|
250 |
+
0,
|
251 |
+
0,
|
252 |
+
0,
|
253 |
+
0,
|
254 |
+
0,
|
255 |
+
0,
|
256 |
+
)
|
257 |
+
|
258 |
+
def start_validation(self):
|
259 |
+
file_name, title, content, gpt_title, gpt_summary = self.get_example(
|
260 |
+
"validation"
|
261 |
+
)
|
262 |
+
return (
|
263 |
+
html_progress_bar("validation"),
|
264 |
+
file_name,
|
265 |
+
title,
|
266 |
+
content,
|
267 |
+
gpt_title,
|
268 |
+
gpt_summary,
|
269 |
+
0,
|
270 |
+
0,
|
271 |
+
0,
|
272 |
+
0,
|
273 |
+
0,
|
274 |
+
0,
|
275 |
+
0,
|
276 |
+
0,
|
277 |
+
0,
|
278 |
+
)
|
279 |
+
|
280 |
+
def start_test(self):
|
281 |
+
file_name, title, content, gpt_title, gpt_summary = self.get_example("test")
|
282 |
+
return (
|
283 |
+
html_progress_bar("test"),
|
284 |
+
file_name,
|
285 |
+
title,
|
286 |
+
content,
|
287 |
+
gpt_title,
|
288 |
+
gpt_summary,
|
289 |
+
0,
|
290 |
+
0,
|
291 |
+
0,
|
292 |
+
0,
|
293 |
+
0,
|
294 |
+
0,
|
295 |
+
0,
|
296 |
+
0,
|
297 |
+
0,
|
298 |
+
)
|
299 |
+
|
300 |
+
|
301 |
+
example_getter = ExampleGetter()
|
302 |
+
|
303 |
+
theme = gr.themes.Soft(
|
304 |
+
primary_hue="emerald",
|
305 |
+
secondary_hue="cyan",
|
306 |
+
text_size="md",
|
307 |
+
spacing_size="lg",
|
308 |
+
font=[
|
309 |
+
gr.themes.GoogleFont("Poppins"),
|
310 |
+
gr.themes.GoogleFont("Poppins"),
|
311 |
+
gr.themes.GoogleFont("Poppins"),
|
312 |
+
gr.themes.GoogleFont("Poppins"),
|
313 |
+
],
|
314 |
+
).set(
|
315 |
+
block_background_fill="*neutral_50",
|
316 |
+
block_background_fill_dark="*neutral_950",
|
317 |
+
section_header_text_size="*text_lg",
|
318 |
+
section_header_text_weight="800",
|
319 |
+
)
|
320 |
+
|
321 |
+
file_name = "Pulsa ▶️"
|
322 |
+
title = "Pulsa ▶️"
|
323 |
+
content = "Pulsa ▶️"
|
324 |
+
gpt_title = "Pulsa ▶️"
|
325 |
+
gpt_summary = "Pulsa ▶️"
|
326 |
+
|
327 |
+
|
328 |
+
with gr.Blocks(
|
329 |
+
theme=theme,
|
330 |
+
title="🖱️ Anotación de Clickbait",
|
331 |
+
analytics_enabled=False,
|
332 |
+
fill_height=True,
|
333 |
+
) as demo:
|
334 |
+
|
335 |
+
gr.Markdown(HEADER)
|
336 |
+
|
337 |
+
with gr.Tab("Guidelines de anotación") as tab_guidelines:
|
338 |
+
gr.Markdown(GUIDELINES)
|
339 |
+
|
340 |
+
with gr.Tab("Train") as tab_progress:
|
341 |
+
gr_play = gr.Button("▶️ Empieza a anotar")
|
342 |
+
|
343 |
+
gr_filename = gr.Textbox(
|
344 |
+
label="Nombre del archivo",
|
345 |
+
value=file_name,
|
346 |
+
lines=1,
|
347 |
+
interactive=False,
|
348 |
+
visible=True,
|
349 |
+
)
|
350 |
+
gr_progress = gr.HTML(value=html_progress_bar("train"), label="Progreso")
|
351 |
+
gr_title = gr.Textbox(label="Título", value=title, lines=1, interactive=False)
|
352 |
+
gr_title_gpt = gr.Textbox(
|
353 |
+
label="Título GPT", value=gpt_title, lines=1, interactive=True
|
354 |
+
)
|
355 |
+
|
356 |
+
gr_summary = gr.Textbox(
|
357 |
+
label="Resumen GPT", value=gpt_summary, lines=4, interactive=True
|
358 |
+
)
|
359 |
+
|
360 |
+
with gr.Accordion("Ver texto completo", open=False):
|
361 |
+
gr_content = gr.Textbox(
|
362 |
+
label="Contenido",
|
363 |
+
lines=15,
|
364 |
+
value=content,
|
365 |
+
interactive=False,
|
366 |
+
)
|
367 |
+
|
368 |
+
gr_exageracion = gr.Slider(
|
369 |
+
label="Exageración",
|
370 |
+
minimum=0,
|
371 |
+
maximum=10,
|
372 |
+
step=1,
|
373 |
+
value=0,
|
374 |
+
info="Se identifica y evalua el uso de afirmaciones excesivas o superlativas que pueden distorsionar la realidad del contenido ofrecido.",
|
375 |
+
)
|
376 |
+
gr_discrepancia = gr.Slider(
|
377 |
+
label="Discrepancia Título-Contenido",
|
378 |
+
minimum=0,
|
379 |
+
maximum=10,
|
380 |
+
step=1,
|
381 |
+
value=0,
|
382 |
+
info="Se evalua la coherencia entre los titulares y el cuerpo del artículo, asegurando que las expectativas generadas se cumplan efectivamente.",
|
383 |
+
)
|
384 |
+
gr_promesas = gr.Slider(
|
385 |
+
label="Promesas Incumplidas",
|
386 |
+
minimum=0,
|
387 |
+
maximum=10,
|
388 |
+
step=1,
|
389 |
+
value=0,
|
390 |
+
info="Se detecta cuando los titulares hacen promesas específicas que el contenido no logra satisfacer, manteniendo un estándar de integridad informativa.",
|
391 |
+
)
|
392 |
+
gr_incompleto = gr.Slider(
|
393 |
+
label="Información Incompleta",
|
394 |
+
minimum=0,
|
395 |
+
maximum=10,
|
396 |
+
step=1,
|
397 |
+
value=0,
|
398 |
+
info="Se identifica la omisión de detalles cruciales que son necesarios para una comprensión completa del tema, evitando tácticas que buscan meramente incentivar clics.",
|
399 |
+
)
|
400 |
+
gr_urgencia = gr.Slider(
|
401 |
+
label="Urgencia Artificial",
|
402 |
+
minimum=0,
|
403 |
+
maximum=10,
|
404 |
+
step=1,
|
405 |
+
value=0,
|
406 |
+
info="Se evalua el uso de frases que intentan crear una percepción de necesidad inmediata o limitación temporal sin justificación real.",
|
407 |
+
)
|
408 |
+
gr_sensacionalismo = gr.Slider(
|
409 |
+
label="Sensacionalismo",
|
410 |
+
minimum=0,
|
411 |
+
maximum=10,
|
412 |
+
step=1,
|
413 |
+
value=0,
|
414 |
+
info="Se distingue el contenido que busca impactar emocionalmente al lector mediante el uso de afirmaciones alarmantes o escandalosas sin fundamento sólido.",
|
415 |
+
)
|
416 |
+
gr_contexto = gr.Slider(
|
417 |
+
label="Omisión de Contexto",
|
418 |
+
minimum=0,
|
419 |
+
maximum=10,
|
420 |
+
step=1,
|
421 |
+
value=0,
|
422 |
+
info="Se revela la falta de información contextual que es esencial para entender completamente la noticia o el argumento presentado.",
|
423 |
+
)
|
424 |
+
gr_manipulacion = gr.Slider(
|
425 |
+
label="Influencia",
|
426 |
+
minimum=0,
|
427 |
+
maximum=10,
|
428 |
+
step=1,
|
429 |
+
value=0,
|
430 |
+
info="Se analizan las técnicas utilizadas para influir en la percepción del lector o dirigir sus conclusiones de manera sesgada o con fines específicos.",
|
431 |
+
)
|
432 |
+
gr_generalScore = gr.Slider(
|
433 |
+
label="Clasificación General",
|
434 |
+
minimum=0,
|
435 |
+
maximum=100,
|
436 |
+
value=0,
|
437 |
+
info="Clasificación general del nivel de clickbait del artículo en una escala del 0 al 100, donde 0 significa que el artículo no es clickbait y 100 significa que el artículo es clickbait en su máxima expresión.",
|
438 |
+
)
|
439 |
+
save = gr.Button("💾 Enviar")
|
440 |
+
gr_play.click(
|
441 |
+
fn=example_getter.start_train,
|
442 |
+
outputs=[
|
443 |
+
gr_progress,
|
444 |
+
gr_filename,
|
445 |
+
gr_title,
|
446 |
+
gr_content,
|
447 |
+
gr_title_gpt,
|
448 |
+
gr_summary,
|
449 |
+
gr_exageracion,
|
450 |
+
gr_discrepancia,
|
451 |
+
gr_promesas,
|
452 |
+
gr_incompleto,
|
453 |
+
gr_urgencia,
|
454 |
+
gr_sensacionalismo,
|
455 |
+
gr_manipulacion,
|
456 |
+
gr_contexto,
|
457 |
+
gr_generalScore,
|
458 |
+
],
|
459 |
+
)
|
460 |
+
|
461 |
+
save.click(
|
462 |
+
fn=example_getter.update_example,
|
463 |
+
inputs=[
|
464 |
+
gr_filename,
|
465 |
+
gr_exageracion,
|
466 |
+
gr_discrepancia,
|
467 |
+
gr_promesas,
|
468 |
+
gr_incompleto,
|
469 |
+
gr_urgencia,
|
470 |
+
gr_sensacionalismo,
|
471 |
+
gr_manipulacion,
|
472 |
+
gr_contexto,
|
473 |
+
gr_generalScore,
|
474 |
+
gr_summary,
|
475 |
+
gr_title,
|
476 |
+
],
|
477 |
+
outputs=[
|
478 |
+
gr_progress,
|
479 |
+
gr_filename,
|
480 |
+
gr_title,
|
481 |
+
gr_content,
|
482 |
+
gr_title_gpt,
|
483 |
+
gr_summary,
|
484 |
+
gr_exageracion,
|
485 |
+
gr_discrepancia,
|
486 |
+
gr_promesas,
|
487 |
+
gr_incompleto,
|
488 |
+
gr_urgencia,
|
489 |
+
gr_sensacionalismo,
|
490 |
+
gr_manipulacion,
|
491 |
+
gr_contexto,
|
492 |
+
gr_generalScore,
|
493 |
+
],
|
494 |
+
)
|
495 |
+
|
496 |
+
with gr.Tab("Validation") as tab_progress:
|
497 |
+
gr_play = gr.Button("▶️ Empieza a anotar")
|
498 |
+
|
499 |
+
gr_filename = gr.Textbox(
|
500 |
+
label="Nombre del archivo",
|
501 |
+
value=file_name,
|
502 |
+
lines=1,
|
503 |
+
interactive=False,
|
504 |
+
visible=True,
|
505 |
+
)
|
506 |
+
gr_progress = gr.HTML(value=html_progress_bar("validation"), label="Progreso")
|
507 |
+
gr_title = gr.Textbox(label="Título", value=title, lines=1, interactive=False)
|
508 |
+
gr_title_gpt = gr.Textbox(
|
509 |
+
label="Título GPT", value=gpt_title, lines=1, interactive=True
|
510 |
+
)
|
511 |
+
|
512 |
+
gr_summary = gr.Textbox(
|
513 |
+
label="Resumen GPT", value=gpt_summary, lines=4, interactive=True
|
514 |
+
)
|
515 |
+
|
516 |
+
with gr.Accordion("Ver texto completo", open=False):
|
517 |
+
gr_content = gr.Textbox(
|
518 |
+
label="Contenido",
|
519 |
+
lines=15,
|
520 |
+
value=content,
|
521 |
+
interactive=False,
|
522 |
+
)
|
523 |
+
|
524 |
+
gr_exageracion = gr.Slider(
|
525 |
+
label="Exageración",
|
526 |
+
minimum=0,
|
527 |
+
maximum=10,
|
528 |
+
step=1,
|
529 |
+
value=0,
|
530 |
+
info="Se identifica y evalua el uso de afirmaciones excesivas o superlativas que pueden distorsionar la realidad del contenido ofrecido.",
|
531 |
+
)
|
532 |
+
gr_discrepancia = gr.Slider(
|
533 |
+
label="Discrepancia Título-Contenido",
|
534 |
+
minimum=0,
|
535 |
+
maximum=10,
|
536 |
+
step=1,
|
537 |
+
value=0,
|
538 |
+
info="Se evalua la coherencia entre los titulares y el cuerpo del artículo, asegurando que las expectativas generadas se cumplan efectivamente.",
|
539 |
+
)
|
540 |
+
gr_promesas = gr.Slider(
|
541 |
+
label="Promesas Incumplidas",
|
542 |
+
minimum=0,
|
543 |
+
maximum=10,
|
544 |
+
step=1,
|
545 |
+
value=0,
|
546 |
+
info="Se detecta cuando los titulares hacen promesas específicas que el contenido no logra satisfacer, manteniendo un estándar de integridad informativa.",
|
547 |
+
)
|
548 |
+
gr_incompleto = gr.Slider(
|
549 |
+
label="Información Incompleta",
|
550 |
+
minimum=0,
|
551 |
+
maximum=10,
|
552 |
+
step=1,
|
553 |
+
value=0,
|
554 |
+
info="Se identifica la omisión de detalles cruciales que son necesarios para una comprensión completa del tema, evitando tácticas que buscan meramente incentivar clics.",
|
555 |
+
)
|
556 |
+
gr_urgencia = gr.Slider(
|
557 |
+
label="Urgencia Artificial",
|
558 |
+
minimum=0,
|
559 |
+
maximum=10,
|
560 |
+
step=1,
|
561 |
+
value=0,
|
562 |
+
info="Se evalua el uso de frases que intentan crear una percepción de necesidad inmediata o limitación temporal sin justificación real.",
|
563 |
+
)
|
564 |
+
gr_sensacionalismo = gr.Slider(
|
565 |
+
label="Sensacionalismo",
|
566 |
+
minimum=0,
|
567 |
+
maximum=10,
|
568 |
+
step=1,
|
569 |
+
value=0,
|
570 |
+
info="Se distingue el contenido que busca impactar emocionalmente al lector mediante el uso de afirmaciones alarmantes o escandalosas sin fundamento sólido.",
|
571 |
+
)
|
572 |
+
gr_contexto = gr.Slider(
|
573 |
+
label="Omisión de Contexto",
|
574 |
+
minimum=0,
|
575 |
+
maximum=10,
|
576 |
+
step=1,
|
577 |
+
value=0,
|
578 |
+
info="Se revela la falta de información contextual que es esencial para entender completamente la noticia o el argumento presentado.",
|
579 |
+
)
|
580 |
+
gr_manipulacion = gr.Slider(
|
581 |
+
label="Influencia",
|
582 |
+
minimum=0,
|
583 |
+
maximum=10,
|
584 |
+
step=1,
|
585 |
+
value=0,
|
586 |
+
info="Se analizan las técnicas utilizadas para influir en la percepción del lector o dirigir sus conclusiones de manera sesgada o con fines específicos.",
|
587 |
+
)
|
588 |
+
gr_generalScore = gr.Slider(
|
589 |
+
label="Clasificación General",
|
590 |
+
minimum=0,
|
591 |
+
maximum=100,
|
592 |
+
value=0,
|
593 |
+
info="Clasificación general del nivel de clickbait del artículo en una escala del 0 al 100, donde 0 significa que el artículo no es clickbait y 100 significa que el artículo es clickbait en su máxima expresión.",
|
594 |
+
)
|
595 |
+
save = gr.Button("💾 Enviar")
|
596 |
+
save.click(
|
597 |
+
fn=example_getter.update_example,
|
598 |
+
inputs=[
|
599 |
+
gr_filename,
|
600 |
+
gr_exageracion,
|
601 |
+
gr_discrepancia,
|
602 |
+
gr_promesas,
|
603 |
+
gr_incompleto,
|
604 |
+
gr_urgencia,
|
605 |
+
gr_sensacionalismo,
|
606 |
+
gr_manipulacion,
|
607 |
+
gr_contexto,
|
608 |
+
gr_generalScore,
|
609 |
+
gr_summary,
|
610 |
+
gr_title,
|
611 |
+
],
|
612 |
+
outputs=[
|
613 |
+
gr_progress,
|
614 |
+
gr_filename,
|
615 |
+
gr_title,
|
616 |
+
gr_content,
|
617 |
+
gr_title_gpt,
|
618 |
+
gr_summary,
|
619 |
+
gr_exageracion,
|
620 |
+
gr_discrepancia,
|
621 |
+
gr_promesas,
|
622 |
+
gr_incompleto,
|
623 |
+
gr_urgencia,
|
624 |
+
gr_sensacionalismo,
|
625 |
+
gr_manipulacion,
|
626 |
+
gr_contexto,
|
627 |
+
gr_generalScore,
|
628 |
+
],
|
629 |
+
)
|
630 |
+
|
631 |
+
gr_play.click(
|
632 |
+
fn=example_getter.start_validation,
|
633 |
+
outputs=[
|
634 |
+
gr_progress,
|
635 |
+
gr_filename,
|
636 |
+
gr_title,
|
637 |
+
gr_content,
|
638 |
+
gr_title_gpt,
|
639 |
+
gr_summary,
|
640 |
+
gr_exageracion,
|
641 |
+
gr_discrepancia,
|
642 |
+
gr_promesas,
|
643 |
+
gr_incompleto,
|
644 |
+
gr_urgencia,
|
645 |
+
gr_sensacionalismo,
|
646 |
+
gr_manipulacion,
|
647 |
+
gr_contexto,
|
648 |
+
gr_generalScore,
|
649 |
+
],
|
650 |
+
)
|
651 |
+
|
652 |
+
with gr.Tab("Test") as tab_progress:
|
653 |
+
gr_play = gr.Button("▶️ Empieza a anotar")
|
654 |
+
|
655 |
+
gr_filename = gr.Textbox(
|
656 |
+
label="Nombre del archivo",
|
657 |
+
value=file_name,
|
658 |
+
lines=1,
|
659 |
+
interactive=False,
|
660 |
+
visible=True,
|
661 |
+
)
|
662 |
+
gr_progress = gr.HTML(value=html_progress_bar("test"), label="Progreso")
|
663 |
+
gr_title = gr.Textbox(label="Título", value=title, lines=1, interactive=False)
|
664 |
+
gr_title_gpt = gr.Textbox(
|
665 |
+
label="Título GPT", value=gpt_title, lines=1, interactive=True
|
666 |
+
)
|
667 |
+
|
668 |
+
gr_summary = gr.Textbox(
|
669 |
+
label="Resumen GPT", value=gpt_summary, lines=4, interactive=True
|
670 |
+
)
|
671 |
+
|
672 |
+
with gr.Accordion("Ver texto completo", open=False):
|
673 |
+
gr_content = gr.Textbox(
|
674 |
+
label="Contenido",
|
675 |
+
lines=15,
|
676 |
+
value=content,
|
677 |
+
interactive=False,
|
678 |
+
)
|
679 |
+
|
680 |
+
gr_exageracion = gr.Slider(
|
681 |
+
label="Exageración",
|
682 |
+
minimum=0,
|
683 |
+
maximum=10,
|
684 |
+
step=1,
|
685 |
+
value=0,
|
686 |
+
info="Se identifica y evalua el uso de afirmaciones excesivas o superlativas que pueden distorsionar la realidad del contenido ofrecido.",
|
687 |
+
)
|
688 |
+
gr_discrepancia = gr.Slider(
|
689 |
+
label="Discrepancia Título-Contenido",
|
690 |
+
minimum=0,
|
691 |
+
maximum=10,
|
692 |
+
step=1,
|
693 |
+
value=0,
|
694 |
+
info="Se evalua la coherencia entre los titulares y el cuerpo del artículo, asegurando que las expectativas generadas se cumplan efectivamente.",
|
695 |
+
)
|
696 |
+
gr_promesas = gr.Slider(
|
697 |
+
label="Promesas Incumplidas",
|
698 |
+
minimum=0,
|
699 |
+
maximum=10,
|
700 |
+
step=1,
|
701 |
+
value=0,
|
702 |
+
info="Se detecta cuando los titulares hacen promesas específicas que el contenido no logra satisfacer, manteniendo un estándar de integridad informativa.",
|
703 |
+
)
|
704 |
+
gr_incompleto = gr.Slider(
|
705 |
+
label="Información Incompleta",
|
706 |
+
minimum=0,
|
707 |
+
maximum=10,
|
708 |
+
step=1,
|
709 |
+
value=0,
|
710 |
+
info="Se identifica la omisión de detalles cruciales que son necesarios para una comprensión completa del tema, evitando tácticas que buscan meramente incentivar clics.",
|
711 |
+
)
|
712 |
+
gr_urgencia = gr.Slider(
|
713 |
+
label="Urgencia Artificial",
|
714 |
+
minimum=0,
|
715 |
+
maximum=10,
|
716 |
+
step=1,
|
717 |
+
value=0,
|
718 |
+
info="Se evalua el uso de frases que intentan crear una percepción de necesidad inmediata o limitación temporal sin justificación real.",
|
719 |
+
)
|
720 |
+
gr_sensacionalismo = gr.Slider(
|
721 |
+
label="Sensacionalismo",
|
722 |
+
minimum=0,
|
723 |
+
maximum=10,
|
724 |
+
step=1,
|
725 |
+
value=0,
|
726 |
+
info="Se distingue el contenido que busca impactar emocionalmente al lector mediante el uso de afirmaciones alarmantes o escandalosas sin fundamento sólido.",
|
727 |
+
)
|
728 |
+
gr_contexto = gr.Slider(
|
729 |
+
label="Omisión de Contexto",
|
730 |
+
minimum=0,
|
731 |
+
maximum=10,
|
732 |
+
step=1,
|
733 |
+
value=0,
|
734 |
+
info="Se revela la falta de información contextual que es esencial para entender completamente la noticia o el argumento presentado.",
|
735 |
+
)
|
736 |
+
gr_manipulacion = gr.Slider(
|
737 |
+
label="Influencia",
|
738 |
+
minimum=0,
|
739 |
+
maximum=10,
|
740 |
+
step=1,
|
741 |
+
value=0,
|
742 |
+
info="Se analizan las técnicas utilizadas para influir en la percepción del lector o dirigir sus conclusiones de manera sesgada o con fines específicos.",
|
743 |
+
)
|
744 |
+
gr_generalScore = gr.Slider(
|
745 |
+
label="Clasificación General",
|
746 |
+
minimum=0,
|
747 |
+
maximum=100,
|
748 |
+
value=0,
|
749 |
+
info="Clasificación general del nivel de clickbait del artículo en una escala del 0 al 100, donde 0 significa que el artículo no es clickbait y 100 significa que el artículo es clickbait en su máxima expresión.",
|
750 |
+
)
|
751 |
+
save = gr.Button("💾 Enviar")
|
752 |
+
save.click(
|
753 |
+
fn=example_getter.update_example,
|
754 |
+
inputs=[
|
755 |
+
gr_filename,
|
756 |
+
gr_exageracion,
|
757 |
+
gr_discrepancia,
|
758 |
+
gr_promesas,
|
759 |
+
gr_incompleto,
|
760 |
+
gr_urgencia,
|
761 |
+
gr_sensacionalismo,
|
762 |
+
gr_manipulacion,
|
763 |
+
gr_contexto,
|
764 |
+
gr_generalScore,
|
765 |
+
gr_summary,
|
766 |
+
gr_title_gpt,
|
767 |
+
],
|
768 |
+
outputs=[
|
769 |
+
gr_progress,
|
770 |
+
gr_filename,
|
771 |
+
gr_title,
|
772 |
+
gr_content,
|
773 |
+
gr_title_gpt,
|
774 |
+
gr_summary,
|
775 |
+
gr_exageracion,
|
776 |
+
gr_discrepancia,
|
777 |
+
gr_promesas,
|
778 |
+
gr_incompleto,
|
779 |
+
gr_urgencia,
|
780 |
+
gr_sensacionalismo,
|
781 |
+
gr_manipulacion,
|
782 |
+
gr_contexto,
|
783 |
+
gr_generalScore,
|
784 |
+
],
|
785 |
+
)
|
786 |
+
|
787 |
+
gr_play.click(
|
788 |
+
fn=example_getter.start_test,
|
789 |
+
outputs=[
|
790 |
+
gr_progress,
|
791 |
+
gr_filename,
|
792 |
+
gr_title,
|
793 |
+
gr_content,
|
794 |
+
gr_title_gpt,
|
795 |
+
gr_summary,
|
796 |
+
gr_exageracion,
|
797 |
+
gr_discrepancia,
|
798 |
+
gr_promesas,
|
799 |
+
gr_incompleto,
|
800 |
+
gr_urgencia,
|
801 |
+
gr_sensacionalismo,
|
802 |
+
gr_manipulacion,
|
803 |
+
gr_contexto,
|
804 |
+
gr_generalScore,
|
805 |
+
],
|
806 |
+
)
|
807 |
+
|
808 |
+
|
809 |
+
demo.launch( auth=(os.environ.get("pass"), os.environ.get("pass")))
|
markdown.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GUIDELINES = """
|
2 |
+
Vamos a anotar los siguientes elementos sobre el texto:
|
3 |
+
- **Exageración** Se identifica y evalua el uso de afirmaciones excesivas o superlativas que pueden distorsionar la realidad del contenido ofrecido.
|
4 |
+
- **Discrepancia Título-Contenido**: Se evalua la coherencia entre los titulares y el cuerpo del artículo, asegurando que las expectativas generadas se cumplan efectivamente.
|
5 |
+
- **Promesas Incumplidas** Se detecta cuando los titulares hacen promesas específicas que el contenido no logra satisfacer, manteniendo un estándar de integridad informativa.
|
6 |
+
- **Información Incompleta** Se identifica la omisión de detalles cruciales que son necesarios para una comprensión completa del tema, evitando tácticas que buscan meramente incentivar clics.
|
7 |
+
- **Urgencia Artificial** Se evalua el uso de frases que intentan crear una percepción de necesidad inmediata o limitación temporal sin justificación real.
|
8 |
+
- **Sensacionalismo** Se distingue el contenido que busca impactar emocionalmente al lector mediante el uso de afirmaciones alarmantes o escandalosas sin fundamento sólido.
|
9 |
+
- **Omisión de Contexto** Se revela la falta de información contextual que es esencial para entender completamente la noticia o el argumento presentado.
|
10 |
+
- **Influencia** Se analizan las técnicas utilizadas para influir en la percepción del lector o dirigir sus conclusiones de manera sesgada o con fines específicos.
|
11 |
+
|
12 |
+
Para ello debes valorar cada elemento en una escala del0 a 10, donde 0 significa que no se presenta el elemento y 10 significa que el elemento está presente en su máxima expresión.
|
13 |
+
|
14 |
+
Además, deberás proporcional una clasificación general del nivel de clickbait del artículo en una escala del 0 al 100, donde 0 significa que el artículo no es clickbait y 100 significa que el artículo es clickbait en su máxima expresión.
|
15 |
+
|
16 |
+
En caso de detectar errores graves en el resumen o el título generado por ChatGPT, también puedes editar este campo para corregirlo.
|
17 |
+
|
18 |
+
Al final de la anotación, recuerda pulsar el botón "Enviar" para guardar tus respuestas.
|
19 |
+
""".strip()
|
20 |
+
|
21 |
+
|
22 |
+
HEADER = """
|
23 |
+
# Anotación de Clickbait en Artículos de Noticias
|
24 |
+
""".strip()
|
25 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
setuptools
|
3 |
+
huggingface_hub
|
4 |
+
filelock
|