File size: 1,031 Bytes
59da9af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pathlib import Path
from typing import Annotated

import typer

from .alignment import to_character_indices_series
from .data import read_aste_file
from .sentiment import to_nice_sentiment

app = typer.Typer()


@app.command()
def aste(
    aste_file: Annotated[Path, typer.Option()],
    output_file: Annotated[Path, typer.Option()],
) -> None:
    df = read_aste_file(aste_file)
    df = df.explode("triples")
    df = df.reset_index(drop=False)
    df = df.merge(
        df.apply(to_character_indices_series, axis="columns"),
        left_index=True,
        right_index=True,
    )
    df["sentiment"] = df.triples.apply(lambda triple: to_nice_sentiment(triple[2]))
    df = df.drop(columns=["triples"])

    print(df.sample(3))

    df.to_parquet(output_file, compression="gzip")


@app.command()
def sem_eval(
    aste_file: Annotated[Path, typer.Option()],
    sem_eval_file: Annotated[Path, typer.Option()],
    output_file: Annotated[Path, typer.Option()],
) -> None:
    pass


if __name__ == "__main__":
    app()