sileod commited on
Commit
a21c5fb
·
verified ·
1 Parent(s): f6ea206

Record exact reproducible converter

Browse files
Files changed (1) hide show
  1. repackage_dataset/dialogue.py +12 -4
repackage_dataset/dialogue.py CHANGED
@@ -17,6 +17,10 @@ MCSCRIPT_URL = 'https://fedora.clarin-d.uni-saarland.de/sfb1102/MCScript-2.0.zip
17
  MCSCRIPT_SHA256 = '50037b08123a4660e2e00ad07bcfa2a7ddc1d666b05b198d359cd2cda8f5e88c'
18
 
19
 
 
 
 
 
20
  def slurp():
21
  """SLURP original human transcripts and intent labels, without bundled audio.
22
 
@@ -24,14 +28,15 @@ def slurp():
24
  Identical transcripts with inconsistent intents are excluded, and duplicate
25
  transcripts stay in their highest-priority native holdout (test, dev, train).
26
  One- and two-word transcripts are excluded as insufficient intent context.
27
- Original terms: CC BY 4.0. All removals and source hashes are recorded.
 
28
  """
29
  splits={}; hashes={}; labels={};counts=Counter()
30
  for split,native in [('train','train'),('validation','devel'),('test','test')]:
31
  url=f'https://raw.githubusercontent.com/pswietojanski/slurp/{SLURP_REVISION}/dataset/slurp/{native}.jsonl'
32
  raw=urllib.request.urlopen(url).read();hashes[native]=hashlib.sha256(raw).hexdigest()
33
  splits[split]=[json.loads(line) for line in raw.splitlines() if line.strip()]
34
- for row in splits[split]:labels.setdefault(text_key(row['sentence']),set()).add(row['intent'])
35
  output={};seen=set()
36
  for split in ('test','validation','train'):
37
  output[split]=[]
@@ -40,10 +45,13 @@ def slurp():
40
  reason='ambiguous_intent' if len(labels[key])!=1 else 'short_transcript' if len(row['sentence'].split())<3 else 'duplicate_transcript' if key in seen else None
41
  if reason:counts[split+'/'+reason]+=1;continue
42
  seen.add(key)
43
- meta=dict(id=str(row['slurp_id']),split_group_id=key,scenario=row['scenario'],entities=row['entities'],source_revision=SLURP_REVISION)
44
- output[split].append(dict(sentence1=row['sentence'],sentence2='',labels=row['intent'],metadata=json.dumps(meta,sort_keys=True)))
 
45
  return write_mirror('slurp',output,'string',dict(source='https://github.com/pswietojanski/slurp',revision=SLURP_REVISION,
46
  source_hashes=hashes,excluded=dict(counts),split_policy='native splits; exact transcript conflicts and overlap removed',
 
 
47
  conversion_sha256=hashlib.sha256(Path(__file__).read_bytes()).hexdigest(),license='cc-by-4.0'))
48
 
49
 
 
17
  MCSCRIPT_SHA256 = '50037b08123a4660e2e00ad07bcfa2a7ddc1d666b05b198d359cd2cda8f5e88c'
18
 
19
 
20
+ def _slurp_intent(row):
21
+ return row['scenario']+'_'+row['action']
22
+
23
+
24
  def slurp():
25
  """SLURP original human transcripts and intent labels, without bundled audio.
26
 
 
28
  Identical transcripts with inconsistent intents are excluded, and duplicate
29
  transcripts stay in their highest-priority native holdout (test, dev, train).
30
  One- and two-word transcripts are excluded as insufficient intent context.
31
+ Intent is the native scenario/action pair; inconsistent raw intent aliases
32
+ are retained in metadata. Original terms: CC BY 4.0.
33
  """
34
  splits={}; hashes={}; labels={};counts=Counter()
35
  for split,native in [('train','train'),('validation','devel'),('test','test')]:
36
  url=f'https://raw.githubusercontent.com/pswietojanski/slurp/{SLURP_REVISION}/dataset/slurp/{native}.jsonl'
37
  raw=urllib.request.urlopen(url).read();hashes[native]=hashlib.sha256(raw).hexdigest()
38
  splits[split]=[json.loads(line) for line in raw.splitlines() if line.strip()]
39
+ for row in splits[split]:labels.setdefault(text_key(row['sentence']),set()).add(_slurp_intent(row))
40
  output={};seen=set()
41
  for split in ('test','validation','train'):
42
  output[split]=[]
 
45
  reason='ambiguous_intent' if len(labels[key])!=1 else 'short_transcript' if len(row['sentence'].split())<3 else 'duplicate_transcript' if key in seen else None
46
  if reason:counts[split+'/'+reason]+=1;continue
47
  seen.add(key)
48
+ meta=dict(id=str(row['slurp_id']),split_group_id=key,scenario=row['scenario'],action=row['action'],
49
+ native_intent=row['intent'],entities=row['entities'],source_revision=SLURP_REVISION)
50
+ output[split].append(dict(sentence1=row['sentence'],sentence2='',labels=_slurp_intent(row),metadata=json.dumps(meta,sort_keys=True)))
51
  return write_mirror('slurp',output,'string',dict(source='https://github.com/pswietojanski/slurp',revision=SLURP_REVISION,
52
  source_hashes=hashes,excluded=dict(counts),split_policy='native splits; exact transcript conflicts and overlap removed',
53
+ intent_definition='native scenario + action',
54
+ normalized_intents={s:sum(r['intent']!=_slurp_intent(r) for r in rows) for s,rows in splits.items()},
55
  conversion_sha256=hashlib.sha256(Path(__file__).read_bytes()).hexdigest(),license='cc-by-4.0'))
56
 
57