Description
The dataset consists of 12 documents taken from EUR-Lex, a multilingual corpus of court decisions and legal dispositions in the 24 official languages of the European Union.
This model extracts ADDRESS, AMOUNT, DATE, ORGANISATION, and PERSON entities from Finnish documents.
Predicted Entities
ADDRESS, AMOUNT, DATE, ORGANISATION, PERSON
How to use
document_assembler = nlp.DocumentAssembler()\
.setInputCol("text")\
.setOutputCol("document")
sentence_detector = nlp.SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")\
.setInputCols(["document"])\
.setOutputCol("sentence")
tokenizer = nlp.Tokenizer()\
.setInputCols(["sentence"])\
.setOutputCol("token")
embeddings = nlp.RoBertaEmbeddings.pretrained("roberta_base_finnish_legal","fi")\
.setInputCols(["sentence", "token"])\
.setOutputCol("embeddings")\
.setMaxSentenceLength(512)\
.setCaseSensitive(True)
ner_model = legal.NerModel.pretrained("legner_mapa", "fi", "legal/models")\
.setInputCols(["sentence", "token", "embeddings"])\
.setOutputCol("ner")
ner_converter = nlp.NerConverter()\
.setInputCols(["sentence", "token", "ner"])\
.setOutputCol("ner_chunk")
nlpPipeline = nlp.Pipeline(stages=[
document_assembler,
sentence_detector,
tokenizer,
embeddings,
ner_model,
ner_converter])
empty_data = spark.createDataFrame([[""]]).toDF("text")
model = nlpPipeline.fit(empty_data)
text = ["""Liberato vaati 22.5.2007 päivätyllä kanteellaan Tribunale di Teramossa ( Teramon alioikeus, Italia ) asumuseroa Grigorescusta ja lapsen huoltajuutta."""]
result = model.transform(spark.createDataFrame([text]).toDF("text"))
Results
+-------------+---------+
|chunk |ner_label|
+-------------+---------+
|Liberato |PERSON |
|22.5.2007 |DATE |
|Italia |ADDRESS |
|Grigorescusta|PERSON |
+-------------+---------+
Model Information
| Model Name: | legner_mapa |
| Compatibility: | Legal NLP 1.0.0+ |
| License: | Licensed |
| Edition: | Official |
| Input Labels: | [sentence, token, embeddings] |
| Output Labels: | [ner] |
| Language: | fi |
| Size: | 1.4 MB |
References
The dataset is available here.
Benchmarking
label precision recall f1-score support
ADDRESS 0.81 0.93 0.86 27
AMOUNT 1.00 1.00 1.00 2
DATE 0.92 0.95 0.94 61
ORGANISATION 0.88 0.81 0.85 27
PERSON 0.93 0.95 0.94 40
micro-avg 0.90 0.92 0.91 157
macro-avg 0.91 0.93 0.92 157
weighted-avg 0.90 0.92 0.91 157