File size: 2,366 Bytes
04782c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Task family of a LeRobot dataset from its name and task strings. Rules fixed 2026-11-18 before any count was read;
revision 2 (same day, before the full read finished): wipe no longer matches eraser/cleanup/brush/sponge, draw is tested first.
revision 3 (after the family purity check failed fold 4/10, open-close 3/10, insert 7/10, draw 6/10): those four rules
require the action itself (fold verb; open/close + an openable thing; into a hole/socket/slot; draw + a shape, write, paint + a surface).
First matching family wins (order matters: a fold task often also says 'pick up the towel')."""
import re

FAMILIES = [
    ("fold",       r"fold(s|ing)?\b|laundry"),
    ("pour",       r"pour|scoop|powder"),
    ("stack",      r"stack|tower|\bpile|jenga"),
    ("sort",       r"\bsort|organi[sz]|by colou?r"),
    ("open-close", r"drawer|\bdoor\b|\blid\b|cabinet|\bzip|\b(open|close|shut)(s|ing)? (the |a |an )?(\w+ )?(drawer|door|lid|box|bag|cabinet|jar|bottle|laptop|microwave|fridge|oven|cap|book|container|case)\b"),
    ("press",      r"\bpress|button|switch|keyboard|\btyp(e|ing)\b"),
    ("insert",     r"insert|\bplug(s|ged|ging)?\b|peg ?hole|\bin(to)? (the |a |an )?(empty )?(\w+ )?(hole|socket|slot|port|groove)\b|keyhole|charger"),
    ("draw",       r"\bdraw(s|ing)? (a |an |the )?(\w+ )?(line|square|triangle|circle|star|smiley|face|picture|shape|letter|word|number|heart)|\bwrit(e|es|ing)\b|\bpaint(s|ing)? (the |a )?(\w+ )?(wall|paper|canvas|picture)"),
    ("wipe",       r"\bwip(e|ing)|sweep|scrub|\bmop\b|clean(ing)? (the |a )?(table|surface|board|whiteboard|window|spill|desk)|erase (the )?(white)?board"),
    ("push",       r"push|slide|hockey"),
    ("handover",   r"hand ?over|pass (it|the)|other hand|right hand|left hand"),
    ("pick-place", r"pick|place|\bput|grab|grasp|\bmove|\bbin\b|\bbox|cube|block|bowl|\bcup|basket|tray|container|\blift|\btake|transfer|drop|chess|lego|ball|bottle|toy|object"),
]
POLICY = re.compile(r"(^|[^a-z])(eval|rollout|inference|infer)", re.I)

def text(rec):
    name = rec["id"].split("/", 1)[1]
    t = " ".join([re.sub(r"[_\-]+", " ", name)] + (rec.get("tasks") or []))
    return t.lower()

def family(rec):
    t = text(rec)
    for f, p in FAMILIES:
        if re.search(p, t):
            return f
    return "other"

def is_policy(rec):
    return bool(POLICY.search(rec["id"].split("/", 1)[1]))