File size: 833 Bytes
d708cb9
7bfa7e6
 
d708cb9
7bfa7e6
 
 
0e0d14f
d708cb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7bfa7e6
 
 
 
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
import re


def make_esrs_categorization_node():

    def categorize_message(state):
        query = state["query"]
        pattern = r"ESRS \d+[A-Z0-9]*|ESRS [A-Z]+\d+[A-Z0-9]*"
        esrs_truth = [
            "ESRS 1",
            "ESRS 2",
            "ESRS E1",
            "ESRS E2",
            "ESRS E3",
            "ESRS E4",
            "ESRS E5",
            "ESRS S1",
            "ESRS S2",
            "ESRS S3",
            "ESRS S4",
            "ESRS G1",
        ]

        matches = re.findall(pattern, query.upper())
        if matches:
            true_matches = [match for match in matches if match in esrs_truth]
            output = {"esrs_type": true_matches if true_matches else "wrong_esrs"}
        else:
            output = {"esrs_type": "none"}

        return output

    return categorize_message