1 # This Python file uses the following encoding: utf-8
3 Created on May 18, 2011
9 from mjacob
.nltk
.parse
.tag
.earley
.TagEdge
import TagEdge
10 from operator
import lt
, eq
12 """the symbol for an index whose value doesn't matter is ~"""
15 class PVTagEdge(TagEdge
):
16 def __init__(self
, production
, treeposition
, treestart
, span
, gapspan
, dotposition
, has_adjoined
):
17 TagEdge
.__init
__(self
, production
, treeposition
, span
, gapspan
, dotposition
, has_adjoined
)
18 self
.__treestart
= treestart
21 """the start position of the elementary tree that has triggered the creation of this edge"""
22 return self
.__treestart
25 if self
.__treestart
== CARENT
:
27 return self
.start() - self
.__treestart
30 return '[%s:%s:%s:%s:%s] %r %s[%s] %s %s' % (self
.__treestart
,
32 self
.gapstart() is None and "-" or self
.gapstart(),
33 self
.gapend() is None and "-" or self
.gapend(),
42 return '[Edge: %s]' % (self
)
44 def __lt__(self
, othr
):
45 return lt((self
.__treestart
, self
.start(), self
.gapstart(), self
.gapend(), self
.end(), self
.production(), self
.treeposition(), self
.dotposition(), self
.has_adjoined()),
46 (othr
.__treestart
, othr
.start(), othr
.gapstart(), othr
.gapend(), othr
.end(), othr
.production(), othr
.treeposition(), othr
.dotposition(), othr
.has_adjoined()))
48 def __eq__(self
, othr
):
49 return eq((self
.__treestart
, self
.start(), self
.gapstart(), self
.gapend(), self
.end(), self
.production(), self
.treeposition(), self
.dotposition(), self
.has_adjoined()),
50 (othr
.__treestart
, othr
.start(), othr
.gapstart(), othr
.gapend(), othr
.end(), othr
.production(), othr
.treeposition(), othr
.dotposition(), othr
.has_adjoined()))
53 return hash((self
.__treestart
, self
.production(), self
.treeposition(), self
.span(), self
.gap(), self
.dotposition(), self
.has_adjoined()))