BVendeville commited on
Commit
a688ec6
·
verified ·
1 Parent(s): a53bf4c

annotation app code-a4670ffc3f9d+git-a75e043-dirty

Browse files
Files changed (3) hide show
  1. app.py +9 -0
  2. core.py +1 -1
  3. guide.py +76 -0
app.py CHANGED
@@ -26,6 +26,7 @@ import gradio as gr # noqa: E402
26
  HERE = Path(__file__).resolve().parent
27
  sys.path.insert(0, str(HERE))
28
  import core as C # noqa: E402
 
29
 
30
  CSS = """
31
  /* Each text is one card: its name is a header bar INSIDE the card's border, so a name can only belong to the
@@ -121,12 +122,20 @@ def build_demo(docs, config, out_dir: str | Path, meta: dict, layout: str = "hor
121
  gr.Markdown(f"## {study.get('title', 'Annotation')}")
122
  if TASK_INTRO[task]:
123
  gr.Markdown(TASK_INTRO[task], elem_id="task_intro")
 
 
 
 
 
124
 
125
  with gr.Column(visible=True) as g_start:
126
  key_in = gr.Textbox(label="Access key", type="password", placeholder="the key you were sent",
127
  visible=bool(config.get("access_key") or config.get("expert_access_key")
128
  or config.get("block_keys")),
129
  elem_id="key_in")
 
 
 
130
  gr.Markdown("**First time?** Choose an ID (not your name) and **write it down**: it is the only "
131
  "way to come back to where you stopped. \n"
132
  "**Coming back?** Enter the ID you chose last time.")
 
26
  HERE = Path(__file__).resolve().parent
27
  sys.path.insert(0, str(HERE))
28
  import core as C # noqa: E402
29
+ import guide as G # noqa: E402
30
 
31
  CSS = """
