Datasets:
Download code/v4_intent.py from kitaniai/OpenJudgment-4B-Preview: direct link, hf CLI and curl.
- Browser
- Download file 3.99 kB
-
https://huggingface.co/datasets/kitaniai/OpenJudgment-4B-Preview/resolve/main/code/v4_intent.py
- Command line
-
hf download hf://datasets/kitaniai/OpenJudgment-4B-Preview/code/v4_intent.py
-
curl -L -o v4_intent.py https://huggingface.co/datasets/kitaniai/OpenJudgment-4B-Preview/resolve/main/code/v4_intent.py
3.99 kB
| """Pure UAReviews intent adapter. No downloading, translation or training. | |
| The Hub exposes one physical train file containing THREE logical splits. Always | |
| use source_split returned here, never the Hub container split. Keep test and | |
| challenge exclusively for evaluation, including when deduplicating against train. | |
| The caller must group duplicate texts across splits and give evaluation priority. | |
| Human final labels are categorical judgments, not measured probabilities. Only | |
| 20% of the source received the paper's three-annotator gold validation; the file | |
| does not identify that subset, so no row is claimed to be independently verified. | |
| """ | |
| import unicodedata | |
| SOURCE = { | |
| "repo": "KSE-RESEARCH-Group/UAReviews", | |
| "revision": "6f2ad474981e453fdf483dee1a6db060888bb212", | |
| "license": "cc-by-4.0", | |
| "file": "benchmark_v1_splits.jsonl", | |
| "card": "https://huggingface.co/datasets/KSE-RESEARCH-Group/UAReviews/blob/" | |
| "6f2ad474981e453fdf483dee1a6db060888bb212/README.md", | |
| "paper": "https://aclanthology.org/2026.unlp-1.2/", | |
| } | |
| # Exact source taxonomy. Candidate wording stays faithful to the published card; | |
| # no invented detailed decision rules or translated Ukrainian input are added. | |
| CANDIDATES = ( | |
| "Gratitude / Positive Feedback", | |
| "Complaint / Dissatisfaction", | |
| "Question / Request for Help", | |
| "Suggestion / Idea", | |
| "Neutral Comment", | |
| ) | |
| KEYS = ("gratitude", "complaint", "question", "suggestion", "neutral") | |
| SPLIT_COUNTS = {"train": 8106, "test": 1737, "challenge": 1737} | |
| INSTRUCTIONS = ( | |
| "Classify the primary communicative intent of this Ukrainian user review or " | |
| "feedback comment using the five provided categories. Select one category." | |
| ) | |
| def adapt(record, expected_split=None): | |
| """Return zero/one Choice task; fail closed on absent/unknown logical splits. | |
| expected_split optionally asserts a caller's logical partition; it must not | |
| be passed as 'train' simply because HF loaded a physical train container. | |
| Unknown labels are errors rather than silently reinterpreted classifications. | |
| Source ratings, emotions, IDs, labels and provenance stay audit-only. | |
| """ | |
| if not isinstance(record, dict): | |
| return [] | |
| split = record.get("split") | |
| if split not in SPLIT_COUNTS: | |
| raise ValueError("UAReviews requires a train/test/challenge row-level split") | |
| if expected_split is not None and expected_split != split: | |
| raise ValueError("UAReviews row-level split differs from requested partition") | |
| label = record.get("final_category") | |
| if label not in CANDIDATES: | |
| raise ValueError("Unknown UAReviews intent label: %r" % label) | |
| content = record.get("content") | |
| if not isinstance(content, str) or not content.strip(): | |
| return [] | |
| state = content.replace("\r\n", "\n").replace("\r", "\n") | |
| group_key = " ".join(unicodedata.normalize("NFC", state).casefold().split()) | |
| return [{ | |
| "state": state, | |
| "instructions": INSTRUCTIONS, | |
| "candidates": list(CANDIDATES), | |
| "keys": list(KEYS), | |
| "target": [float(candidate == label) for candidate in CANDIDATES], | |
| "kind": "choice", | |
| "group_key": group_key, | |
| "source_split": split, | |
| "split": split, | |
| "metadata": { | |
| "source": SOURCE["repo"], | |
| "source_revision": SOURCE["revision"], | |
| "source_license": SOURCE["license"], | |
| "source_card": SOURCE["card"], | |
| "source_paper": SOURCE["paper"], | |
| "source_file": SOURCE["file"], | |
| "source_row_id": record.get("id"), | |
| "source_split": split, | |
| "evaluation_only": split != "train", | |
| "source_origin": record.get("source"), | |
| "language": "uk", | |
| "label_method": "published_final_human_intent_annotation", | |
| "target_semantics": "one_hot_categorical_annotation_not_calibrated_probability", | |
| "independent_gold_subset_membership": "not_identified_in_source", | |
| }, | |
| }] | |