Graph Parsing

The GraphParsing submodule provides implementations of graph-based parsing algorithms.

julia> using DependencyTrees.GraphParsing

In graph-based dependency parsing, trees are built all at once, predicting a globally best parse from a set of possible ones. A set of possible parses for a sentence is represented by a square matrix of arc weights: a DependencyGraph.

An appealing feature of graph parsing is that jointly predicting the whole tree structure avoids the parser making a "wrong turn" the way that transition parsers can. The drawback of this is the sacrifice of speed: graph parsing methods are slower than transition parsing methods (𝒪(n^2) for the Chu-Liu/Edmonds algorithm and 𝒪(n^3) for the Eisner algorithm, where n is the number of tokens in a sentence).

The DependencyTrees.GraphParsing module implements the following algorithms:

Dependency Graphs

DependencyTrees.GraphParsing.DependencyGraphMethod
DependencyGraph(tree::DependencyTree)

Create a dependency graph from tree.

Arcs will have a score of 1.0, and non-arcs 0.0.

julia> using DependencyTrees, DependencyTrees.GraphParsing

julia> tree = DependencyTree([(0, "book"), (3, "that"), (1, "flight")])
┌──────── 0 ROOT
└─►┌───── 1 book
   │  ┌─► 2 that
   └─►└── 3 flight

julia> graph = DependencyGraph(tree)
3×3 DependencyGraph{Float64}:
 1.0  0.0  1.0
 0.0  0.0  0.0
 0.0  1.0  0.0
source

Graph Decoding Algorithms

Chu-Liu/Edmonds Algorithm

Eisner's Algorithm

Cycle Detection

Tarjan's Algorithm