|
Pep 0.4 API Documentation | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.osu.ling.pep.Parse
public class Parse
Represents a parse completed by an Earley parser
.
A parse contains the string (list
of
tokens
) parsed, the seed category
and completed chart
. The status
of the
completed parse can also be determined.
Parse trees
can be retrieved
for any Category
in the parse at a given string index and origin
position. Parses allow the fully derived parse trees for the seed category
to be obtained using getParseTrees()
. For a parse of a string
using a grammar that permits structural or lexical ambiguity, the methods
for fetching parse trees will return sets that contain more than one element.
EarleyParser
,
Chart
Method Summary | |
---|---|
boolean |
equals(Object obj)
Tests whether this parse equals another by comparing their tokens, seed categories, and completed charts. |
Chart |
getChart()
Gets the completed chart for this parse. |
ParseTree |
getParseTreeFor(Edge edge)
Gets a parse tree corresponding to the given edge. |
Set<ParseTree> |
getParseTrees()
Gets completed parse trees for the seed category spanning the entire input string. |
Set<ParseTree> |
getParseTreesFor(Category category,
int origin,
int index)
Gets the parse trees derived during this parse with the specified category as their parent 's left side. |
Category |
getSeed()
Gets the seed category for this parse. |
Status |
getStatus()
Gets the status of this parse. |
List<String> |
getTokens()
Gets the tokens parsed. |
int |
hashCode()
Computes a hash code for this parse based on its tokens, seed category, and chart. |
String |
toString()
Gets a string representation of this parse. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public boolean equals(Object obj)
equals
in class Object
true
iff the given object is an instance of
Parse
and its tokens, seed category, and chart are
equal to those of this parse.public Chart getChart()
public ParseTree getParseTreeFor(Edge edge)
edge
- The edge to find a parse tree for.
chart
, returns
null
. The parse tree returned will be the same as
calling
ParseTree.newParseTree(edge);
NullPointerException
- If edge
is null
.ParseTree.newParseTree(Edge)
,
Chart.contains(Edge)
public Set<ParseTree> getParseTrees()
seed
category
spanning the entire string, or the empty
set
if none were derivable. In the case that
the grammar used in this parse permits ambiguity for the string parsed,
this set will contain more than one member. If this parse's
status
is Status.ERROR
, the
empty set
is returned.getParseTreesFor(Category, int, int)
public Set<ParseTree> getParseTreesFor(Category category, int origin, int index)
parent
's left side. This
parse's chart must contain a completed edge at the specified index that
starts at the specified origin with the correct category as its left
side.
For example, the string Mary saw her duck parsed using the
tiny
grammar included in samples will produce a parse that
contains two subtrees for the category VP
at origin
position 1
and index 4
. This is because the
derived VP
categories for saw her duck both start
at 1
and end at 4
. To retrieve these subtrees
from the parse, use
Parse.getParseTreesFor(VP, 1, 4)
where VP
represents an instance of Category
whose
name
is "VP".
category
- The category of the parse tree's
parent
. This is the left side of the
edge's dotted rule.origin
- The origin position of the edge to find parse trees for.index
- The string index position of the edge to find parse trees
for. This is the end position of the subtree.
empty set
if no edges match.
NullPointerException
- If category
is
null
.public Category getSeed()
public Status getStatus()
accepts
a string
when its completed
chart
contains an edge where the following conditions hold:
index
in the
chart,passive
,origin
is the beginning of the string
(position 0
), andleft side
of its
dotted rule
is the same as the
start category that seeded
the parse.
Status.ACCEPT
for accepted strings,
Status.REJECT
for rejected ones. The status Status.ERROR
is returned if an error occurred during the parse.public List<String> getTokens()
public int hashCode()
hashCode
in class Object
List.hashCode()
,
Category.hashCode()
,
Chart.hashCode()
public String toString()
toString
in class Object
ACCEPT: S -> [the, boy, left] (1)
" for an
accepted
parse of "the boy left" with
seed category S
and one possible parse
tree
.
|
Pep: Pep is an Earley parser | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the overview file.