booteek-ai commited on
Commit
48154df
·
verified ·
1 Parent(s): 98ce07a

docs: dataset card v1 (booteek pt-PT lexicon)

Browse files
Files changed (1) hide show
  1. README.md +174 -0
README.md ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - pt
5
+ tags:
6
+ - portuguese
7
+ - pt-PT
8
+ - european-portuguese
9
+ - lexicon
10
+ - ngram
11
+ - phrase-bank
12
+ - hospitality
13
+ - nlp
14
+ pretty_name: booteek pt-PT lexicon
15
+ size_categories:
16
+ - 10K<n<100K
17
+ task_categories:
18
+ - text-generation
19
+ - feature-extraction
20
+ ---
21
+
22
+ # booteek pt-PT lexicon
23
+
24
+ A SQLite lexicon of European Portuguese (**pt-PT**) unigrams, bigrams (PMI-ranked),
25
+ phrases (3/4/5-grams), and diagnostic tokens (pt-PT vs pt-BR variants), derived from
26
+ the [`booteek-ai/fineweb2-bagaco2`](https://huggingface.co/datasets/booteek-ai/fineweb2-bagaco2)
27
+ corpus (mirror of [`duarteocarmo/fineweb2-bagaco2`](https://huggingface.co/datasets/duarteocarmo/fineweb2-bagaco2)).
28
+
29
+ Built for grounding LLM outputs in **European Portuguese** (not Brazilian) — Haiku,
30
+ GPT-4, Gemini all default to pt-BR phrasing when asked for "Portuguese" without aggressive
31
+ prompting. This lexicon provides a phrase bank + collocation index + diagnostic tokens that
32
+ applications can query at runtime to:
33
+
34
+ - Score the pt-PT confidence of generated text
35
+ - Detect pt-BR-isms (`você` vs `tu`, `ônibus` vs `autocarro`, `acreditar` vs `crer`, …)
36
+ - Inject collocations and phrases into prompts as few-shot grounding
37
+ - Surface under-served pt-PT search vocabulary for SEO/AEO
38
+
39
+ ## Provenance
40
+
41
+ | Field | Value |
42
+ |---|---|
43
+ | Source corpus | [`booteek-ai/fineweb2-bagaco2`](https://huggingface.co/datasets/booteek-ai/fineweb2-bagaco2) (`all` config) |
44
+ | Upstream | [`duarteocarmo/fineweb2-bagaco2`](https://huggingface.co/datasets/duarteocarmo/fineweb2-bagaco2) → [`uonlp/CulturaX`](https://huggingface.co/datasets/uonlp/CulturaX) (pt split) filtered by [`duarteocarmo/fasttext-euptvid`](https://huggingface.co/duarteocarmo/fasttext-euptvid) |
45
+ | Docs processed | 1,000,000 |
46
+ | Tokens processed | ~390 million |
47
+ | Extraction date | 2026-05-13 |
48
+ | Extractor | `extract-pt-pt-corpus.py` v2026-05-13-v2-all-1M |
49
+ | Output size | ~17 MB |
50
+
51
+ ## Schema
52
+
53
+ Five tables. Inspect provenance with `SELECT key, value FROM meta`.
54
+
55
+ ### `unigrams`
56
+ ```sql
57
+ CREATE TABLE unigrams (
58
+ token TEXT PRIMARY KEY, -- surface form, accents preserved
59
+ count INTEGER NOT NULL, -- corpus frequency
60
+ doc_freq INTEGER NOT NULL,
61
+ pt_pt_score REAL -- avg ptpt_score from upstream
62
+ );
63
+ ```
64
+
65
+ ### `bigrams`
66
+ ```sql
67
+ CREATE TABLE bigrams (
68
+ token1 TEXT, token2 TEXT,
69
+ count INTEGER NOT NULL,
70
+ pmi REAL NOT NULL, -- pointwise mutual information, ≥ 3.0
71
+ PRIMARY KEY (token1, token2)
72
+ );
73
+ ```
74
+
75
+ ### `phrases`
76
+ ```sql
77
+ CREATE TABLE phrases (
78
+ phrase TEXT PRIMARY KEY,
79
+ length INTEGER NOT NULL, -- 3, 4, or 5
80
+ count INTEGER NOT NULL,
81
+ domain_hint TEXT -- optional: food | service | team | NULL
82
+ );
83
+ ```
84
+
85
+ ### `diagnostic_tokens`
86
+ ```sql
87
+ CREATE TABLE diagnostic_tokens (
88
+ token TEXT PRIMARY KEY,
89
+ variant TEXT NOT NULL, -- 'pt-PT' | 'pt-BR'
90
+ notes TEXT
91
+ );
92
+ ```
93
+
94
+ Used at query-time to compute pt-PT confidence and detect pt-BR-isms.
95
+
96
+ ### `meta`
97
+ Extraction provenance (source dataset, doc count, token count, extracted_at,
98
+ extractor_version, license, attribution chain).
99
+
100
+ ## Usage
101
+
102
+ ### Python
103
+ ```python
104
+ import sqlite3
105
+ from huggingface_hub import hf_hub_download
106
+
107
+ path = hf_hub_download(
108
+ repo_id="booteek-ai/pt-pt-lexicon",
109
+ filename="pt-pt-corpus.sqlite",
110
+ repo_type="dataset",
111
+ )
112
+ db = sqlite3.connect(path)
113
+
114
+ # Top collocations for "vinho"
115
+ rows = db.execute(
116
+ "SELECT token2, count, pmi FROM bigrams WHERE token1=? ORDER BY pmi DESC LIMIT 5",
117
+ ("vinho",),
118
+ ).fetchall()
119
+ # → [('tinto', ...), ('branco', ...), ('verde', ...), ('porto', ...), ...]
120
+ ```
121
+
122
+ ### TypeScript (via better-sqlite3)
123
+ booteek consumes this lexicon via `src/lib/lexicon/pt-pt.ts`. Surface API:
124
+ ```ts
125
+ import {
126
+ getTopCollocations,
127
+ getCommonPhrases,
128
+ ptPtConfidence,
129
+ detectPtBrIsms,
130
+ } from '@/lib/lexicon/pt-pt';
131
+
132
+ getTopCollocations('vinho', 5);
133
+ // → ['vinho tinto', 'vinho branco', 'vinho do porto', ...]
134
+
135
+ ptPtConfidence('Apanho o autocarro e ponho a comida no frigorífico.');
136
+ // → 0.95 (high pt-PT confidence)
137
+
138
+ detectPtBrIsms('Vou pegar o ônibus.');
139
+ // → [{ token: 'ônibus', variant: 'pt-BR', ptPtAlternative: 'autocarro' }]
140
+ ```
141
+
142
+ ## Re-extraction
143
+
144
+ The corpus is built from `booteek-ai/fineweb2-bagaco2`. See the extraction pipeline in
145
+ the [booteek monorepo](https://github.com/anthonyporto/booteek):
146
+ `scripts/lexicon/extract-pt-pt-corpus.py`.
147
+
148
+ ```bash
149
+ # Full corpus extraction (1M docs, ~90 minutes against pre-cached parquet shards)
150
+ .venv/bin/python scripts/lexicon/extract-pt-pt-corpus.py \
151
+ --config all \
152
+ --max-docs 1000000 \
153
+ --min-bigram-pmi 4.0
154
+ ```
155
+
156
+ ## License
157
+
158
+ **MIT** — preserved from the upstream
159
+ [`duarteocarmo/fineweb2-bagaco2`](https://huggingface.co/datasets/duarteocarmo/fineweb2-bagaco2)
160
+ dataset card.
161
+
162
+ ## Attribution
163
+
164
+ Derived from the FineWeb2 Bagaço2 pt-PT slice maintained by
165
+ [**Duarte O. Carmo**](https://huggingface.co/duarteocarmo) (FOSDEM speaker, pt-PT NLP).
166
+ Upstream corpus: [CulturaX](https://huggingface.co/datasets/uonlp/CulturaX).
167
+ pt-PT classifier: [fasttext-euptvid](https://huggingface.co/duarteocarmo/fasttext-euptvid).
168
+
169
+ ## Maintainer
170
+
171
+ [`booteek-ai`](https://huggingface.co/booteek-ai) on HuggingFace.
172
+ Booteek is Europe's first AI Visibility platform for independent restaurants and bars
173
+ ([booteek.ai](https://booteek.ai)). The lexicon is open under MIT for any pt-PT
174
+ NLP work — not specific to hospitality.