ArthurSrz commited on
Commit
b68fea2
·
verified ·
1 Parent(s): 7d48f25

docs: update dataset card with 4 daily sources and full schema

Browse files
Files changed (1) hide show
  1. README.md +112 -93
README.md CHANGED
@@ -7,6 +7,8 @@ tags:
7
  - french-law
8
  - embeddings
9
  - legifrance
 
 
10
  - mistral
11
  size_categories:
12
  - 10K<n<100K
@@ -31,32 +33,86 @@ configs:
31
 
32
  # Open Codes
33
 
34
- Open dataset of French legal code articles with embeddings.
35
 
36
- Chunked articles from French legal codes sourced from
37
- [Legifrance](https://www.legifrance.gouv.fr/) via the PISTE API,
38
  with 1024-dimensional embeddings generated by Mistral AI.
39
 
40
- Each row is a text chunk enriched with full article metadata from the parent
41
- legal code article.
 
 
 
 
 
 
42
 
43
  ## Dataset Description
44
 
45
- - **Source**: [PISTE Legifrance API](https://piste.gouv.fr/) (official French government legal database)
46
  - **License**: [Licence Ouverte / Etalab 2.0](https://www.etalab.gouv.fr/licence-ouverte-open-licence/)
47
  - **Embeddings**: Mistral AI `mistral-embed` (1024 dimensions)
48
- - **Update frequency**: Daily (nightly sync at 02:00 UTC, dataset push at 06:00 UTC)
49
- - **Codes**: Dynamically sourced from `LEX_codes_piste` (active codes only)
50
  - **Quality**: Dedup + stale-chunk filtering applied before every push
51
 
52
- ### Legal codes included
 
 
 
 
 
 
 
 
53
 
54
  The list of legal codes is dynamic and managed in the `LEX_codes_piste` table.
55
  Adding a new code there (with `actif=true`) automatically includes it in the next sync and export.
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  ## Schema
58
 
59
- ### Chunk fields
 
 
 
 
 
 
 
 
 
60
  | Column | Type | Description |
61
  |--------|------|-------------|
62
  | `chunk_text` | string | Text content of the chunk |
@@ -71,7 +127,7 @@ Adding a new code there (with `actif=true`) automatically includes it in the nex
71
  | `etat` | string | Article status (VIGUEUR, ABROGE, etc.) |
72
  | `fullSectionsTitre` | string | Full hierarchy path in the code |
73
 
74
- ### Article metadata fields (prefixed `article_`)
75
 
76
  #### Identifiers
77
  | Column | Type | Description |
@@ -97,109 +153,72 @@ Adding a new code there (with `actif=true`) automatically includes it in the nex
97
 
98
  #### Dates & Status
99
 
100
- **Date format**: `article_dateDebut` and `article_dateFin` are stored as **Unix timestamps in milliseconds** (string type). This is the raw format returned by the Legifrance PISTE API.
101
-
102
- To convert to a human-readable date in Python:
103
-
104
- ```python
105
- from datetime import datetime, timezone
106
-
107
- timestamp_ms = "1301529600000"
108
- dt = datetime.fromtimestamp(int(timestamp_ms) / 1000, tz=timezone.utc)
109
- print(dt) # 2011-03-31 00:00:00+00:00
110
- ```
111
-
112
- Special value: `32472144000000` (year 2999) means "no end date" — the article is in force indefinitely.
113
 
114
  | Column | Type | Description |
115
  |--------|------|-------------|
116
  | `article_dateDebut` | string | Effective start date (Unix ms) |
117
  | `article_dateFin` | string | Effective end date (Unix ms, `32472144000000` = indefinite) |
118
- | `article_dateDebutExtension` | string | Extension start date (Unix ms) |
119
- | `article_dateFinExtension` | string | Extension end date (Unix ms) |
120
  | `article_etat` | string | Status: `VIGUEUR` (in force), `ABROGE` (repealed), etc. |
121
- | `article_type_article` | string | Article type |
122
- | `article_nature` | string | Legal nature |
123
- | `article_origine` | string | Origin (e.g. `LEGI`) |
124
- | `article_version_article` | string | Version identifier |
125
- | `article_versionPrecedente` | string | Previous version ID |
126
- | `article_multipleVersions` | bool | Has multiple versions |
127
 
128
  #### Hierarchy
129
  | Column | Type | Description |
130
  |--------|------|-------------|
131
- | `article_sectionParentId` | string | Parent section ID |
132
- | `article_sectionParentCid` | string | Parent section consolidated ID |
133
- | `article_sectionParentTitre` | string | Parent section title |
134
  | `article_fullSectionsTitre` | string | Full hierarchy path |
135
- | `article_ordre` | int32 | Sort order within the code |
136
  | `article_partie` | string | Partie (e.g. "Partie legislative") |
137
  | `article_livre` | string | Livre |
138
  | `article_titre` | string | Titre |
139
  | `article_chapitre` | string | Chapitre |
140
  | `article_section` | string | Section |
141
  | `article_sous_section` | string | Sous-section |
142
- | `article_paragraphe` | string | Paragraphe |
143
 
144
- #### Extras
145
  | Column | Type | Description |
146
  |--------|------|-------------|
147
- | `article_infosComplementaires` | string | Additional info (plain text) |
148
- | `article_infosComplementairesHtml` | string | Additional info (HTML) |
149
- | `article_conditionDiffere` | string | Deferred condition |
150
- | `article_infosRestructurationBranche` | string | Branch restructuring info |
151
- | `article_infosRestructurationBrancheHtml` | string | Branch restructuring (HTML) |
152
- | `article_renvoi` | string | Cross-references |
153
- | `article_comporteLiensSP` | bool | Contains SP links |
154
- | `article_idTechInjection` | string | Technical injection ID |
155
- | `article_refInjection` | string | Injection reference |
156
- | `article_numeroBo` | string | BO number |
157
- | `article_inap` | string | INAP code |
158
-
159
- ## Configs
160
-
161
- | Config | Description | Source |
162
- |--------|-------------|--------|
163
- | `default` | Code articles + chunks from Legifrance PISTE API | `REF_codes_legifrance` + `REF_article_chunks` |
164
- | `jurisprudence` | Court decisions from Judilibre API | `REF_decisions_judilibre` + `REF_legal_chunks` |
165
- | `circulaires` | Government circulars | `REF_circulaires` + `REF_legal_chunks` |
166
- | `reponses_legis` | Parliamentary written answers | `REF_reponses_ministerial` + `REF_legal_chunks` |
167
-
168
- ## Usage
169
-
170
- ```python
171
- from datasets import load_dataset
172
- from datetime import datetime, timezone
173
-
174
- # Load default config (code articles)
175
- ds = load_dataset("ArthurSrz/open_codes", split="train")
176
-
177
- # Load jurisprudence config (court decisions)
178
- juris = load_dataset("ArthurSrz/open_codes", "jurisprudence", split="train")
179
-
180
- # Access a chunk with its embedding and article metadata
181
- row = ds[0]
182
- print(row["code_name"]) # e.g. "Code civil"
183
- print(row["chunk_text"][:200])
184
- print(len(row["embedding"])) # 1024
185
-
186
- # Convert dates from Unix ms to datetime
187
- date_debut = datetime.fromtimestamp(int(row["article_dateDebut"]) / 1000, tz=timezone.utc)
188
- print(date_debut) # e.g. 2011-03-31 00:00:00+00:00
189
-
190
- # Filter by legal code
191
- code_civil = ds.filter(lambda x: x["code_name"] == "Code civil")
192
-
193
- # Filter active articles only
194
- en_vigueur = ds.filter(lambda x: x["article_etat"] == "VIGUEUR")
195
-
196
- # Use embeddings for semantic search
197
- import numpy as np
198
- query_emb = np.array(ds[0]["embedding"])
199
- ```
200
 
201
  ## Provenance
202
 
203
  Built by the [marIAnne](https://github.com/ArthurSrz/open_codes) project.
204
- Sync pipeline fetches articles nightly from PISTE Legifrance, chunks them,
205
- and generates embeddings via Mistral AI.
 
 
 
 
 
 
7
  - french-law
8
  - embeddings
9
  - legifrance
10
+ - judilibre
11
+ - circulaires
12
  - mistral
13
  size_categories:
14
  - 10K<n<100K
 
33
 
34
  # Open Codes
35
 
36
+ Open dataset of French legal texts with semantic embeddings, updated daily from 4 official sources.
37
 
38
+ Chunked texts from French legal codes, court decisions, government circulars, and parliamentary Q&A,
 
39
  with 1024-dimensional embeddings generated by Mistral AI.
40
 
41
+ ## Sources updated daily
42
+
43
+ | Source | Description | Config | Volume |
44
+ |--------|-------------|--------|--------|
45
+ | **Codes** | 5 major legal codes from Legifrance | `default` | ~26K chunks |
46
+ | **Decisions de justice** | Court decisions from Judilibre | `jurisprudence` | ~82K decisions |
47
+ | **Circulaires** | Government circulars | `circulaires` | ~10K circulaires |
48
+ | **Questions & Reponses** | Parliamentary Q&A (reponses ministerielles) | `reponses_legis` | ~40K reponses |
49
 
50
  ## Dataset Description
51
 
52
+ - **Sources**: [PISTE Legifrance API](https://piste.gouv.fr/), [Judilibre API](https://www.courdecassation.fr/acces-rapide-judilibre), [DILA JORF](https://journal-officiel.gouv.fr/)
53
  - **License**: [Licence Ouverte / Etalab 2.0](https://www.etalab.gouv.fr/licence-ouverte-open-licence/)
54
  - **Embeddings**: Mistral AI `mistral-embed` (1024 dimensions)
55
+ - **Update frequency**: Daily (nightly sync at 02:00 UTC, dataset push at 07:00 UTC)
 
56
  - **Quality**: Dedup + stale-chunk filtering applied before every push
57
 
58
+ ### Legal codes included (default config)
59
+
60
+ | Code | Domain |
61
+ |------|--------|
62
+ | Code civil | Core private law |
63
+ | Code de l'urbanisme | Urban planning |
64
+ | Code electoral | Electoral law |
65
+ | Code general des collectivites territoriales | Local government |
66
+ | Code des communes | Municipal law |
67
 
68
  The list of legal codes is dynamic and managed in the `LEX_codes_piste` table.
69
  Adding a new code there (with `actif=true`) automatically includes it in the next sync and export.
70
 
71
+ ## Usage
72
+
73
+ ```python
74
+ from datasets import load_dataset
75
+
76
+ # Load code articles (default config)
77
+ codes = load_dataset("ArthurSrz/open_codes", split="train")
78
+
79
+ # Load other sources
80
+ jurisprudence = load_dataset("ArthurSrz/open_codes", "jurisprudence", split="train")
81
+ circulaires = load_dataset("ArthurSrz/open_codes", "circulaires", split="train")
82
+ reponses = load_dataset("ArthurSrz/open_codes", "reponses_legis", split="train")
83
+
84
+ # Browse a chunk
85
+ row = codes[0]
86
+ print(row["code_name"]) # e.g. "Code civil"
87
+ print(row["chunk_text"][:200])
88
+ print(len(row["embedding"])) # 1024
89
+
90
+ # Convert dates from Unix ms to datetime
91
+ from datetime import datetime, timezone
92
+ date_debut = datetime.fromtimestamp(int(row["article_dateDebut"]) / 1000, tz=timezone.utc)
93
+ print(date_debut) # e.g. 2011-03-31 00:00:00+00:00
94
+
95
+ # Use embeddings for semantic search
96
+ import numpy as np
97
+ query_emb = get_embedding("responsabilite civile") # your embedding function
98
+ scores = np.dot(np.array(codes["embedding"]), query_emb)
99
+ top_k = np.argsort(scores)[-5:][::-1]
100
+ for i in top_k:
101
+ print(f"{codes[i]['code_name']} {codes[i]['num']}: {codes[i]['chunk_text'][:100]}")
102
+ ```
103
+
104
  ## Schema
105
 
106
+ ### Configs
107
+
108
+ | Config | Description | Source |
109
+ |--------|-------------|--------|
110
+ | `default` | Code articles + chunks from Legifrance PISTE API | `REF_codes_legifrance` + `REF_article_chunks` |
111
+ | `jurisprudence` | Court decisions from Judilibre API | `REF_decisions_judilibre` + `REF_legal_chunks` |
112
+ | `circulaires` | Government circulars | `REF_circulaires` + `REF_legal_chunks` |
113
+ | `reponses_legis` | Parliamentary written answers | `REF_reponses_ministerial` + `REF_legal_chunks` |
114
+
115
+ ### Default config — Chunk fields
116
  | Column | Type | Description |
117
  |--------|------|-------------|
118
  | `chunk_text` | string | Text content of the chunk |
 
127
  | `etat` | string | Article status (VIGUEUR, ABROGE, etc.) |
128
  | `fullSectionsTitre` | string | Full hierarchy path in the code |
129
 
130
+ ### Default config — Article metadata fields (prefixed `article_`)
131
 
132
  #### Identifiers
133
  | Column | Type | Description |
 
153
 
154
  #### Dates & Status
155
 
156
+ **Date format**: `article_dateDebut` and `article_dateFin` are stored as **Unix timestamps in milliseconds** (string type). Special value: `32472144000000` (year 2999) means "no end date" — the article is in force indefinitely.
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  | Column | Type | Description |
159
  |--------|------|-------------|
160
  | `article_dateDebut` | string | Effective start date (Unix ms) |
161
  | `article_dateFin` | string | Effective end date (Unix ms, `32472144000000` = indefinite) |
 
 
162
  | `article_etat` | string | Status: `VIGUEUR` (in force), `ABROGE` (repealed), etc. |
 
 
 
 
 
 
163
 
164
  #### Hierarchy
165
  | Column | Type | Description |
166
  |--------|------|-------------|
 
 
 
167
  | `article_fullSectionsTitre` | string | Full hierarchy path |
 
168
  | `article_partie` | string | Partie (e.g. "Partie legislative") |
169
  | `article_livre` | string | Livre |
170
  | `article_titre` | string | Titre |
171
  | `article_chapitre` | string | Chapitre |
172
  | `article_section` | string | Section |
173
  | `article_sous_section` | string | Sous-section |
 
174
 
175
+ ### Jurisprudence config
176
  | Column | Type | Description |
177
  |--------|------|-------------|
178
+ | `chunk_text` | string | Decision text chunk |
179
+ | `embedding` | float32[1024] | Mistral AI embedding vector |
180
+ | `source_id` | string | Judilibre decision ID |
181
+ | `chunk_index` | int32 | Chunk position |
182
+ | `jurisdiction` | string | Court (e.g. Cour de cassation) |
183
+ | `chamber` | string | Chamber |
184
+ | `date_decision` | string | Decision date |
185
+ | `solution` | string | Decision outcome |
186
+ | `fiche_arret` | string | Case summary |
187
+ | `url_judilibre` | string | Judilibre URL |
188
+
189
+ ### Circulaires config
190
+ | Column | Type | Description |
191
+ |--------|------|-------------|
192
+ | `chunk_text` | string | Circular text chunk |
193
+ | `embedding` | float32[1024] | Mistral AI embedding vector |
194
+ | `source_id` | string | Circulaire ID |
195
+ | `chunk_index` | int32 | Chunk position |
196
+ | `numero` | string | Circular number |
197
+ | `date_parution` | string | Publication date |
198
+ | `ministere` | string | Issuing ministry |
199
+ | `objet` | string | Subject |
200
+ | `url_legifrance` | string | Legifrance URL |
201
+
202
+ ### Reponses legis config
203
+ | Column | Type | Description |
204
+ |--------|------|-------------|
205
+ | `chunk_text` | string | Answer text chunk |
206
+ | `embedding` | float32[1024] | Mistral AI embedding vector |
207
+ | `source_id` | string | Reponse ID |
208
+ | `chunk_index` | int32 | Chunk position |
209
+ | `numero_question` | string | Question number |
210
+ | `date_reponse` | string | Answer date |
211
+ | `ministere` | string | Answering ministry |
212
+ | `question_text` | string | Original question |
213
+ | `url_legifrance` | string | Legifrance URL |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
  ## Provenance
216
 
217
  Built by the [marIAnne](https://github.com/ArthurSrz/open_codes) project.
218
+
219
+ - Legal codes & circulaires: [PISTE / Legifrance](https://piste.gouv.fr/)
220
+ - Jurisprudence: [Judilibre / Cour de cassation](https://www.courdecassation.fr/acces-rapide-judilibre)
221
+ - Reponses ministerielles: [DILA / Journal officiel](https://journal-officiel.gouv.fr/)
222
+ - Embeddings: [Mistral AI](https://mistral.ai/)
223
+ - Backend: [Xano](https://www.xano.com/)
224
+ - Dataset hosting: [HuggingFace Hub](https://huggingface.co/)