Views
No views yet
1repo_id = "ilsp/justice"
2model_path = hf_hub_download(repo_id=repo_id, filename="20250105-court_decisions_paragraph_classifier.ftz")
3sample_decision = hf_hub_download(repo_id=repo_id, filename="sample_data/Α2485_2023.txt") # anonymized decision
4model = load_model(model_path)
5labels_map = {
6 'preamble': '__label__0', '__label__0': 'preamble',
7 'panel': '__label__1', '__label__1': 'panel',
8 'litigants': '__label__2', '__label__2': 'litigants',
9 'justification': '__label__3', '__label__3': 'justification',
10 'decision': '__label__4', '__label__4': 'decision',
11 'post': '__label__5', '__label__5': 'post'}
12
13with open(sample_decision) as inf:
14 paras = [p for p in inf.read().split(NL) if p.strip()]
15 random.shuffle(paras)
16 text = NL.join(paras)
17
18nchars = 150
19for line in text.split(NL):
20 pred = labels_map[model.predict(line.strip())[0][0]]
21 if len(line) > nchars:
22 line = line[0:nchars]
23 print(f"{line} -> {pred}") 1from flair.data import Sentence, Token
2from flair.models import SequenceTagger
3from huggingface_hub import hf_hub_download
4
5REPO_ID = "ilsp/justice"
6MODEL_PATH = "decisions-ner-model.pt"
7model_path = hf_hub_download(repo_id=REPO_ID, filename=MODEL_PATH)
8model = SequenceTagger.load(model_path)
9
10text = "Για να δικάσει την από 30 Μαρτίου 2020 έφεση των 1) Νίκης Νικίδου του Νίκου , κατοίκου Νίκαιας ( Νεάπολης 1 ) , 2) Άννας Άννίδου του Άνθιμου , κατοίκου Αθήνας ( Αγράμπελης 1 ) και 3) Σοφίας Σοφίδου του Σοφοκλή , κατοίκου Στυλίδας ( Στρυμώνος 1 ) , οι οποίοι παρέστησαν με τον δικηγόρο Λυσία Λυσίου ( Α.Μ. 12341 ) , που τον διόρισαν με πληρεξούσιο ."
11sentence = Sentence([Token(t) for t in text.split()]) # or use a sentence splitter
12model.predict(sentence)
13sentence.get_spans("ner")
14[Span[11:13]: "Νίκης Νικίδου" → PERSON (1.0000),
Span[14:15]: "Νίκου" → PERSON (1.0000),
Span[19:21]: "Νεάπολης 1" → FAC (1.0000),
Span[24:26]: "Άννας Άννίδου" → PERSON (1.0000),
Span[27:28]: "Άνθιμου" → PERSON (1.0000),
Span[32:34]: "Αγράμπελης 1" → FAC (1.0000),
Span[37:39]: "Σοφίας Σοφίδου" → PERSON (1.0000),
Span[40:41]: "Σοφοκλή" → PERSON (1.0000),
Span[45:47]: "Στρυμώνος 1" → FAC (1.0000)]