Skip to main content

AnCast++ metric for evaluating UMR semantic graphs

Project description

Ancast

AnCast metric for evaluating UMR semantic graphs.

Install

ancast is currently available as a local, editable install only

$ pip install -e .

Usage

Consider sample AMR/UMR files in samples dir

CLI command

Currently, output file path is required and will contain analysis csv file.

$ ancast --help
usage: ancast++ Argparser [-h] -p PRED [PRED ...] [-pe PRED_EXT [PRED_EXT ...]] -g GOLD [GOLD ...] [-ge GOLD_EXT [GOLD_EXT ...]] [-o OUTPUT] [-s {snt,doc}] [-df {amr,umr}] [-c CNEIGHBOR] [-sc SENSE_COEFFICIENT] [--separate-1-and-2 [SEPARATE_1_AND_2]]
                          [--allow-reify [ALLOW_REIFY]] [--use-alignment [USE_ALIGNMENT]] [--use-smatch-top [USE_SMATCH_TOP]] [--weighted {snts,toks}] [--seed SEED] [--debug]

options:
  -h, --help            show this help message and exit
  -p PRED [PRED ...], --pred PRED [PRED ...]
                        (required) path to prediction file or dir (if dir, same filenames must exist in `gold`)
  -pe PRED_EXT [PRED_EXT ...], --pred-ext PRED_EXT [PRED_EXT ...]
                        if `args.pred` flag is a dir, which file extensions to consider
  -g GOLD [GOLD ...], --gold GOLD [GOLD ...]
                        (required) path to gold file or dir (if dir, same filenames must exist in `pred`)
  -ge GOLD_EXT [GOLD_EXT ...], --gold-ext GOLD_EXT [GOLD_EXT ...]
                        if `args.gold` flag is a dir, which file extensions to consider
  -o OUTPUT, --output OUTPUT
                        (optional) path to output analysis files(if new dir, should not contain comma in the base dirname)
  -s {snt,doc}, --scope {snt,doc}
                        whether to run ancast over AMR/UMR sentence-level graphs (`snt`) or to run ancast++ over UMR document-level graphs (`doc`)
  -df {amr,umr}, --data-format {amr,umr}
                        whether the input data are AMR(s) or UMR(s) (automatically set to `umr` if `--scope` is `doc`)
  -c CNEIGHBOR, --cneighbor CNEIGHBOR
                        coefficient for the importance of neighborhood information when broadcasting
  -sc SENSE_COEFFICIENT, --sense-coefficient SENSE_COEFFICIENT
                        importance of sense ID when comparing two concepts
  --separate-1-and-2 [SEPARATE_1_AND_2]
                        whether to combine one-hop and two-hop neighbors together
  --allow-reify [ALLOW_REIFY]
                        whether to apply reification before comparing graphs
  --use-alignment [USE_ALIGNMENT]
                        whether to use alignment information when establishing anchors
  --use-smatch-top [USE_SMATCH_TOP]
                        whether to add (TOP :root `ROOT_NODE`) edge
  --weighted {snts,toks}
                        whether to apply weighted average for ancast++ doc-level evaluation by (1) number of sentences or (2) number of tokens
  --seed SEED           random seed for reproducibility
  --debug               debug logging mode

Python API with Files

evaluate accepts the same set of arguments described above.

from ancast import evaluate

pred_fpath = "./samples/umr_test.txt"
gold_fpath = "./samples/umr_gold.txt"
out_fpath = "./samples/outputs"

out = evaluate(
    pred_fpath,
    gold_fpath, 
    out_fpath, 
    scope="doc"
)

Python API with Strings

You can pass AMR/UMR files as strings and acquire fscores and detailed comparison directly through evaluate

from ancast import evaluate

pred_strings = open("./samples/umr_test.txt", "r").read() # alternatively you can directly pass generated umrs/amrs packed in standard format
gold_strings = open("./samples/umr_gold.txt", "r").read()
# out_fpath = "./samples/outputs"

out = evaluate(
    pred_strings,
    gold_strings, 
    # out_fpath, 
    scope="doc",
    output_csv_as_string=True
)

Cite

Please cite this paper for now:

@inproceedings{sun2024ancast,
    title = "Anchor and Broadcast: An Efficient Concept Alignment Approach for Evaluation of Semantic Graphs",
    author = "Sun, Haibo and Nianwen Xue ",
    booktitle = "Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation",
    month = may,
    year = "2024",
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ancast-0.1.1.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ancast-0.1.1-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file ancast-0.1.1.tar.gz.

File metadata

  • Download URL: ancast-0.1.1.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ancast-0.1.1.tar.gz
Algorithm Hash digest
SHA256 722f74000cd105cb09d3d873d9600cdd02bade2f5005c4d06b6a556edfb1d2e3
MD5 a8a9bebfa08e147caa1f4615f32633da
BLAKE2b-256 a461cf02247826e2f20524a6d618161a1300643a9b483dcc44ccc560af824c51

See more details on using hashes here.

Provenance

The following attestation bundles were made for ancast-0.1.1.tar.gz:

Publisher: python-publish.yml on umr4nlp/ancast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ancast-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ancast-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ancast-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27b6d931fdc6ef95049e96c4250d1ab8271be092757f7522ba545980f9ecb398
MD5 d51b11c4cd05b75854506729305ceca4
BLAKE2b-256 dc43bc48026897a1a50a5b9dc12100d3ec0cf0fe070ac9b0ab825e65df89c8cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for ancast-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on umr4nlp/ancast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page