adding dataset into repo
Browse files- .gitignore +2 -0
- README.md +13 -0
- articles.parquet +3 -0
- container/Dockerfile +0 -0
- notebooks_preprocess/preprocess_xml.ipynb +177 -0
- raw/.gitattributes +2 -0
- raw/Code civil.xml +3 -0
- raw/Code de la consommation.xml +3 -0
- raw/Code de la propriété intellectuelle.xml +3 -0
- raw/Code de la route.xml +3 -0
- raw/Code de la santé publique.xml +3 -0
- raw/Code de la sécurité sociale.xml +3 -0
- raw/Code du travail.xml +3 -0
- raw/Code général des impôts.xml +3 -0
- raw/Code pénal.xml +3 -0
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
.DS_Store
|
README.md
CHANGED
|
@@ -11,3 +11,16 @@ Les principaux pdfs correspondent aux différents code de lois (civil / pénal e
|
|
| 11 |
|
| 12 |
Il s'agit des pdfs preparsés qui peuvent être ensuite utilisé dans des appli autour du NLP / LLMs dans un soucis de collaborations.
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
Il s'agit des pdfs preparsés qui peuvent être ensuite utilisé dans des appli autour du NLP / LLMs dans un soucis de collaborations.
|
| 13 |
|
| 14 |
+
Les différents codes ont été extrait en format XML ici : https://codes.droit.org/
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Les formats XML permet de faire un meilleurs preprocessing des codes de loi.
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
La structure des données :
|
| 21 |
+
|
| 22 |
+
- dans raw/ on retrouve les différents codes en format xml.
|
| 23 |
+
|
| 24 |
+
- dans notebooks_preprocess/ on retrouve les différents notebooks qui ont permis de constitué le dataset final.
|
| 25 |
+
|
| 26 |
+
|
articles.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 4,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"import pandas as pd\n",
|
| 10 |
+
"import numpy as np\n",
|
| 11 |
+
"\n",
|
| 12 |
+
"# import xml parsing tools\n",
|
| 13 |
+
"import xml.etree.ElementTree as ET\n"
|
| 14 |
+
]
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"cell_type": "code",
|
| 18 |
+
"execution_count": 59,
|
| 19 |
+
"metadata": {},
|
| 20 |
+
"outputs": [
|
| 21 |
+
{
|
| 22 |
+
"name": "stdout",
|
| 23 |
+
"output_type": "stream",
|
| 24 |
+
"text": [
|
| 25 |
+
"Found 9 files\n",
|
| 26 |
+
"Parsing Code de la consommation.xml\n",
|
| 27 |
+
"Found 2164 articles\n",
|
| 28 |
+
"Parsing Code civil.xml\n",
|
| 29 |
+
"Found 2881 articles\n",
|
| 30 |
+
"Parsing Code du travail.xml\n",
|
| 31 |
+
"Found 11258 articles\n",
|
| 32 |
+
"Parsing Code général des impôts.xml\n",
|
| 33 |
+
"Found 2315 articles\n",
|
| 34 |
+
"Parsing Code de la propriété intellectuelle.xml\n",
|
| 35 |
+
"Found 1896 articles\n",
|
| 36 |
+
"Parsing Code de la santé publique.xml\n",
|
| 37 |
+
"Found 13242 articles\n",
|
| 38 |
+
"Parsing Code de la sécurité sociale.xml\n",
|
| 39 |
+
"Found 7318 articles\n",
|
| 40 |
+
"Parsing Code pénal.xml\n",
|
| 41 |
+
"Found 1303 articles\n",
|
| 42 |
+
"Parsing Code de la route.xml\n",
|
| 43 |
+
"Found 1157 articles\n"
|
| 44 |
+
]
|
| 45 |
+
}
|
| 46 |
+
],
|
| 47 |
+
"source": [
|
| 48 |
+
"def retrieve_every_article_xml(xml_file):\n",
|
| 49 |
+
" \"\"\"\n",
|
| 50 |
+
" This function retrieves all the articles from a xml file\n",
|
| 51 |
+
" \"\"\"\n",
|
| 52 |
+
" tree = ET.parse(xml_file)\n",
|
| 53 |
+
" root = tree.getroot()\n",
|
| 54 |
+
" \n",
|
| 55 |
+
" # find all xml tags with the name \"article\"\n",
|
| 56 |
+
" articles = root.findall(\".//article\")\n",
|
| 57 |
+
" print(\"Found {} articles\".format(len(articles)))\n",
|
| 58 |
+
" \n",
|
| 59 |
+
" return articles\n",
|
| 60 |
+
"\n",
|
| 61 |
+
"def parse_article_xml(article):\n",
|
| 62 |
+
" \n",
|
| 63 |
+
" # we we check if there is any children\n",
|
| 64 |
+
" return \"\".join(article.itertext())\n",
|
| 65 |
+
"\n",
|
| 66 |
+
"def main(main_folder=\"/Users/adrienbufort/Documents/workspace/datasets/LoiLibre/raw\"):\n",
|
| 67 |
+
" \n",
|
| 68 |
+
" # npw we can list all the xml files in the folder\n",
|
| 69 |
+
" import os\n",
|
| 70 |
+
" files = os.listdir(main_folder)\n",
|
| 71 |
+
" files = [f for f in files if f.endswith(\".xml\")]\n",
|
| 72 |
+
" print(\"Found {} files\".format(len(files)))\n",
|
| 73 |
+
" \n",
|
| 74 |
+
" # we can now parse all the files \n",
|
| 75 |
+
" df_articles = []\n",
|
| 76 |
+
" \n",
|
| 77 |
+
" for f in files:\n",
|
| 78 |
+
" print(\"Parsing {}\".format(f))\n",
|
| 79 |
+
" articles = retrieve_every_article_xml(os.path.join(main_folder, f))\n",
|
| 80 |
+
" articles_text = [parse_article_xml(a) for a in articles]\n",
|
| 81 |
+
" articles_metadata = [a.attrib for a in articles]\n",
|
| 82 |
+
" \n",
|
| 83 |
+
" dataframe_articles = pd.DataFrame({\"text\": articles_text})\n",
|
| 84 |
+
" dataframe_metadata = pd.DataFrame(articles_metadata)\n",
|
| 85 |
+
" \n",
|
| 86 |
+
" # concatenate the columns\n",
|
| 87 |
+
" dataframe_tmp = pd.concat([dataframe_articles, dataframe_metadata], axis=1)\n",
|
| 88 |
+
" df_articles.append(dataframe_tmp)\n",
|
| 89 |
+
" \n",
|
| 90 |
+
" # concatenate all the dataframes\n",
|
| 91 |
+
" df_articles = pd.concat(df_articles)\n",
|
| 92 |
+
" \n",
|
| 93 |
+
" return df_articles\n",
|
| 94 |
+
"\n",
|
| 95 |
+
"# we can now parse all the files\n",
|
| 96 |
+
"articles = main()\n",
|
| 97 |
+
" \n",
|
| 98 |
+
" \n",
|
| 99 |
+
" \n",
|
| 100 |
+
"\n"
|
| 101 |
+
]
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"cell_type": "code",
|
| 105 |
+
"execution_count": 61,
|
| 106 |
+
"metadata": {},
|
| 107 |
+
"outputs": [],
|
| 108 |
+
"source": [
|
| 109 |
+
"# strip the text\n",
|
| 110 |
+
"articles[\"text\"] = articles[\"text\"].str.strip()"
|
| 111 |
+
]
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"cell_type": "code",
|
| 115 |
+
"execution_count": 69,
|
| 116 |
+
"metadata": {},
|
| 117 |
+
"outputs": [],
|
| 118 |
+
"source": [
|
| 119 |
+
"# save the dataframe\n",
|
| 120 |
+
"articles.to_parquet(\"../articles.parquet\")"
|
| 121 |
+
]
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"cell_type": "code",
|
| 125 |
+
"execution_count": 68,
|
| 126 |
+
"metadata": {},
|
| 127 |
+
"outputs": [
|
| 128 |
+
{
|
| 129 |
+
"name": "stdout",
|
| 130 |
+
"output_type": "stream",
|
| 131 |
+
"text": [
|
| 132 |
+
"Defaulting to user installation because normal site-packages is not writeable\n",
|
| 133 |
+
"Collecting pyarrow\n",
|
| 134 |
+
" Downloading pyarrow-14.0.1-cp39-cp39-macosx_11_0_arm64.whl (24.0 MB)\n",
|
| 135 |
+
"\u001b[K |████████████████████████████████| 24.0 MB 14.7 MB/s eta 0:00:01\n",
|
| 136 |
+
"\u001b[?25hRequirement already satisfied: numpy>=1.16.6 in /Users/adrienbufort/Library/Python/3.9/lib/python/site-packages (from pyarrow) (1.25.1)\n",
|
| 137 |
+
"Installing collected packages: pyarrow\n",
|
| 138 |
+
"Successfully installed pyarrow-14.0.1\n",
|
| 139 |
+
"\u001b[33mWARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.\n",
|
| 140 |
+
"You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n"
|
| 141 |
+
]
|
| 142 |
+
}
|
| 143 |
+
],
|
| 144 |
+
"source": [
|
| 145 |
+
"!pip3 install pyarrow"
|
| 146 |
+
]
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"cell_type": "code",
|
| 150 |
+
"execution_count": null,
|
| 151 |
+
"metadata": {},
|
| 152 |
+
"outputs": [],
|
| 153 |
+
"source": []
|
| 154 |
+
}
|
| 155 |
+
],
|
| 156 |
+
"metadata": {
|
| 157 |
+
"kernelspec": {
|
| 158 |
+
"display_name": "Python 3",
|
| 159 |
+
"language": "python",
|
| 160 |
+
"name": "python3"
|
| 161 |
+
},
|
| 162 |
+
"language_info": {
|
| 163 |
+
"codemirror_mode": {
|
| 164 |
+
"name": "ipython",
|
| 165 |
+
"version": 3
|
| 166 |
+
},
|
| 167 |
+
"file_extension": ".py",
|
| 168 |
+
"mimetype": "text/x-python",
|
| 169 |
+
"name": "python",
|
| 170 |
+
"nbconvert_exporter": "python",
|
| 171 |
+
"pygments_lexer": "ipython3",
|
| 172 |
+
"version": "3.9.6"
|
| 173 |
+
}
|
| 174 |
+
},
|
| 175 |
+
"nbformat": 4,
|
| 176 |
+
"nbformat_minor": 2
|
| 177 |
+
}
|
raw/.gitattributes
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.xml filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.xml filter=lfs diff=lfs merge=lfs -text
|
raw/Code civil.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5c7e13800690fb56fb5429380c2690be705e7fefdc10b490536ef01a00cba936
|
| 3 |
+
size 2207870
|
raw/Code de la consommation.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cad3609ac5fa0d6c8a77d39b0464580c9d95cbabf5f7d9e6debfe495e2dd68b8
|
| 3 |
+
size 3124402
|
raw/Code de la propriété intellectuelle.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:554f2d06e1c86d343ecedfb49c9bc20da4eafa5278b20da8fa599028fd0fa682
|
| 3 |
+
size 2907670
|
raw/Code de la route.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d964aae0f38e2e8594eda9b5cd03b1c63821590f4cab1a4b537af5774a27419f
|
| 3 |
+
size 2163799
|
raw/Code de la santé publique.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9bc0a7cbbb7a6dc0bb1898a0ae2833038f576337e3c5b5d9bee8b60c5c3fff44
|
| 3 |
+
size 21578146
|
raw/Code de la sécurité sociale.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28fcb8ea16018fd4183893bb60803c0c12dcc460a7d1be57a503e6a7968d1e08
|
| 3 |
+
size 14720826
|
raw/Code du travail.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5505ba3afa6f54bd873aed3459d89e20c9b536e2b91752c77843545c4141013a
|
| 3 |
+
size 14168348
|
raw/Code général des impôts.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1cd7119875730f0c80b691776980f2363921a3a7c949d912f22eea236a8f130f
|
| 3 |
+
size 7816294
|
raw/Code pénal.xml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:431a7154eca1c5fc2ea241300e44e9bce00dd45836b8c632f61b2ad14d6d4bc9
|
| 3 |
+
size 1707626
|