
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.Edge
public class Edge
An edge in a chart
produced by an
Earley parser
. Edges consist of a
dotted rule
paired with an
origin position
within a string.
An edge is either active or
passive
depending on
how far
processing has succeeded in the
dotted rule. When an edge is passive, parsing has successfully completed the
left side category
at the edge's origin
position within the string being parsed.
Edges can be created by prediction
based
on a grammar rule
, or by
scanning
an input token that matches the
active category
of some edge's dotted rule.
An edge can also be completed
based on another
edge, allowing parse trees
to trace the derivation of a
string based on a Grammar
.
Upon creation
, a completed edge advances
the position
of the edge's
dotted rule
by 1
,
but maintains the same origin position as the edge. It also maintains
backpointers
to the edges that were used in completing
the new edge.
Edges are immutable and can not be altered once they are created. In an Earley parser, edges are only ever added, never removed or changed.
Chart
,
DottedRule
Constructor Summary  

Edge(DottedRule dottedRule,
int origin)
Creates an edge containing the specified dotted rule at the origin position given. 

Edge(DottedRule dottedRule,
int origin,
Set<Edge> bases)
Creates an edge for the specified dotted rule and origin position, with the given set of edges as bases for its completion. 
Method Summary  

static Edge 
complete(Edge toComplete,
Edge basis)
Completes the specified edge based on the specified basis. 
boolean 
equals(Object obj)
Tests whether this edge is equal to another edge by comparing their dotted rules, origin positions, and basis edges . 
Set<Edge> 
getBases()
Gets the bases for completion of this edge, in order of insertion. 
DottedRule 
getDottedRule()
Gets this edge's dotted rule. 
int 
getOrigin()
Gets this edge's origin position. 
int 
hashCode()
Computes a hash code for this edge based on its dotted rule, origin position, and bases. 
boolean 
isPassive()
Tests whether this is a passive edge or not. 
static Edge 
predictFor(Rule rule,
int origin)
Makes a predicted edge based on the specified rule, with the specified origin position. 
static Edge 
scan(Edge edge,
String token)
Creates an edge based on the given edge and the token that was just scanned. 
String 
toString()
Gets a string representation of this edge. 
Methods inherited from class java.lang.Object 

clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
Constructor Detail 

public Edge(DottedRule dottedRule, int origin)
dottedRule
 The dotted rule at origin
.origin
 The origin position within the string being parsed.
IndexOutOfBoundsException
 If origin < 0
.Edge(DottedRule, int, Set)
public Edge(DottedRule dottedRule, int origin, Set<Edge> bases)
bases
 The set of bases, in order, that completed this edge. If
this is null
, the empty set
is used.
IndexOutOfBoundsException
 If origin < 0
.Method Detail 

public static Edge complete(Edge toComplete, Edge basis)
toComplete
 The edge to complete.basis
 The basis on which this edge is being completed. This edge
will be added to the set of bases
already in the
edge, if any are present.
dotted rule
's position is advanced by
1
and its bases contains basis
.
NullPointerException
 if toComplete
or
basis
is null
.
IllegalArgumentException
 If the specified basis is not a
suitable edge for completing this edge. Reasons for this exception are
that the basis edge:
dotted rule
whose
position
is 0
(meaning that no completion has actually taken place)left
category does not equal this edge's dotted rule's
active category
.DottedRule.advanceDot(DottedRule)
public boolean equals(Object obj)
basis edges
.
equals
in class Object
true
iff the given object is an instance of
Edge
and its dotted rule, origin, and bases are equal to
this edge's dotted rule, origin, and bases.DottedRule.equals(Object)
public Set<Edge> getBases()
empty set
is returned.complete(Edge, Edge)
public DottedRule getDottedRule()
public int getOrigin()
public int hashCode()
hashCode
in class Object
DottedRule.hashCode()
public boolean isPassive()
active category
.
true
iff the active category of this edge's dotted
rule is null
.public static Edge predictFor(Rule rule, int origin)
rule
 The rule to construct a predicted edge for.origin
 The origin position of the newly predicted edge.
dotted rule
is the
specified rule at position 0
. The new edge's origin is the
specified origin
.
NullPointerException
 If rule
is null
.public static Edge scan(Edge edge, String token)
edge
 The edge whose active category is the justscanned token.token
 The justscanned token.
origin
), but with its rule's
dot position
advanced by one. The new
edge's bases
incorporates the old edge and all of
its bases.
NullPointerException
 If edge
or token
is null
.
IllegalArgumentException
 In any of the following cases:
edge
is
passive
.edge
's
dotted rule
's
active category
is not a
terminal
.edge
's rule's active category's
name
is not equal to the scanned
token
.public String toString()
toString
in class Object
0
and dotted rule S > NP * VP
.DottedRule.toString()

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 FrontCover Texts, and no BackCover Texts. A copy of the license is included in the overview file.