cueaudit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cueaudit/__init__.py +40 -0
- cueaudit/_core.py +673 -0
- cueaudit/stopwords.txt +161 -0
- cueaudit-0.1.0.dist-info/METADATA +226 -0
- cueaudit-0.1.0.dist-info/RECORD +7 -0
- cueaudit-0.1.0.dist-info/WHEEL +5 -0
- cueaudit-0.1.0.dist-info/top_level.txt +1 -0
cueaudit/__init__.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""cueaudit: a deterministic audit of multiple choice items.
|
|
2
|
+
|
|
3
|
+
The package reads multiple choice benchmark items (a stem, the
|
|
4
|
+
options, and the key) and flags item writing flaws under nine
|
|
5
|
+
mechanical rules drawn from the published item writing flaw
|
|
6
|
+
taxonomy. It never runs a model and never judges whether a key is
|
|
7
|
+
correct. Bank level cue statistics sit alongside the per item
|
|
8
|
+
flags.
|
|
9
|
+
|
|
10
|
+
The statistics are cue measurements, not item quality judgments,
|
|
11
|
+
and a flagged item can still be a good item.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from ._core import (
|
|
15
|
+
RULE_IDS,
|
|
16
|
+
AuditReport,
|
|
17
|
+
BankStats,
|
|
18
|
+
FlawFlag,
|
|
19
|
+
Item,
|
|
20
|
+
ItemResult,
|
|
21
|
+
audit_items,
|
|
22
|
+
bank_statistics,
|
|
23
|
+
load_items,
|
|
24
|
+
normalise,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__version__ = "0.1.0"
|
|
28
|
+
|
|
29
|
+
__all__ = [
|
|
30
|
+
"RULE_IDS",
|
|
31
|
+
"AuditReport",
|
|
32
|
+
"BankStats",
|
|
33
|
+
"FlawFlag",
|
|
34
|
+
"Item",
|
|
35
|
+
"ItemResult",
|
|
36
|
+
"audit_items",
|
|
37
|
+
"bank_statistics",
|
|
38
|
+
"load_items",
|
|
39
|
+
"normalise",
|
|
40
|
+
]
|
cueaudit/_core.py
ADDED
|
@@ -0,0 +1,673 @@
|
|
|
1
|
+
"""Core implementation of the cueaudit package.
|
|
2
|
+
|
|
3
|
+
The module is organised in four parts. The first part holds the data
|
|
4
|
+
types that cross the public boundary. The second part holds text
|
|
5
|
+
normalisation and the small text measures every rule shares. The
|
|
6
|
+
third part holds the nine audit rules. The fourth part holds the
|
|
7
|
+
bank level statistics and the file loaders.
|
|
8
|
+
|
|
9
|
+
Every rule is deterministic on normalised text. Normalisation is
|
|
10
|
+
Unicode NFC, case folding, runs of whitespace collapsed to one
|
|
11
|
+
space, leading and trailing whitespace stripped, and surrounding
|
|
12
|
+
quotation marks removed. Length always means the character count
|
|
13
|
+
after normalisation.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import csv
|
|
17
|
+
import json
|
|
18
|
+
import re
|
|
19
|
+
import string
|
|
20
|
+
import unicodedata
|
|
21
|
+
from dataclasses import dataclass, field
|
|
22
|
+
from importlib import resources
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# ------------------------------------------------------------------
|
|
26
|
+
# Part one: the data types.
|
|
27
|
+
# ------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass(frozen=True)
|
|
31
|
+
class Item:
|
|
32
|
+
"""One multiple choice item.
|
|
33
|
+
|
|
34
|
+
The key is the integer position of the correct option inside
|
|
35
|
+
the options tuple. An item carries 2 to 6 options; the bound
|
|
36
|
+
is enforced here at construction, so an item built directly
|
|
37
|
+
is held to it exactly as an item built by the loaders is, and
|
|
38
|
+
a construction outside the bound raises ValueError naming
|
|
39
|
+
the bound and the count given.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
item_id: str
|
|
43
|
+
stem: str
|
|
44
|
+
options: tuple
|
|
45
|
+
key: int
|
|
46
|
+
|
|
47
|
+
def __post_init__(self):
|
|
48
|
+
# Store the options as a tuple whatever sequence the caller
|
|
49
|
+
# passed, so the frozen record cannot be mutated later.
|
|
50
|
+
object.__setattr__(self, "options", tuple(self.options))
|
|
51
|
+
# Enforce the option count bound on every construction
|
|
52
|
+
# path, not only on the loader path: the rules divide by
|
|
53
|
+
# counts taken over the other options, so an item outside
|
|
54
|
+
# the bound would otherwise fail inside a rule with an
|
|
55
|
+
# error that names nothing about the item.
|
|
56
|
+
if not 2 <= len(self.options) <= 6:
|
|
57
|
+
raise ValueError(
|
|
58
|
+
f"an item carries 2 to 6 options; "
|
|
59
|
+
f"item '{self.item_id}' carries {len(self.options)}"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass(frozen=True)
|
|
64
|
+
class FlawFlag:
|
|
65
|
+
"""One rule firing on one item.
|
|
66
|
+
|
|
67
|
+
The severity is the word cue for a flag that points at a guessing
|
|
68
|
+
advantage and the word structural for a flag that points at the
|
|
69
|
+
form of the item itself. The detail is a plain sentence naming
|
|
70
|
+
the measured values behind the flag.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
rule_id: str
|
|
74
|
+
severity: str
|
|
75
|
+
detail: str
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass(frozen=True)
|
|
79
|
+
class ItemResult:
|
|
80
|
+
"""The flags raised on one item, in rule order."""
|
|
81
|
+
|
|
82
|
+
item_id: str
|
|
83
|
+
flags: tuple
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass(frozen=True)
|
|
87
|
+
class AuditReport:
|
|
88
|
+
"""The result of auditing a list of items.
|
|
89
|
+
|
|
90
|
+
The counts mapping holds one entry per rule that fired at least
|
|
91
|
+
once. The stratum counts mapping groups the same counts by
|
|
92
|
+
stratum; an item is numeric heavy when at least half of its
|
|
93
|
+
options are numeric only, and every other item sits in the text
|
|
94
|
+
stratum.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
n_items: int
|
|
98
|
+
results: tuple
|
|
99
|
+
counts: dict = field(default_factory=dict)
|
|
100
|
+
stratum_counts: dict = field(default_factory=dict)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@dataclass(frozen=True)
|
|
104
|
+
class BankStats:
|
|
105
|
+
"""Bank level cue statistics for a list of items.
|
|
106
|
+
|
|
107
|
+
The statistics are cue measurements, not item quality judgments,
|
|
108
|
+
and a flagged item can still be a good item. Fields that need a
|
|
109
|
+
group of items to be defined carry None when that group is
|
|
110
|
+
empty, as their field notes state.
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
n_items: int
|
|
114
|
+
n_options_mean: float
|
|
115
|
+
key_position_shares: tuple
|
|
116
|
+
key_position_spread: object
|
|
117
|
+
unique_longest_items: int
|
|
118
|
+
longest_option_key_rate: object
|
|
119
|
+
longest_option_edge: object
|
|
120
|
+
duplicate_option_items: int
|
|
121
|
+
duplicate_option_share: float
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# ------------------------------------------------------------------
|
|
125
|
+
# Part two: normalisation and shared text measures.
|
|
126
|
+
# ------------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
_QUOTE_CHARS = "\"'‘’“”«»"
|
|
129
|
+
|
|
130
|
+
# The numeric form shared by rules R3 and R9: digits, commas, one
|
|
131
|
+
# decimal point, one leading minus sign, and nothing else.
|
|
132
|
+
_NUMBER_RE = re.compile(r"^-?[0-9][0-9,]*(\.[0-9]+)?$")
|
|
133
|
+
|
|
134
|
+
# A range written with a hyphen separator. Each number keeps its own
|
|
135
|
+
# leading minus sign, so a range of negative numbers still parses.
|
|
136
|
+
_RANGE_HYPHEN_RE = re.compile(
|
|
137
|
+
r"^(-?[0-9][0-9,]*(?:\.[0-9]+)?)-(-?[0-9][0-9,]*(?:\.[0-9]+)?)$"
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
_WORD_RE = re.compile(r"[a-z0-9]+")
|
|
141
|
+
|
|
142
|
+
_NEGATIVE_STEM_WORDS = ("not", "except", "never")
|
|
143
|
+
_ABSOLUTE_WORDS = ("always", "never", "all", "none")
|
|
144
|
+
_ABOVE_PHRASES = ("all of the above", "none of the above")
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _load_stopwords():
|
|
148
|
+
"""Read the frozen stopword list shipped with the package."""
|
|
149
|
+
text = (
|
|
150
|
+
resources.files("cueaudit")
|
|
151
|
+
.joinpath("stopwords.txt")
|
|
152
|
+
.read_text(encoding="utf-8")
|
|
153
|
+
)
|
|
154
|
+
return frozenset(text.split("\n"))
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
_STOPWORDS = _load_stopwords()
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def normalise(text):
|
|
161
|
+
"""Return the normalised form of a piece of text.
|
|
162
|
+
|
|
163
|
+
The steps, in order: Unicode NFC, case folding, every run of
|
|
164
|
+
whitespace collapsed to one space, leading and trailing
|
|
165
|
+
whitespace stripped, and surrounding quotation marks removed.
|
|
166
|
+
"""
|
|
167
|
+
folded = unicodedata.normalize("NFC", text).casefold()
|
|
168
|
+
collapsed = " ".join(folded.split())
|
|
169
|
+
return collapsed.strip(_QUOTE_CHARS)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _is_number(text):
|
|
173
|
+
"""True when the normalised text matches the numeric form."""
|
|
174
|
+
return bool(_NUMBER_RE.match(text))
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _number_value(text):
|
|
178
|
+
"""The float value of a text in the numeric form."""
|
|
179
|
+
return float(text.replace(",", ""))
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _parse_range(text):
|
|
183
|
+
"""Parse a normalised option as a numeric range, or return None.
|
|
184
|
+
|
|
185
|
+
A range is exactly two numbers in the numeric form joined by one
|
|
186
|
+
separator: the word to standing alone, an en dash, or a hyphen.
|
|
187
|
+
An option carrying any other character does not parse.
|
|
188
|
+
"""
|
|
189
|
+
if " to " in text:
|
|
190
|
+
parts = text.split(" to ")
|
|
191
|
+
if len(parts) == 2 and all(_is_number(p) for p in parts):
|
|
192
|
+
return (_number_value(parts[0]), _number_value(parts[1]))
|
|
193
|
+
return None
|
|
194
|
+
if "–" in text:
|
|
195
|
+
parts = text.split("–")
|
|
196
|
+
if len(parts) == 2 and all(_is_number(p) for p in parts):
|
|
197
|
+
return (_number_value(parts[0]), _number_value(parts[1]))
|
|
198
|
+
return None
|
|
199
|
+
match = _RANGE_HYPHEN_RE.match(text)
|
|
200
|
+
if match:
|
|
201
|
+
return (_number_value(match.group(1)), _number_value(match.group(2)))
|
|
202
|
+
return None
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def _whole_words(text):
|
|
206
|
+
"""The whole words of a normalised text, as a set.
|
|
207
|
+
|
|
208
|
+
A whole word is a maximal run of letters and digits, so a word
|
|
209
|
+
inside a longer token never counts.
|
|
210
|
+
"""
|
|
211
|
+
return set(_WORD_RE.findall(text))
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def _tokens(text):
|
|
215
|
+
"""The tokens of a normalised text under the rule R7 tokenisation.
|
|
216
|
+
|
|
217
|
+
The text is split on whitespace and every token is stripped of
|
|
218
|
+
leading and trailing characters in the ASCII punctuation set.
|
|
219
|
+
Tokens are never split internally, so a hyphen or an apostrophe
|
|
220
|
+
inside a token stays part of the token, and the token length
|
|
221
|
+
counts the whole stripped token.
|
|
222
|
+
"""
|
|
223
|
+
return [tok.strip(string.punctuation) for tok in text.split()]
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def _has_letters(text):
|
|
227
|
+
"""True when the normalised text contains at least one letter."""
|
|
228
|
+
return any(ch.isalpha() for ch in text)
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def _stratum(norm_options):
|
|
232
|
+
"""The stratum of an item from its normalised options."""
|
|
233
|
+
numeric = sum(1 for opt in norm_options if _is_number(opt))
|
|
234
|
+
if numeric * 2 >= len(norm_options):
|
|
235
|
+
return "numeric_heavy"
|
|
236
|
+
return "text"
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
# ------------------------------------------------------------------
|
|
240
|
+
# Part three: the nine rules.
|
|
241
|
+
#
|
|
242
|
+
# Each rule function takes the item, its normalised stem, and its
|
|
243
|
+
# normalised options, and returns a FlawFlag or None. Flags are
|
|
244
|
+
# independent per rule: rule R5 reads the stem only and rule R6
|
|
245
|
+
# reads the options only, so one word in one field never raises the
|
|
246
|
+
# other rule, and an item may carry several flags by design.
|
|
247
|
+
# ------------------------------------------------------------------
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _rule_r1(item, stem, opts):
|
|
251
|
+
"""R1, key length cue (cue).
|
|
252
|
+
|
|
253
|
+
Fires when the key option is the unique longest option and its
|
|
254
|
+
length is at least 1.25 times the mean length of the others.
|
|
255
|
+
"""
|
|
256
|
+
lengths = [len(o) for o in opts]
|
|
257
|
+
key_len = lengths[item.key]
|
|
258
|
+
if lengths.count(max(lengths)) != 1 or key_len != max(lengths):
|
|
259
|
+
return None
|
|
260
|
+
others = [ln for i, ln in enumerate(lengths) if i != item.key]
|
|
261
|
+
mean_others = sum(others) / len(others)
|
|
262
|
+
if key_len < 1.25 * mean_others:
|
|
263
|
+
return None
|
|
264
|
+
detail = (
|
|
265
|
+
f"The key option is the longest option at {key_len} characters, "
|
|
266
|
+
f"which is {key_len / mean_others:.2f} times the mean length of "
|
|
267
|
+
f"the other options at {mean_others:.1f} characters."
|
|
268
|
+
)
|
|
269
|
+
return FlawFlag("R1", "cue", detail)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def _rule_r2(item, stem, opts):
|
|
273
|
+
"""R2, duplicate options (structural).
|
|
274
|
+
|
|
275
|
+
Fires when two or more options are equal after normalisation.
|
|
276
|
+
"""
|
|
277
|
+
seen = {}
|
|
278
|
+
for pos, opt in enumerate(opts):
|
|
279
|
+
if opt in seen:
|
|
280
|
+
detail = (
|
|
281
|
+
f"Options {seen[opt] + 1} and {pos + 1} are identical "
|
|
282
|
+
f"after normalisation: '{opt}'."
|
|
283
|
+
)
|
|
284
|
+
return FlawFlag("R2", "structural", detail)
|
|
285
|
+
seen[opt] = pos
|
|
286
|
+
return None
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def _rule_r3(item, stem, opts):
|
|
290
|
+
"""R3, overlapping ranges (structural).
|
|
291
|
+
|
|
292
|
+
Fires when two options parse as numeric ranges and the ranges
|
|
293
|
+
share more than a single endpoint value. Ranges that only touch
|
|
294
|
+
at one endpoint do not fire.
|
|
295
|
+
"""
|
|
296
|
+
parsed = [(pos, _parse_range(o)) for pos, o in enumerate(opts)]
|
|
297
|
+
parsed = [(pos, r) for pos, r in parsed if r is not None]
|
|
298
|
+
for i in range(len(parsed)):
|
|
299
|
+
for j in range(i + 1, len(parsed)):
|
|
300
|
+
(a, b) = parsed[i][1]
|
|
301
|
+
(c, d) = parsed[j][1]
|
|
302
|
+
if max(a, c) < min(b, d):
|
|
303
|
+
detail = (
|
|
304
|
+
f"The ranges '{opts[parsed[i][0]]}' and "
|
|
305
|
+
f"'{opts[parsed[j][0]]}' overlap beyond a shared "
|
|
306
|
+
f"endpoint."
|
|
307
|
+
)
|
|
308
|
+
return FlawFlag("R3", "structural", detail)
|
|
309
|
+
return None
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def _rule_r4(item, stem, opts):
|
|
313
|
+
"""R4, all or none of the above (structural).
|
|
314
|
+
|
|
315
|
+
Fires when an option equals one of the two phrases after
|
|
316
|
+
normalisation.
|
|
317
|
+
"""
|
|
318
|
+
for pos, opt in enumerate(opts):
|
|
319
|
+
if opt in _ABOVE_PHRASES:
|
|
320
|
+
detail = (
|
|
321
|
+
f"Option {pos + 1} is '{opt}', an all or none of the "
|
|
322
|
+
f"above option."
|
|
323
|
+
)
|
|
324
|
+
return FlawFlag("R4", "structural", detail)
|
|
325
|
+
return None
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def _rule_r5(item, stem, opts):
|
|
329
|
+
"""R5, negative stem (structural).
|
|
330
|
+
|
|
331
|
+
Fires when the stem contains one of the whole words not, except,
|
|
332
|
+
or never. The flag fires on the word alone, in any stem; it is a
|
|
333
|
+
prompt to read the stem, and the detail says so.
|
|
334
|
+
"""
|
|
335
|
+
words = _whole_words(stem)
|
|
336
|
+
for word in _NEGATIVE_STEM_WORDS:
|
|
337
|
+
if word in words:
|
|
338
|
+
detail = (
|
|
339
|
+
f"The stem contains the word '{word}'; the stem needs "
|
|
340
|
+
f"a reader check for negation emphasis."
|
|
341
|
+
)
|
|
342
|
+
return FlawFlag("R5", "structural", detail)
|
|
343
|
+
return None
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def _rule_r6(item, stem, opts):
|
|
347
|
+
"""R6, absolute terms (cue).
|
|
348
|
+
|
|
349
|
+
Fires when a non key option contains one of the whole words
|
|
350
|
+
always, never, all, or none, and the key option contains none
|
|
351
|
+
of them.
|
|
352
|
+
"""
|
|
353
|
+
if _whole_words(opts[item.key]) & set(_ABSOLUTE_WORDS):
|
|
354
|
+
return None
|
|
355
|
+
for pos, opt in enumerate(opts):
|
|
356
|
+
if pos == item.key:
|
|
357
|
+
continue
|
|
358
|
+
found = _whole_words(opt) & set(_ABSOLUTE_WORDS)
|
|
359
|
+
if found:
|
|
360
|
+
word = sorted(found)[0]
|
|
361
|
+
detail = (
|
|
362
|
+
f"Option {pos + 1} contains the absolute term "
|
|
363
|
+
f"'{word}', and the key option contains none of the "
|
|
364
|
+
f"absolute terms."
|
|
365
|
+
)
|
|
366
|
+
return FlawFlag("R6", "cue", detail)
|
|
367
|
+
return None
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def _rule_r7(item, stem, opts):
|
|
371
|
+
"""R7, stem echo (cue).
|
|
372
|
+
|
|
373
|
+
Fires when a content word of the stem (length 5 or more under
|
|
374
|
+
the tokenisation, and not in the frozen stopword list) appears
|
|
375
|
+
in exactly one option and that option is the key. When several
|
|
376
|
+
content words qualify, the flag fires once and names them.
|
|
377
|
+
"""
|
|
378
|
+
stem_words = {
|
|
379
|
+
tok
|
|
380
|
+
for tok in _tokens(stem)
|
|
381
|
+
if len(tok) >= 5 and tok not in _STOPWORDS
|
|
382
|
+
}
|
|
383
|
+
if not stem_words:
|
|
384
|
+
return None
|
|
385
|
+
option_tokens = [set(_tokens(o)) for o in opts]
|
|
386
|
+
qualifying = []
|
|
387
|
+
for word in sorted(stem_words):
|
|
388
|
+
holders = [i for i, toks in enumerate(option_tokens) if word in toks]
|
|
389
|
+
if len(holders) == 1 and holders[0] == item.key:
|
|
390
|
+
qualifying.append(word)
|
|
391
|
+
if not qualifying:
|
|
392
|
+
return None
|
|
393
|
+
names = ", ".join(f"'{w}'" for w in qualifying)
|
|
394
|
+
detail = (
|
|
395
|
+
f"The stem words {names} appear in the key option and in no "
|
|
396
|
+
f"other option."
|
|
397
|
+
)
|
|
398
|
+
return FlawFlag("R7", "cue", detail)
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
def _rule_r8(item, stem, opts):
|
|
402
|
+
"""R8, length spread (cue).
|
|
403
|
+
|
|
404
|
+
Fires when the longest option is at least twice the length of
|
|
405
|
+
the shortest option, whatever the key position.
|
|
406
|
+
"""
|
|
407
|
+
lengths = [len(o) for o in opts]
|
|
408
|
+
longest, shortest = max(lengths), min(lengths)
|
|
409
|
+
if shortest > 0 and longest >= 2 * shortest:
|
|
410
|
+
detail = (
|
|
411
|
+
f"The longest option is {longest} characters and the "
|
|
412
|
+
f"shortest is {shortest} characters, a spread of "
|
|
413
|
+
f"{longest / shortest:.2f} times."
|
|
414
|
+
)
|
|
415
|
+
return FlawFlag("R8", "cue", detail)
|
|
416
|
+
return None
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def _rule_r9(item, stem, opts):
|
|
420
|
+
"""R9, mixed option form (structural).
|
|
421
|
+
|
|
422
|
+
Fires when the options mix numeric only options with options
|
|
423
|
+
containing letters. An option that is neither numeric only nor
|
|
424
|
+
letter bearing completes neither side of the mix.
|
|
425
|
+
"""
|
|
426
|
+
numeric = sum(1 for o in opts if _is_number(o))
|
|
427
|
+
lettered = sum(1 for o in opts if _has_letters(o))
|
|
428
|
+
if numeric >= 1 and lettered >= 1:
|
|
429
|
+
numeric_word = "option" if numeric == 1 else "options"
|
|
430
|
+
lettered_word = "option" if lettered == 1 else "options"
|
|
431
|
+
detail = (
|
|
432
|
+
f"The item mixes {numeric} numeric only {numeric_word} "
|
|
433
|
+
f"with {lettered} {lettered_word} containing letters."
|
|
434
|
+
)
|
|
435
|
+
return FlawFlag("R9", "structural", detail)
|
|
436
|
+
return None
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
_RULES = {
|
|
440
|
+
"R1": _rule_r1,
|
|
441
|
+
"R2": _rule_r2,
|
|
442
|
+
"R3": _rule_r3,
|
|
443
|
+
"R4": _rule_r4,
|
|
444
|
+
"R5": _rule_r5,
|
|
445
|
+
"R6": _rule_r6,
|
|
446
|
+
"R7": _rule_r7,
|
|
447
|
+
"R8": _rule_r8,
|
|
448
|
+
"R9": _rule_r9,
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
#: The rule ids of the frozen rule set, in order.
|
|
452
|
+
RULE_IDS = tuple(_RULES)
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
def audit_items(items, rules=None):
|
|
456
|
+
"""Audit a list of items and return an AuditReport.
|
|
457
|
+
|
|
458
|
+
With rules None the full frozen rule set runs. A caller may pass
|
|
459
|
+
a subset of rule ids; an unknown rule id raises ValueError.
|
|
460
|
+
"""
|
|
461
|
+
items = list(items)
|
|
462
|
+
if rules is None:
|
|
463
|
+
selected = list(RULE_IDS)
|
|
464
|
+
else:
|
|
465
|
+
selected = list(rules)
|
|
466
|
+
for rule_id in selected:
|
|
467
|
+
if rule_id not in _RULES:
|
|
468
|
+
raise ValueError(f"unknown rule id: {rule_id}")
|
|
469
|
+
results = []
|
|
470
|
+
counts = {}
|
|
471
|
+
stratum_counts = {}
|
|
472
|
+
for item in items:
|
|
473
|
+
stem = normalise(item.stem)
|
|
474
|
+
opts = [normalise(o) for o in item.options]
|
|
475
|
+
flags = []
|
|
476
|
+
for rule_id in selected:
|
|
477
|
+
flag = _RULES[rule_id](item, stem, opts)
|
|
478
|
+
if flag is not None:
|
|
479
|
+
flags.append(flag)
|
|
480
|
+
counts[rule_id] = counts.get(rule_id, 0) + 1
|
|
481
|
+
stratum = _stratum(opts)
|
|
482
|
+
bucket = stratum_counts.setdefault(stratum, {})
|
|
483
|
+
bucket[rule_id] = bucket.get(rule_id, 0) + 1
|
|
484
|
+
results.append(ItemResult(item.item_id, tuple(flags)))
|
|
485
|
+
return AuditReport(len(items), tuple(results), counts, stratum_counts)
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
# ------------------------------------------------------------------
|
|
489
|
+
# Part four: bank statistics and loaders.
|
|
490
|
+
# ------------------------------------------------------------------
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
def bank_statistics(items):
|
|
494
|
+
"""Compute the bank level cue statistics for a list of items.
|
|
495
|
+
|
|
496
|
+
The key position shares hold one entry per option position up
|
|
497
|
+
to the longest item; the share at a position is taken over the
|
|
498
|
+
items that have that many or more options. The key position
|
|
499
|
+
spread compares only positions present in at least 10 items and
|
|
500
|
+
is None when no position reaches 10 items. The longest option
|
|
501
|
+
key rate and its edge over chance are None when no item has a
|
|
502
|
+
unique longest option.
|
|
503
|
+
"""
|
|
504
|
+
items = list(items)
|
|
505
|
+
n = len(items)
|
|
506
|
+
if n == 0:
|
|
507
|
+
return BankStats(0, 0.0, (), None, 0, None, None, 0, 0.0)
|
|
508
|
+
norm = [[normalise(o) for o in item.options] for item in items]
|
|
509
|
+
n_options_mean = sum(len(o) for o in norm) / n
|
|
510
|
+
max_options = max(len(o) for o in norm)
|
|
511
|
+
shares = []
|
|
512
|
+
for pos in range(max_options):
|
|
513
|
+
holders = [it for it in items if len(it.options) > pos]
|
|
514
|
+
hits = sum(1 for it in holders if it.key == pos)
|
|
515
|
+
shares.append(hits / len(holders))
|
|
516
|
+
eligible = [
|
|
517
|
+
shares[pos]
|
|
518
|
+
for pos in range(max_options)
|
|
519
|
+
if sum(1 for it in items if len(it.options) > pos) >= 10
|
|
520
|
+
]
|
|
521
|
+
spread = (max(eligible) - min(eligible)) if eligible else None
|
|
522
|
+
unique_longest = 0
|
|
523
|
+
key_is_longest = 0
|
|
524
|
+
chance_sum = 0.0
|
|
525
|
+
duplicate_items = 0
|
|
526
|
+
for item, opts in zip(items, norm):
|
|
527
|
+
lengths = [len(o) for o in opts]
|
|
528
|
+
if lengths.count(max(lengths)) == 1:
|
|
529
|
+
unique_longest += 1
|
|
530
|
+
chance_sum += 1.0 / len(opts)
|
|
531
|
+
if lengths[item.key] == max(lengths):
|
|
532
|
+
key_is_longest += 1
|
|
533
|
+
if len(set(opts)) < len(opts):
|
|
534
|
+
duplicate_items += 1
|
|
535
|
+
if unique_longest:
|
|
536
|
+
rate = key_is_longest / unique_longest
|
|
537
|
+
edge = rate - chance_sum / unique_longest
|
|
538
|
+
else:
|
|
539
|
+
rate = None
|
|
540
|
+
edge = None
|
|
541
|
+
return BankStats(
|
|
542
|
+
n,
|
|
543
|
+
n_options_mean,
|
|
544
|
+
tuple(shares),
|
|
545
|
+
spread,
|
|
546
|
+
unique_longest,
|
|
547
|
+
rate,
|
|
548
|
+
edge,
|
|
549
|
+
duplicate_items,
|
|
550
|
+
duplicate_items / n,
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
def _validate_record(record, where):
|
|
555
|
+
"""Build an Item from one raw record, or raise ValueError.
|
|
556
|
+
|
|
557
|
+
The error names the record position, given by the caller in the
|
|
558
|
+
where argument, so a bad file can be repaired by hand.
|
|
559
|
+
"""
|
|
560
|
+
if not isinstance(record, dict):
|
|
561
|
+
raise ValueError(f"{where}: record is not an object")
|
|
562
|
+
for name in ("item_id", "stem", "options", "key"):
|
|
563
|
+
if name not in record:
|
|
564
|
+
raise ValueError(f"{where}: record is missing '{name}'")
|
|
565
|
+
item_id = record["item_id"]
|
|
566
|
+
stem = record["stem"]
|
|
567
|
+
options = record["options"]
|
|
568
|
+
key = record["key"]
|
|
569
|
+
if not isinstance(item_id, str) or not item_id:
|
|
570
|
+
raise ValueError(f"{where}: item_id is not a non empty string")
|
|
571
|
+
if not isinstance(stem, str) or not stem.strip():
|
|
572
|
+
raise ValueError(f"{where}: stem is empty")
|
|
573
|
+
if not isinstance(options, (list, tuple)) or not all(
|
|
574
|
+
isinstance(o, str) for o in options
|
|
575
|
+
):
|
|
576
|
+
raise ValueError(f"{where}: options is not a list of strings")
|
|
577
|
+
if len(options) < 2:
|
|
578
|
+
raise ValueError(f"{where}: fewer than 2 options")
|
|
579
|
+
if len(options) > 6:
|
|
580
|
+
raise ValueError(f"{where}: more than 6 options")
|
|
581
|
+
if not isinstance(key, int) or isinstance(key, bool):
|
|
582
|
+
raise ValueError(f"{where}: key is not an integer")
|
|
583
|
+
if key < 0 or key >= len(options):
|
|
584
|
+
raise ValueError(f"{where}: key out of range")
|
|
585
|
+
return Item(item_id, stem, tuple(options), key)
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def _load_json(path):
|
|
589
|
+
with open(path, encoding="utf-8") as handle:
|
|
590
|
+
data = json.load(handle)
|
|
591
|
+
if not isinstance(data, list):
|
|
592
|
+
raise ValueError("top level of a JSON file must be a list of records")
|
|
593
|
+
return [
|
|
594
|
+
_validate_record(record, f"record {i}")
|
|
595
|
+
for i, record in enumerate(data, 1)
|
|
596
|
+
]
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
def _load_jsonl(path):
|
|
600
|
+
items = []
|
|
601
|
+
with open(path, encoding="utf-8") as handle:
|
|
602
|
+
for lineno, line in enumerate(handle, 1):
|
|
603
|
+
if not line.strip():
|
|
604
|
+
continue
|
|
605
|
+
try:
|
|
606
|
+
record = json.loads(line)
|
|
607
|
+
except json.JSONDecodeError as exc:
|
|
608
|
+
raise ValueError(f"line {lineno}: malformed line") from exc
|
|
609
|
+
items.append(_validate_record(record, f"line {lineno}"))
|
|
610
|
+
return items
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
def _load_csv(path):
|
|
614
|
+
"""Load a CSV file under the stated column mapping.
|
|
615
|
+
|
|
616
|
+
The header row names the columns item_id, stem, key, and one
|
|
617
|
+
column per option named option_1 through option_6. An empty
|
|
618
|
+
option cell is dropped wherever it sits in the row; the
|
|
619
|
+
remaining option cells, in column order, are the options of
|
|
620
|
+
the item.
|
|
621
|
+
"""
|
|
622
|
+
items = []
|
|
623
|
+
with open(path, encoding="utf-8", newline="") as handle:
|
|
624
|
+
reader = csv.DictReader(handle)
|
|
625
|
+
if reader.fieldnames is None:
|
|
626
|
+
raise ValueError("row 1: the CSV file has no header row")
|
|
627
|
+
for name in ("item_id", "stem", "key"):
|
|
628
|
+
if name not in reader.fieldnames:
|
|
629
|
+
raise ValueError(f"row 1: missing column '{name}'")
|
|
630
|
+
for row in reader:
|
|
631
|
+
where = f"row {reader.line_num}"
|
|
632
|
+
options = []
|
|
633
|
+
for col in range(1, 7):
|
|
634
|
+
cell = row.get(f"option_{col}")
|
|
635
|
+
if cell is not None and cell != "":
|
|
636
|
+
options.append(cell)
|
|
637
|
+
try:
|
|
638
|
+
key = int(row["key"])
|
|
639
|
+
except (TypeError, ValueError) as exc:
|
|
640
|
+
raise ValueError(f"{where}: key is not an integer") from exc
|
|
641
|
+
record = {
|
|
642
|
+
"item_id": row["item_id"],
|
|
643
|
+
"stem": row["stem"],
|
|
644
|
+
"options": options,
|
|
645
|
+
"key": key,
|
|
646
|
+
}
|
|
647
|
+
items.append(_validate_record(record, where))
|
|
648
|
+
return items
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
_LOADERS = {"json": _load_json, "jsonl": _load_jsonl, "csv": _load_csv}
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
def load_items(path, format=None):
|
|
655
|
+
"""Load items from a JSON, JSONL, or CSV file.
|
|
656
|
+
|
|
657
|
+
The format is inferred from the file suffix when format is
|
|
658
|
+
None. Each record carries an item id, a stem, 2 to 6 options,
|
|
659
|
+
and the key as the integer position of the correct option. A
|
|
660
|
+
record that fails validation raises ValueError naming the
|
|
661
|
+
record position.
|
|
662
|
+
"""
|
|
663
|
+
if format is None:
|
|
664
|
+
name = str(path).lower()
|
|
665
|
+
for suffix in (".jsonl", ".json", ".csv"):
|
|
666
|
+
if name.endswith(suffix):
|
|
667
|
+
format = suffix[1:]
|
|
668
|
+
break
|
|
669
|
+
else:
|
|
670
|
+
raise ValueError(f"cannot infer a format from the name: {path}")
|
|
671
|
+
if format not in _LOADERS:
|
|
672
|
+
raise ValueError(f"unknown format: {format}")
|
|
673
|
+
return _LOADERS[format](path)
|
cueaudit/stopwords.txt
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
a
|
|
2
|
+
about
|
|
3
|
+
above
|
|
4
|
+
after
|
|
5
|
+
again
|
|
6
|
+
against
|
|
7
|
+
all
|
|
8
|
+
am
|
|
9
|
+
an
|
|
10
|
+
and
|
|
11
|
+
any
|
|
12
|
+
are
|
|
13
|
+
aren't
|
|
14
|
+
as
|
|
15
|
+
at
|
|
16
|
+
be
|
|
17
|
+
because
|
|
18
|
+
been
|
|
19
|
+
before
|
|
20
|
+
being
|
|
21
|
+
below
|
|
22
|
+
between
|
|
23
|
+
both
|
|
24
|
+
but
|
|
25
|
+
by
|
|
26
|
+
can
|
|
27
|
+
could
|
|
28
|
+
couldn't
|
|
29
|
+
d
|
|
30
|
+
did
|
|
31
|
+
didn't
|
|
32
|
+
do
|
|
33
|
+
does
|
|
34
|
+
doesn't
|
|
35
|
+
doing
|
|
36
|
+
don't
|
|
37
|
+
down
|
|
38
|
+
during
|
|
39
|
+
each
|
|
40
|
+
few
|
|
41
|
+
for
|
|
42
|
+
from
|
|
43
|
+
further
|
|
44
|
+
had
|
|
45
|
+
hadn't
|
|
46
|
+
has
|
|
47
|
+
hasn't
|
|
48
|
+
have
|
|
49
|
+
haven't
|
|
50
|
+
having
|
|
51
|
+
he
|
|
52
|
+
her
|
|
53
|
+
here
|
|
54
|
+
hers
|
|
55
|
+
herself
|
|
56
|
+
him
|
|
57
|
+
himself
|
|
58
|
+
his
|
|
59
|
+
how
|
|
60
|
+
i
|
|
61
|
+
if
|
|
62
|
+
in
|
|
63
|
+
into
|
|
64
|
+
is
|
|
65
|
+
isn't
|
|
66
|
+
it
|
|
67
|
+
it's
|
|
68
|
+
its
|
|
69
|
+
itself
|
|
70
|
+
just
|
|
71
|
+
ll
|
|
72
|
+
m
|
|
73
|
+
ma
|
|
74
|
+
me
|
|
75
|
+
mightn't
|
|
76
|
+
more
|
|
77
|
+
most
|
|
78
|
+
mustn't
|
|
79
|
+
my
|
|
80
|
+
myself
|
|
81
|
+
needn't
|
|
82
|
+
no
|
|
83
|
+
nor
|
|
84
|
+
not
|
|
85
|
+
now
|
|
86
|
+
o
|
|
87
|
+
of
|
|
88
|
+
off
|
|
89
|
+
on
|
|
90
|
+
once
|
|
91
|
+
only
|
|
92
|
+
or
|
|
93
|
+
other
|
|
94
|
+
our
|
|
95
|
+
ours
|
|
96
|
+
ourselves
|
|
97
|
+
out
|
|
98
|
+
over
|
|
99
|
+
own
|
|
100
|
+
re
|
|
101
|
+
s
|
|
102
|
+
same
|
|
103
|
+
shan't
|
|
104
|
+
she
|
|
105
|
+
she's
|
|
106
|
+
should
|
|
107
|
+
shouldn't
|
|
108
|
+
so
|
|
109
|
+
some
|
|
110
|
+
such
|
|
111
|
+
t
|
|
112
|
+
than
|
|
113
|
+
that
|
|
114
|
+
that'll
|
|
115
|
+
the
|
|
116
|
+
their
|
|
117
|
+
theirs
|
|
118
|
+
them
|
|
119
|
+
themselves
|
|
120
|
+
then
|
|
121
|
+
there
|
|
122
|
+
these
|
|
123
|
+
they
|
|
124
|
+
this
|
|
125
|
+
those
|
|
126
|
+
through
|
|
127
|
+
to
|
|
128
|
+
too
|
|
129
|
+
under
|
|
130
|
+
until
|
|
131
|
+
up
|
|
132
|
+
ve
|
|
133
|
+
very
|
|
134
|
+
was
|
|
135
|
+
wasn't
|
|
136
|
+
we
|
|
137
|
+
were
|
|
138
|
+
weren't
|
|
139
|
+
what
|
|
140
|
+
when
|
|
141
|
+
where
|
|
142
|
+
which
|
|
143
|
+
while
|
|
144
|
+
who
|
|
145
|
+
whom
|
|
146
|
+
why
|
|
147
|
+
will
|
|
148
|
+
with
|
|
149
|
+
won't
|
|
150
|
+
would
|
|
151
|
+
wouldn't
|
|
152
|
+
y
|
|
153
|
+
you
|
|
154
|
+
you'd
|
|
155
|
+
you'll
|
|
156
|
+
you're
|
|
157
|
+
you've
|
|
158
|
+
your
|
|
159
|
+
yours
|
|
160
|
+
yourself
|
|
161
|
+
yourselves
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cueaudit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic audit of multiple choice benchmark items for item writing flaws
|
|
5
|
+
Author: Prabhu Rangaraju
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: benchmark,multiple choice,item analysis,evaluation
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering
|
|
11
|
+
Requires-Python: <3.13,>=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# cueaudit
|
|
15
|
+
|
|
16
|
+
cueaudit audits multiple choice benchmark items for item writing
|
|
17
|
+
flaws. It reads only the stem, the options, and the key of each
|
|
18
|
+
item, and flags flaws under nine mechanical rules drawn from the
|
|
19
|
+
published item writing flaw taxonomy. It runs before any model is
|
|
20
|
+
queried. It never runs a model, never calls a network, and never
|
|
21
|
+
judges whether a key is correct.
|
|
22
|
+
|
|
23
|
+
## What it takes in and what it returns
|
|
24
|
+
|
|
25
|
+
An item is a record with an item id, a stem, an ordered set of 2 to
|
|
26
|
+
6 options, and the key given as the integer position of the correct
|
|
27
|
+
option, counting from 0. Items load from JSON, JSONL, or CSV files with the
|
|
28
|
+
load_items function, or are built directly as Item records.
|
|
29
|
+
|
|
30
|
+
A JSON or JSONL record carries four fields: item_id (a string),
|
|
31
|
+
stem (a string), options (a list of 2 to 6 strings), and key (the
|
|
32
|
+
integer position of the correct option, counting from 0). A JSON
|
|
33
|
+
file holds a list of records; a JSONL file holds one record on
|
|
34
|
+
each line. A CSV file carries a header row naming the columns
|
|
35
|
+
item_id, stem, and key, and one column per option named option_1
|
|
36
|
+
through option_6, of which the file need carry only as many as
|
|
37
|
+
its widest item needs; a missing or empty option cell is dropped
|
|
38
|
+
wherever it sits in the row, and the remaining cells, in column
|
|
39
|
+
order, are the options. A record that fails validation raises
|
|
40
|
+
ValueError naming the record position.
|
|
41
|
+
|
|
42
|
+
audit_items returns a report holding one result per item. Each
|
|
43
|
+
result carries the flags the rules raised on that item. A flag
|
|
44
|
+
names its rule, its severity (the word cue for a flag that points
|
|
45
|
+
at a guessing advantage, the word structural for a flag that points
|
|
46
|
+
at the form of the item), and a plain sentence naming the measured
|
|
47
|
+
values behind the flag. The report also holds the flag counts per
|
|
48
|
+
rule, and the same counts split by stratum: an item sits in the
|
|
49
|
+
numeric_heavy stratum when at least half of its options are numeric
|
|
50
|
+
only, and in the text stratum otherwise.
|
|
51
|
+
|
|
52
|
+
bank_statistics returns the bank level cue statistics: the mean
|
|
53
|
+
option count, the share of keys at each option position and the
|
|
54
|
+
spread of those shares, the count of items with a unique longest
|
|
55
|
+
option and the rate at which the key is that longest option with
|
|
56
|
+
its edge over chance, and the count and share of items holding
|
|
57
|
+
duplicate options. Chance, in the edge, is the rate expected if
|
|
58
|
+
the key were placed uniformly at random among the options of
|
|
59
|
+
each item with a unique longest option: one over the number of
|
|
60
|
+
options of that item, averaged over those items. Two definition
|
|
61
|
+
details govern the position figures: the share at a position is
|
|
62
|
+
taken over the items that have that many or more options, and
|
|
63
|
+
the spread compares only positions present in at least 10 items.
|
|
64
|
+
|
|
65
|
+
## The nine rules
|
|
66
|
+
|
|
67
|
+
All nine rules are deterministic on normalised text. Normalisation
|
|
68
|
+
is Unicode NFC, case folding, whitespace collapsed to single
|
|
69
|
+
spaces, and surrounding quotation marks removed. Length means the
|
|
70
|
+
character count after normalisation.
|
|
71
|
+
|
|
72
|
+
- R1, key length cue. The key option is the unique longest option
|
|
73
|
+
and its length is at least 1.25 times the mean length of the
|
|
74
|
+
other options.
|
|
75
|
+
- R2, duplicate options. Two or more options in one item are equal
|
|
76
|
+
after normalisation.
|
|
77
|
+
- R3, overlapping ranges. Two options parse as numeric ranges and
|
|
78
|
+
the ranges share more than a single endpoint value. A range is
|
|
79
|
+
two numbers joined by the word to, an en dash, or a hyphen.
|
|
80
|
+
Ranges that only touch at one endpoint do not fire this rule.
|
|
81
|
+
- R4, all or none of the above. An option equals one of those two
|
|
82
|
+
phrases after normalisation.
|
|
83
|
+
- R5, negative stem. The stem contains one of the whole words not,
|
|
84
|
+
except, or never. This flag is a prompt to read the stem, and the
|
|
85
|
+
package says so wherever the rule is described.
|
|
86
|
+
- R6, absolute terms. A non key option contains one of the whole
|
|
87
|
+
words always, never, all, or none, and the key option contains
|
|
88
|
+
none of them.
|
|
89
|
+
- R7, stem echo. A content word of the stem (length 5 or more, and
|
|
90
|
+
not in the frozen stopword list the package ships) appears in
|
|
91
|
+
exactly one option, and that option is the key. The list ships
|
|
92
|
+
in the package as the file stopwords.txt.
|
|
93
|
+
- R8, length spread. The longest option in the item is at least
|
|
94
|
+
twice the length of the shortest option.
|
|
95
|
+
- R9, mixed option form. The options mix numeric only options with
|
|
96
|
+
options containing letters. An option that is neither completes
|
|
97
|
+
neither side of the mix.
|
|
98
|
+
|
|
99
|
+
## Where cueaudit sits
|
|
100
|
+
|
|
101
|
+
Response based item analysis already exists: the CTT package on
|
|
102
|
+
CRAN is the named example, and it reports how options performed
|
|
103
|
+
once students or models have answered. Flaw detection research
|
|
104
|
+
systems also exist: SAQUET and BenchMarkerUI both detect item
|
|
105
|
+
writing flaws, and both use model judges to do it. cueaudit covers
|
|
106
|
+
the ground before either of those: the item text alone, read by
|
|
107
|
+
fixed rules, at the moment a bank is written or audited, with no
|
|
108
|
+
responses collected and no model in the loop.
|
|
109
|
+
|
|
110
|
+
## Limits
|
|
111
|
+
|
|
112
|
+
- The validated scope is items whose options are text. Items whose
|
|
113
|
+
options are mostly numeric or code are placed in the
|
|
114
|
+
numeric_heavy stratum and reported apart, and the flaw reading
|
|
115
|
+
for that stratum is the measured result for that stratum, not
|
|
116
|
+
the headline reading for text items.
|
|
117
|
+
- The statistics are cue measurements, not item quality
|
|
118
|
+
judgments, and a flagged item can still be a good item.
|
|
119
|
+
- Rule R5 flags a word, not a fault: a negative stem can be the
|
|
120
|
+
right way to write an item, and the flag only asks a reader to
|
|
121
|
+
check the negation emphasis.
|
|
122
|
+
- The package reads item text only. It says nothing about whether
|
|
123
|
+
a key is right, whether an item is hard, or whether a bank is
|
|
124
|
+
fair.
|
|
125
|
+
|
|
126
|
+
## Install
|
|
127
|
+
|
|
128
|
+
cueaudit has no runtime dependency beyond the standard library.
|
|
129
|
+
It is built and tested on Python 3.12, and the package metadata
|
|
130
|
+
declares support for Python 3.11 and 3.12.
|
|
131
|
+
|
|
132
|
+
pip install cueaudit
|
|
133
|
+
|
|
134
|
+
## Worked example
|
|
135
|
+
|
|
136
|
+
The bank below holds 12 constructed items: one firing case for
|
|
137
|
+
each rule, and three items that draw no flag. The same bank ships
|
|
138
|
+
with the source distribution at tests/fixtures/worked_example.json.
|
|
139
|
+
Keys are stated as positions, counting from 0.
|
|
140
|
+
|
|
141
|
+
- we-01. Stem: What is the capital of France? Options: Paris,
|
|
142
|
+
London, Berlin, Madrid. Key position 0.
|
|
143
|
+
- we-02. Stem: Which city is the capital of France? Options:
|
|
144
|
+
Paris, the seat of the French government; A port city on the
|
|
145
|
+
channel; A town in the green hills; A city near the border. Key
|
|
146
|
+
position 0.
|
|
147
|
+
- we-03. Stem: Which of these is a primary colour? Options: Red,
|
|
148
|
+
Blue, Red, Green. Key position 0.
|
|
149
|
+
- we-04. Stem: Which band holds the value 25? Options: 10 to 30,
|
|
150
|
+
20 to 40, 50 to 60, 70 to 80. Key position 0.
|
|
151
|
+
- we-05. Stem: Which of these is a metal? Options: Iron plate,
|
|
152
|
+
Wooden plank, Glass panel, All of the above. Key position 0.
|
|
153
|
+
- we-06. Stem: Which of the following is not a fruit? Options: A
|
|
154
|
+
carrot, An apple, A grape, A peach. Key position 0.
|
|
155
|
+
- we-07. Stem: Which statement about sound is correct? Options:
|
|
156
|
+
Sound travels through air as a wave; Sound always travels in a
|
|
157
|
+
straight line; Sound moves through water; Sound fades with
|
|
158
|
+
distance. Key position 0.
|
|
159
|
+
- we-08. Stem: A cartographer draws maps of coastlines. What does
|
|
160
|
+
a cartographer produce? Options: Maps drawn by a trained
|
|
161
|
+
cartographer; Charts of ocean temperatures at depth; Lists of
|
|
162
|
+
mountain heights in the alps; Tables of river lengths by region.
|
|
163
|
+
Key position 0.
|
|
164
|
+
- we-09. Stem: Which animal lives in the sea? Options: Cod; A
|
|
165
|
+
very large whale shark specimen; A small coastal crab; A young
|
|
166
|
+
harbour seal. Key position 2.
|
|
167
|
+
- we-10. Stem: Which of these values is the largest? Options: 42,
|
|
168
|
+
17, 99, six. Key position 2.
|
|
169
|
+
- we-11. Stem: Which value is twice ten? Options: 10, 20, 30, 40.
|
|
170
|
+
Key position 1.
|
|
171
|
+
- we-12. Stem: Which bird cannot fly? Options: A swift in flight;
|
|
172
|
+
An ostrich; A sparrow of hedges; A grey heron. Key position 1.
|
|
173
|
+
|
|
174
|
+
The audit and the bank statistics for this bank, exactly as the
|
|
175
|
+
package prints them:
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
we-01: no flags
|
|
179
|
+
we-02: R1 (cue) The key option is the longest option at 40 characters, which is 1.64 times the mean length of the other options at 24.3 characters.
|
|
180
|
+
we-03: R2 (structural) Options 1 and 3 are identical after normalisation: 'red'.
|
|
181
|
+
we-04: R3 (structural) The ranges '10 to 30' and '20 to 40' overlap beyond a shared endpoint.
|
|
182
|
+
we-05: R4 (structural) Option 4 is 'all of the above', an all or none of the above option.
|
|
183
|
+
we-05: R6 (cue) Option 4 contains the absolute term 'all', and the key option contains none of the absolute terms.
|
|
184
|
+
we-06: R5 (structural) The stem contains the word 'not'; the stem needs a reader check for negation emphasis.
|
|
185
|
+
we-07: R6 (cue) Option 2 contains the absolute term 'always', and the key option contains none of the absolute terms.
|
|
186
|
+
we-08: R7 (cue) The stem words 'cartographer' appear in the key option and in no other option.
|
|
187
|
+
we-09: R8 (cue) The longest option is 33 characters and the shortest is 3 characters, a spread of 11.00 times.
|
|
188
|
+
we-10: R9 (structural) The item mixes 3 numeric only options with 1 option containing letters.
|
|
189
|
+
we-11: no flags
|
|
190
|
+
we-12: no flags
|
|
191
|
+
Counts: R1 1, R2 1, R3 1, R4 1, R5 1, R6 2, R7 1, R8 1, R9 1
|
|
192
|
+
Stratum numeric_heavy: R9 1
|
|
193
|
+
Stratum text: R1 1, R2 1, R3 1, R4 1, R5 1, R6 2, R7 1, R8 1
|
|
194
|
+
Bank items: 12
|
|
195
|
+
Mean options per item: 4.0
|
|
196
|
+
Key position shares: 0.6666666666666666, 0.16666666666666666, 0.16666666666666666, 0.0
|
|
197
|
+
Key position spread: 0.6666666666666666
|
|
198
|
+
Unique longest items: 7
|
|
199
|
+
Longest option key rate: 0.14285714285714285
|
|
200
|
+
Longest option edge: -0.10714285714285715
|
|
201
|
+
Duplicate option items: 1
|
|
202
|
+
Duplicate option share: 0.08333333333333333
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Two readings worth noting. Item we-05 draws two flags, because the
|
|
206
|
+
all or none of the above option also carries an absolute term, and
|
|
207
|
+
flags are independent per rule by design. Item we-12 draws no flag
|
|
208
|
+
even though its longest option is not the key: a long distractor on
|
|
209
|
+
its own breaks no rule in the set.
|
|
210
|
+
|
|
211
|
+
## Sources for the rule set
|
|
212
|
+
|
|
213
|
+
The rules are narrowed from the item writing flaw taxonomy of
|
|
214
|
+
Haladyna, Downing, and Rodriguez (2002), A review of
|
|
215
|
+
multiple-choice item-writing guidelines for classroom assessment,
|
|
216
|
+
Applied Measurement in Education 15(3), and from the flaw list of
|
|
217
|
+
Tarrant, Knierim, Hayes, and Ware (2006), The frequency of item
|
|
218
|
+
writing flaws in multiple-choice questions used in high stakes
|
|
219
|
+
nursing assessments, Nurse Education in Practice 6(6). A 2026
|
|
220
|
+
study in the Journal of Educational Evaluation for Health
|
|
221
|
+
Professions measured flaws of the same family in machine generated
|
|
222
|
+
medical items. Full citations sit in CITATION.cff.
|
|
223
|
+
|
|
224
|
+
## Licence
|
|
225
|
+
|
|
226
|
+
MIT. See the licence expression in the package metadata.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
cueaudit/__init__.py,sha256=UL0W_Ej8XTrlUZfjh5FQnSFrmh1ik-Jk3fWFducJRHU,889
|
|
2
|
+
cueaudit/_core.py,sha256=DbqY2Nu2bFcFRTXiGz68gdI7JZN2xzlWHhgw1V1QDWQ,22777
|
|
3
|
+
cueaudit/stopwords.txt,sha256=WlC_PlLJi-pLECLT3rHc2hH6rl1pRwa_9HHY8ss_hAw,832
|
|
4
|
+
cueaudit-0.1.0.dist-info/METADATA,sha256=krMlVcTqGygRCku_Nmrf1qt1CGl6kx88e7xBzoP41RQ,10991
|
|
5
|
+
cueaudit-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
+
cueaudit-0.1.0.dist-info/top_level.txt,sha256=tfcov8PNnyL8K66kT-7rVLZ8xy8ETjf0CGurfgW6nFE,9
|
|
7
|
+
cueaudit-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cueaudit
|