Views
No views yet
| Id | Label | Description |
|---|---|---|
| 0 | O | Not a legal act and not an article |
| 1 | abbreviation_relevant_following_act | A legal act abbreviation relevant to the following legal act |
| 2 | abbreviation_relevant_previous_act | A legal act abbreviation relevant to a previously mentioned legal act |
| 3 | another_act | A legal act |
| 4 | another_act_abbreviation | A legal act mentioned as an abbreviation |
| 5 | another_act_equal_previous_act | An assumed legal act introduced previously |
| 6 | another_act_sequence_end | Inside a sequence of legal acts |
| 7 | another_act_sequence_start | At the beginning of a sequence of legal acts |
| 8 | another_article_equal_previous_article | An assumed article introduced previously |
| 9 | article_current | An article mentioning itself |
| 10 | article_relevant_current_act | An article of the same legal act as the one being processed |
| 11 | article_relevant_current_act_range_end | A range end of articles belonging to the current act |
| 12 | article_relevant_current_act_range_start | A range start of articles belonging to the current act |
| 13 | article_relevant_following_act | An article of a following legal act |
| 15 | article_relevant_following_act_range_end | A range end of articles belonging to a following act |
| 16 | article_relevant_following_act_range_start | A range start of articles belonging to a following legal act |
| 17 | article_relevant_previous_act | An article of a previously mentioned legal act |
| 18 | article_relevant_previous_act_range_end | A range end of articles belonging to a previously mentioned legal act |
| 19 | article_relevant_previous_act_range_start | A range start of articles belonging to a previously mentioned legal act |
| 20 | current_act | A legal act mentioning itself |
| 21 | treaty_abbreviation | A treaty mentioned as an abbreviation |
| 22 | treaty_name | A treaty |
| 23 | service_label | A token comprising more than 1 label |
1from transformers import (
2 TokenClassificationPipeline,
3 RobertaForTokenClassification,
4 RobertaTokenizerFast,
5)
6
7legal_act_extraction_model = RobertaForTokenClassification.from_pretrained(
8 'Lexemo/roberta_large_legal_act_extraction')
9tokenizer = RobertaTokenizerFast.from_pretrained("roberta-large")
10pypeline = TokenClassificationPipeline(model=legal_act_extraction_model,
11 tokenizer=tokenizer,
12 aggregation_strategy='simple')
131# Inference
2import pandas as pd
3from tabulate import tabulate
4
5text = """When Member States adopt those measures, they shall contain a
6reference to this Directive or be accompanied by such reference on the
7occasion of their official publication. They shall also include a statement
8that references in existing laws, regulations and administrative provisions
9to Article 9 of Directive 97/23/EC shall be construed as references to
10Article 13 of this Directive. Member States shall determine how such
11reference is to be made and how that statement is to be formulated."""
12
13entities = pypeline(text)
14df = pd.DataFrame(entities)
15print(tabulate(df, showindex=True, headers=df.columns))# Output
entity_group score word start end
-- ------------------------------ -------- ------------------ ------- -----
0 current_act 0.999999 Directive 80 89
1 article_relevant_following_act 0.999995 9 296 297
2 another_act 0.999999 Directive 97/23/EC 301 319
3 article_relevant_following_act 0.999996 13 364 366
4 current_act 0.999999 Directive 375 384