Skip to content

Commit

Permalink
Merge pull request #760 from clulab/kwalcock/compileThompson
Browse files Browse the repository at this point in the history
Make it compile
  • Loading branch information
navalani authored Oct 4, 2023
2 parents ef57e46 + 6b1e489 commit deae650
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions main/src/main/scala/org/clulab/odin/impl/ThompsonVM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.clulab.processors.Document
import org.clulab.struct.Interval
import org.clulab.odin._

import scala.::
//import scala.::



Expand Down Expand Up @@ -39,22 +39,22 @@ object ThompsonVM {
def results: Seq[(NamedGroups, NamedMentions)]
}

private case class SingleThread(
case class SingleThread(
tok: Int,
inst: Inst,
dir: Direction,
groups: NamedGroups,
mentions: NamedMentions,
partialGroups: PartialGroups,
partialMatches: PartialMatches
var partialMatches: PartialMatches
) extends Thread {
def isDone: Boolean = inst == Done
def isReallyDone: Boolean = isDone
def results: Seq[(NamedGroups, NamedMentions)] = Seq((groups, mentions))
}


private case class ThreadBundle(bundles: Seq[Seq[Thread]]) extends Thread {
case class ThreadBundle(bundles: Seq[Seq[Thread]]) extends Thread {
// at least one thread is done and the threads after the threadbundle can be dropped
def isDone: Boolean = bundles.exists(_.exists(_.isDone))
// all bundles are done and we can retrieve the results
Expand Down Expand Up @@ -101,7 +101,7 @@ object ThompsonVM {
loop((i.next, gs + (name -> updatedGroups), ms, partials) :: rest, ts)
case _ => sys.error("unable to close capture")
}
case i => loop(rest, SingleThread(tok, i, dir, gs, ms, pgs) :: ts)
case i => loop(rest, SingleThread(tok, i, dir, gs, ms, pgs, List.empty[PartialMatch]) :: ts)
}
}
// return threads produced by `inst`
Expand Down Expand Up @@ -305,11 +305,11 @@ case class SaveStart(name: String) extends Inst {
def dup() = copy()
override def hashCode: Int = (name, super.hashCode).##

override def execute(thread: SingleThread): Unit = {
// Create a PartialMatch object and add it to the PartialMatches list
val partialMatch = PartialMatch(thread.sent, thread.tok, thread.tok, name)
thread.partialMatches = partialMatch :: thread.partialMatches
}
def execute(thread: ThompsonVM.SingleThread): Unit = {
// Create a PartialMatch object and add it to the PartialMatches list
val partialMatch = ThompsonVM.PartialMatch(thread.partialMatches.head.sentenceId, thread.tok, thread.tok, name)
thread.partialMatches = partialMatch :: thread.partialMatches
}


override def equals(other: Any): Boolean = {
Expand Down

0 comments on commit deae650

Please sign in to comment.