Skip to content

Utils

ie_eval.metrics.utils

Utils.

Classes

Functions

compute_all_metrics

compute_all_metrics(
    label_dir: Path,
    prediction_dir: Path,
    nerval_threshold: float = 30.0,
    by_category: bool = False,
) -> PrettyTable

Compute all metrics.

Parameters:

Name Type Description Default
label_dir Path

Path to the label directory.

required
prediction_dir Path

Path to the prediction directory.

required
by_category bool

Whether to compute the metric globally or for each category. Defaults to False.

False

Returns:

Name Type Description
PrettyTable PrettyTable

Summary table.

Source code in ie_eval/metrics/utils.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def compute_all_metrics(
    label_dir: Path,
    prediction_dir: Path,
    nerval_threshold: float = 30.0,
    by_category: bool = False,
) -> PrettyTable:
    """Compute all metrics.

    Args:
        label_dir (Path): Path to the label directory.
        prediction_dir (Path): Path to the prediction directory.
        by_category (bool, optional): Whether to compute the metric globally or for each category. Defaults to False.

    Returns:
        PrettyTable: Summary table.
    """
    dataset = load_dataset(label_dir=label_dir, prediction_dir=prediction_dir)
    bow_table = compute_bag_of_anything(
        dataset,
        by_category,
        WordType.word,
        print_table=False,
    )
    botw_table = compute_bag_of_anything(
        dataset,
        by_category,
        WordType.tagged_word,
        print_table=False,
    )
    boe_table = compute_bag_of_anything(
        dataset,
        by_category,
        WordType.entity,
        print_table=False,
    )
    ecer_ewer_table = compute_oiecerewer(
        label_dir,
        prediction_dir,
        by_category,
        print_table=False,
    )
    nerval_table = compute_oinerval(
        label_dir,
        prediction_dir,
        nerval_threshold,
        by_category,
        print_table=False,
    )

    table = make_summary_table(
        bow_table=bow_table,
        botw_table=botw_table,
        boe_table=boe_table,
        ecer_ewer_table=ecer_ewer_table,
        nerval_table=nerval_table,
    )
    print(table)  # noqa: T201
    return table