Skip to main content

Implementation of the Feng-Hirst RST Discourse Parser

Project description

Installation

pip install feng-hirst-rst-parser

README.md and README_original.md

This project is a fork of an update of the original Feng-Hirst RST parser repo. The original README.md is included as README_original.md. It is recommended to install this project as a Python package and use it that way. This should simplifiy usage significantly and make it more accessible. This README.md will focus on the current version and does not include instructions for how to run the original version.

General Information

  • This RST-style discourse parser produces discourse tree structure on full-text level, given a raw text. No prior sentence splitting or any sort of preprocessing is expected. The program runs on Linux systems.
  • The overall software work flow is similar to the one described in the paper by Feng and Hirst (ACL 2014). They removed the post-editing component from the workflow, as well as the set of entity-based transaction features from our feature set. Moreover, both structure and relation classification models are implemented using CRFSuite.

Usage

Example

See example.py for a very simple example. Note that this requires both matplotlib and pydot to run. The plotting functionality is not required to use the parser, hence these packages are not listed as requirements, and you will have to install them yourself.

More detailed usage

First instantiate the parser:

parser = DiscourseParser(
        verbose,
        skip_parsing,
        global_features,
        save_preprocessed,
        output_dir=output_dir
    )

Then parse your file to get a ParseTree:

pt = parser.parse(os.path.join(current_file_dir, 'example.txt'))

You can convert this ParseTree to a networkx graph:

G = pt.to_networkx()

Which should make it much easier to work with or to analyze the tree structure.

Additionally metrics can be extracted:

metrics = extract_metrics(G, relation_ngrams=[(1, 2), (3, 4)])

At the moment this gives you the depth of the tree, counts how often each relation occurs, and relation_ngrams can tell you how often each 'ngram' is found in the paths from the root node to all the leaf nodes.

Command-line usage and more

Refer to README_original.md for more information.

Bugs and comments

If you encounter and bugs using the program, please create an Issue on the GitHub repo.

Developers

  • Original author: Vanessa Wei Feng, Department of Computer Science, University of Toronto, Canada
  • Arne Neumann updated it to use nltk 3.4 on this github repo, and created a Dockerfile.
  • Zining Zhu updated the scripts to use Python 3.
  • Thomas Huber, Chair of Data Science and Natural Language Processing, University of St. Gallen, updated the scripts further and added the networkx functionality.

References

  • Vanessa Wei Feng and Graeme Hirst, 2014. Two-pass Discourse Segmentation with Pairing and Global Features. arXiv: 1407.8215v1. http://arxiv.org/abs/1407.8215
  • Vanessa Wei Feng and Graeme Hirst, 2014. A Linear-Time Bottom-Up Discourse Parser with Constraints and Post-Editing. In Proceedings of the 52th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies (ACL-2014), Baltimore, USA. http://aclweb.org/anthology/P14-1048

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

feng_hirst_rst_parser-0.1.4.tar.gz (53.3 MB view details)

Uploaded Source

Built Distribution

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

feng_hirst_rst_parser-0.1.4-py3-none-any.whl (53.8 MB view details)

Uploaded Python 3

File details

Details for the file feng_hirst_rst_parser-0.1.4.tar.gz.

File metadata

  • Download URL: feng_hirst_rst_parser-0.1.4.tar.gz
  • Upload date:
  • Size: 53.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.11

File hashes

Hashes for feng_hirst_rst_parser-0.1.4.tar.gz
Algorithm Hash digest
SHA256 94f82ec9df3410db63f6b0db326e00b4399bfaecf6ef6a8486a68ad7f08980e1
MD5 8489c6d1dce6e1a8334f17a2d5d6bf8f
BLAKE2b-256 0dea5bcad6cefe95344576113ebeae942ebd988bd86244a726669031a424912c

See more details on using hashes here.

File details

Details for the file feng_hirst_rst_parser-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for feng_hirst_rst_parser-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 510b94244dc72310c35557331fc30e8e70a0472663ea32e3657ead8adc892af7
MD5 588eadeecd8812e503f26a77f70e361d
BLAKE2b-256 c35c0d2f6dd6f39f0574c1a620090acf03a08a6443306107b67cfb7d0e362200

See more details on using hashes here.

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