File size: 5,258 Bytes
96e8f56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# 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 <repository-url>
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)