# Legal ML Audit Affaire Enhanced Dataset This project enhances the [les-audits-affaires](https://huggingface.co/datasets/legmlai/les-audits-affaires) dataset by adding reference citations and web search results to create a comprehensive legal dataset for French law analysis. ## Overview The project processes the base dataset from `huggingface.co/datasets/legmlai/les-audits-affaires` and enriches it with: - **Reference Citations**: Parsed from legal framework datasets based on the `legal_framework` field - **Web Search Results**: Generated by querying each question through the websearch API ## Dataset Schema The enhanced dataset contains the following columns: | Column | Type | Description | |--------|------|-------------| | `id` | string | Unique identifier for each entry | | `question` | string | Legal question or query | | `legal_framework` | string | French legal framework reference | | `reference_article_content` | string | Content of the referenced legal article | | `reference_article_title` | string | Title of the referenced legal article | | `reference_citations` | dict | Dictionary of unique legal references parsed from the content | | `websearch_result` | string | Web search results for the question | ## Legal Framework Mapping The project maps legal frameworks to specific datasets for citation parsing: | Legal Framework | Dataset | |----------------|---------| | Cadre légal: Code de commerce français | `louisbrulenaudet/code-commerce` | | Cadre légal: Code du travail français | `louisbrulenaudet/code-travail` | | Cadre légal: Code monétaire et financier | `louisbrulenaudet/code-monetaire-financier` | | Cadre légal: Droit fiscal français | ```python `None` ``` | | Cadre légal: Code général des impôts | `louisbrulenaudet/cgi` | | Cadre légal: Code de la propriété intellectuelle | `louisbrulenaudet/code-propriete-intellectuelle` | | Cadre légal: Code des assurances | `louisbrulenaudet/code-assurances` | | Cadre légal: Code de la consommation | `louisbrulenaudet/code-consommation` | | Cadre légal: Code de la commande publique | `louisbrulenaudet/code-commande-publique` | ## Project Structure ``` legml_audit_affaire_enhanced_dataset/ ├── datasets/ # Downloaded datasets storage ├── docs/ # Documentation ├── results/ # Output results ├── scripts/ # Utility scripts ├── templates/ # README templates for final dataset ├── tests/ # Test files ├── utils/ # Core processing modules │ ├── dataops/ # Dataset operations │ ├── web/ # Web search functionality │ │ └── websearch.py # Web search implementation │ └── {dataset_name}/ # Parser modules for each legal framework │ └── parser.py # Content parsing logic ├── main.py # Main execution script ├── requirements.txt # Python dependencies └── README.md # This file ``` ## Dependencies - `huggingface_datasets` - Dataset loading and manipulation - `gradio_client` - Web search API integration - `huggingface_hub` - Hugging Face Hub operations ## Installation 1. Clone the repository: ```bash git clone cd legml_audit_affaire_enhanced_dataset ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` ## Usage ### Running the Main Script ```bash python main.py ``` This will: 1. Download the base dataset from `legmlai/les-audits-affaires` 2. Download legal framework datasets based on the mapping (None for Legal Framework "Droit Fiscal Francais") 3. Parse reference citations from legal content 4. Generate web search results for each question 5. Create the enhanced dataset with all additional columns ### Processing Pipeline 1. **Dataset Loading**: Downloads the base dataset and legal framework datasets 2. **Citation Parsing**: For each entry, parses the `reference_article_content` to extract citations based on the `legal_framework` 3. **Web Search**: Queries the websearch API for each question using the Gradio client 4. **Dataset Enhancement**: Combines all data into the final enhanced dataset ## Output The enhanced dataset will be saved in the `results/` directory with the final dataset : - Enhanced dataset with all original columns plus `reference_citations` and `websearch_result` ## Contributing 1. Fork the repository 2. Create a feature branch 3. Make your changes 4. Add tests if applicable 5. Submit a pull request ## License [Add your license information here] ## Citation If you use this dataset in your research, please cite: ```bibtex @dataset{legml_audit_affaire_enhanced, title={Legal ML Audit Affaire Enhanced Dataset}, author={[Your Name/Organization]}, year={2024}, url={[Dataset URL]} } ``` ## Acknowledgments - Original dataset: [les-audits-affaires](https://huggingface.co/datasets/legmlai/les-audits-affaires) - Legal framework datasets: [louisbrulenaudet](https://huggingface.co/louisbrulenaudet) - Web search API: [victor/websearch](https://huggingface.co/spaces/victor/websearch)