Skip to content

Commit

Permalink
Added sentence to chart as a field
Browse files Browse the repository at this point in the history
  • Loading branch information
David Brooks committed Sep 21, 2014
1 parent 36706bf commit 1c6ff06
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "scharpa"

version := "0.3"
version := "0.4"

scalaVersion := "2.11.2"

Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/junglebarry/scharpa.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ package object scharpa {
} else None
}

case class Chart(arcs: Set[Arc]) {
case class Chart(arcs: Set[Arc], sentence: Seq[String]) {
def nextChart(arc: Arc): (Chart, Seq[Arc]) = {
if (arcs(arc)) {
(this, Seq.empty[Arc])
Expand All @@ -143,7 +143,7 @@ package object scharpa {
arcs.filter(_.active).flatMap(_.applyFundamental(arc))
}
// return chart with new arc added; also, new arcs to be added to next agenda
(Chart(arcs + arc), fundamentals.toSeq)
(Chart(arcs + arc, sentence), fundamentals.toSeq)
}
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ package object scharpa {
val agenda = sentence.zipWithIndex.map {
case (word, index) => WordArc(index, index + 1, word)
}
ParserState(agenda, Chart(Set.empty[Arc]))
ParserState(agenda, Chart(Set.empty[Arc], sentence))
}

/**
Expand All @@ -231,7 +231,7 @@ package object scharpa {
}.toSet
// top-down starting rule added to agenda
val agenda = Seq(RuleArc(0, 0, RuleApplication(grammar.top)))
ParserState(agenda, Chart(chartWordArcs))
ParserState(agenda, Chart(chartWordArcs, sentence))
}

/**
Expand Down

0 comments on commit 1c6ff06

Please sign in to comment.