File size: 1,531 Bytes
28bcf8a
b8425f0
20103bc
28bcf8a
38ec31b
6ddcc01
28bcf8a
 
 
380ec2b
28bcf8a
b8425f0
 
 
28bcf8a
380ec2b
 
 
 
 
 
20103bc
380ec2b
 
20103bc
380ec2b
 
20103bc
380ec2b
20103bc
 
380ec2b
 
 
 
 
20103bc
380ec2b
 
 
 
 
 
 
28bcf8a
 
b8425f0
 
31b29e2
20103bc
 
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
import streamlit as st
from utils import generate_titles
import logging

st.header("Exemple de titrage automatique")
st.image("assets/cour-de-cassation.png")

url_input = st.text_input(
    label="Entrez l'URL d'une décision sur le site de la cour de cassation",
    placeholder="https://www.courdecassation.fr/decision",
)
n_titles = st.number_input(
    label="Choisissez un nombre de titres", min_value=1, max_value=10, value=3
)


def check_url_input(url):
    url_splits = url.split("/")

    # checking the URL
    if len(url_splits) != 5:
        logging.debug("URL is not long enough")
        return False
    if url_splits[0] != "https:":
        logging.debug("URL does not contain 'https:'")
        return False
    if url_splits[2] not in ["www.courdecassation.fr", "courdecassation.fr"]:
        logging.debug("URL does not refer to 'courdecassation.fr'")
        return False
    if url_splits[3] != "decision":
        logging.debug("URL does not contain 'decision'")
        return False

    # checking the judilibre id
    try:
        int(url_splits[4], base=16)
        logging.debug("Decision ID is not the right format")
    except ValueError:
        return False

    return True


if check_url_input(url_input):
    judilibre_id = url_input.split("/")[-1]

    st.text(f"Voici {n_titles} titres pour la décision {url_input}")
    for i, title in enumerate(generate_titles(decision="", n_titles=int(n_titles))):
        st.text(f"({i+1:02}) {title}")
else:
    st.warning("L'URL n'est pas conforme...")