Datasets:
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() | |
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") | |
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() | |