32
  /* Each text is one card: its name is a header bar INSIDE the card's border, so a name can only belong to the
 
122
  gr.Markdown(f"## {study.get('title', 'Annotation')}")
123
  if TASK_INTRO[task]:
124
  gr.Markdown(TASK_INTRO[task], elem_id="task_intro")
125
+ guide_md = study.get(f"guide_{task}") or G.GUIDE.get(task)
126
+ if guide_md: # always on the page, so it can be reopened at any time
127
+ with gr.Accordion("Instructions and example (click to open or close at any time)", open=False,
128
+ elem_id="guide"):
129
+ gr.Markdown(guide_md)
130
 
131
  with gr.Column(visible=True) as g_start:
132
  key_in = gr.Textbox(label="Access key", type="password", placeholder="the key you were sent",
133
  visible=bool(config.get("access_key") or config.get("expert_access_key")
134
  or config.get("block_keys")),
135
  elem_id="key_in")
136
+ if task != "both":
137
+ gr.Markdown("Please read **Instructions and example** above before you start; you can open it again "
138
+ "at any time, on every page.")
139
  gr.Markdown("**First time?** Choose an ID (not your name) and **write it down**: it is the only "
140
  "way to come back to where you stopped. \n"
141
  "**Coming back?** Enter the ID you chose last time.")
core.py CHANGED
@@ -185,7 +185,7 @@ def key_cohort(given: str | None, config) -> str | None:
185
  return None
186
 
187
 
188
- APP_FILES = ("app.py", "core.py", "hub.py")
189
 
190
 
191
  def code_hash(folder: str | Path | None = None) -> str:
 
185
  return None
186
 
187
 
188
+ APP_FILES = ("app.py", "core.py", "hub.py", "guide.py")
189
 
190
 
191
  def code_hash(folder: str | Path | None = None) -> str:
guide.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Instructions and a worked example for each part of the study, shown in a panel participants can reopen at any
2
+ time. The example is made up (it is not one of the study documents), so it cannot prime any real answer.
3
+ A config can replace a text with ``study.guide_simplicity`` / ``study.guide_validity`` (Markdown)."""
4
+
5
+ EXAMPLE_TEXTS = {
6
+ "A": "We looked at 12 studies with 2,431 people over 65. Walking every day probably means fewer falls after "
7
+ "one year. We do not know if it prevents broken bones.",
8
+ "B": "Twelve randomised trials in adults aged over 65 found that daily walking programmes probably reduce the "
9
+ "incidence of falls at 12 months relative to usual care, whereas the effect on fractures remains very "
10
+ "uncertain owing to very low-certainty evidence.",
11
+ "C": "Older people who walked every day had fewer falls. Walking also helped prevent broken bones.",
12
+ }
13
+ EXAMPLE_SOURCE = ("Twelve randomised trials (n = 2,431) compared daily walking programmes with usual care in adults "
14
+ "over 65 living at home. Walking reduced falls at 12 months (risk ratio 0.78, 95% CI 0.66 to 0.92; "
15
+ "moderate-certainty evidence). Effects on fractures were uncertain (very low-certainty evidence). "
16
+ "Authors' conclusions: daily walking probably reduces falls in older adults living in the "
17
+ "community, but we do not know whether it reduces fractures.")
18
+
19
+
20
+ def _texts() -> str:
21
+ return "\n".join(f"> **Text {L}.** {t}\n>" for L, t in EXAMPLE_TEXTS.items())
22
+
23
+
24
+ GUIDE = {
25
+ "simplicity": f"""
26
+ **What you do.** For each document you see three short texts (A, B, C) that explain the same piece of medical
27
+ research to the general public. You do **not** see the original research summary in this part.
28
+
29
+ 1. **Easiest to follow**: the text you understood with the least effort.
30
+ 2. **Hardest to follow**: the text that took the most effort to understand.
31
+ 3. **How much easier**: two short questions that compare the easiest with the middle one, and the middle one with
32
+ the hardest: *negligible*, *small*, *moderate* or *large*.
33
+
34
+ Judge only how easy each text is to **read and understand**: words, sentences, how ideas follow each other.
35
+ Do **not** judge whether the content is correct or complete (you cannot check that here), and do not simply pick
36
+ the shortest text: a short text can still be hard to follow. There are no right answers; we want your experience
37
+ as a reader. Once you submit a document you cannot go back to it.
38
+
39
+ **Example** (made up, not one of the study documents):
40
+
41
+ {_texts()}
42
+
43
+ A possible answer: **easiest A**, **hardest B**. A uses short sentences and everyday words; B packs everything
44
+ into one long sentence with terms like "incidence" and "very low-certainty evidence". C is about as easy as A, so
45
+ "How much easier is A than C?" → *negligible*; "How much easier is C than B?" → *large*. (C's claim about broken
46
+ bones is wrong, but that is not what this part asks about.)
47
+ """,
48
+ "validity": f"""
49
+ **What you do.** For each document you see the **original** research summary and three short texts (A, B, C)
50
+ written from it for the general public. For each question, tick every text it applies to (none, one, two or
51
+ all three):
52
+
53
+ 1. **Leaves out important information**: a reader would not learn the **main result** and **how certain it is**.
54
+ Take these from the summary's conclusions. Dropping details (numbers, methods, secondary results) is expected
55
+ in a simplification and is **not** an omission.
56
+ 2. **Contradicts the source**: says something the summary says is not so, for example the opposite effect, a
57
+ result the summary calls uncertain presented as established, or a wrong number.
58
+ 3. **States a finding more broadly than the source supports** (if shown): drops *who* the finding applies to or
59
+ *under what conditions*, for example "people" for "adults over 65 living at home".
60
+
61
+ Judge only faithfulness to the summary, not how easy the text is to read. Once you submit a document you cannot
62
+ go back to it.
63
+
64
+ **Example** (made up, not one of the study documents).
65
+
66
+ > **Original summary.** {EXAMPLE_SOURCE}
67
+
68
+ {_texts()}
69
+
70
+ A possible answer:
71
+ - *Leaves out important information*: **C**. It gives the main result but not how certain it is (the summary says
72
+ walking *probably* reduces falls). A and B keep both.
73
+ - *Contradicts the source*: **C**. It says walking helped prevent broken bones; the summary says this is not known.
74
+ - *More broadly than supported*: **C**. "Older people" drops "over 65" and "living at home"; A and B keep the age.
75
+ """,
76
+ }