Giter Site home page Giter Site logo

littlepea13 / leamr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ablodge/leamr

0.0 1.0 0.0 9.88 MB

A structurally comprehensive dataset of AMR-to-text alignments for coverage of a larger variety of linguistic phenomena, for research related to AMR parsing, generation, and evaluation.

Python 100.00%

leamr's Introduction

LEAMR

LEAMR (Linguistically Enriched AMR, pronounced lemur) Alignments is a data release of alignments between AMR and English text for better parsing and probing of many different linguistic phenomena. We also include our code for the LEAMR aligner. For more details, read our paper.

Austin Blodgett and Nathan Schneider. 2021. Probabilistic, Structure-Aware Algorithms for Improved Variety, Accuracy, and Coverage of AMR Alignments. In Proceedings of the 59th Annual Meeting ofthe Association for Computational Linguistics.

For other useful resouces for AMR research, also take a look at AMR-utils and the AMR Bibliography.

Install

pip install -r requirements.txt
git clone https://github.com//ablodge/amr-utils
pip install ./amr-utils

Data

We release alignment data for AMR Release 3.0 and Little Prince comprising ~60,000 sentences, as well as 350 sentences with gold alignments in leamr_test.txt and leamr_dev.txt.

We release 4 layers of alignments: subgraph, duplicate subgraph, relation, and reentrancy alignments.

For AMR Release 3.0 and Little Prince, as well as our gold test and dev data we release:

  • <corpus>.subgraph_alignments.json: Each subgraph alignment maps a DAG-shaped subgraph to a single span. We also include duplicate subgraph alignments in this layer with the alignment type "dupl-subgraph". Some AMRs involve a "duplicate" of some part of the graph to represent ellipsis and other phenomena where some part of the meaning is unpronounced. Duplicate subgraph alignments are used to represent these cases.
  • <corpus>.relation_alignments.json: Each relation alignment maps a span to a collection of external edges, where each edge is between two subgraphs aligned in the previous layer. These alignments include argument structures (gave => :ARG0, :ARG1, :ARG2) and single relation alignments (when => :time).
  • <corpus>.reentrancy_alignments.json: Each reentrancy alignment maps a reentrant edge to the span which "triggers" that reentrancy, and is classified with a reentrancy type to account for phenomona like coreference, control, and coordination.

We also release <corpus>.spans.json which species the spans for each sentence, grouping together tokens which are named entities or multiword expressions.

JSON Format

Alignments are released as JSON files.

To read alignments from a JSON file do:

reader = AMR_Reader()
alignments = reader.load_alignments_from_json(alignments_file)

Get Alignments

Anonymized alignments are stored in the folder data-release/alignments. To interpret them, you will need the associated AMR data.

Get AMR Data

You will first need to obtain AMR Release 3.0 from LDC: https://catalog.ldc.upenn.edu/LDC2020T02. Afterwards you can run the following code to unpack the remainder of the data. Make sure to specify <LDC parent dir> as the parent directory of your AMR Release 3.0 data.

wget https://amr.isi.edu/download/amr-bank-struct-v1.6.txt -O data-release/amrs/little_prince.txt
python build_data.py <LDC parent dir>
python unanonymize_alignments.py

Run Pre-trained Aligner

For a file of unaligned AMRs for English <unaligned amr file>, you can create alignments by running the following code. The script nlp_data.py does necessary preprocessing and may take several hours to run on a large dataset.

python nlp_data.py <unaligned amr file>

python align_with_pretrained_model.py -t <unaligned amr file> --subgraph-model ldc+little_prince.subgraph_aligner.params --relation-model ldc+little_prince.relation_aligner.params --reentrancy-model ldc+little_prince.reentrancy_aligner.params 

Train Aligner

You can set <train file> to 'data-release/amrs/ldc+little_prince' or some other AMR file name. The script nlp_data.py does necessary preprocessing and may take several hours to run on a large dataset.

python nlp_data.py <train file>.txt

python train_subgraph_aligner.py -T <train file>.txt --save-model <model name>.subgraph_aligner.params
python train_relation_aligner.py -T <train file>.txt --save-model <model name>.relation_aligner.params
python train_reentrancy_aligner.py -T <train file>.txt --save-model <model name>.reentrancy_aligner.params

Bibtex

@inproceedings{blodgett2021,
    title = "Probabilistic, Structure-Aware Algorithms for Improved Variety, Accuracy, and Coverage of {AMR} Alignments",
    author = "Blodgett, Austin and
      Schneider, Nathan",
    booktitle = "Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics",
    month = aug,
    year = 2021
}

leamr's People

Contributors

ablodge avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.