Skip to content

Commit

Permalink
Tagger.tag calls through Tagger.tagAll
Browse files Browse the repository at this point in the history
  • Loading branch information
dhgarrette committed Aug 5, 2012
1 parent 637b9ff commit df4b283
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/scala/opennlp/scalabha/tag/Tagger.scala
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
package opennlp.scalabha.tag package opennlp.scalabha.tag


import opennlp.scalabha.util.CollectionUtils._

/** /**
* Tag sequences of symbols. * Tag sequences of symbols.
* *
Expand All @@ -15,10 +17,8 @@ trait Tagger[Sym, Tag] {
* @return sequences tagged by the model * @return sequences tagged by the model
*/ */
def tag(rawSequences: Seq[IndexedSeq[Sym]]): Seq[IndexedSeq[(Sym, Tag)]] = def tag(rawSequences: Seq[IndexedSeq[Sym]]): Seq[IndexedSeq[(Sym, Tag)]] =
(rawSequences zip rawSequences.map(tagSequence)).map { (rawSequences zip tagAll(rawSequences)).mapt((ws, tagged) =>
case (ws, ts) => ts.map(ws zip _).getOrElse( tagged.getOrElse(throw new RuntimeException("could not tag sentence: '%s'".format(ws.mkString(" ")))))
throw new RuntimeException("could not tag sentence: '%s'".format(ws.mkString(" "))))
}


/** /**
* Tag each sequence using this model. * Tag each sequence using this model.
Expand All @@ -28,7 +28,7 @@ trait Tagger[Sym, Tag] {
*/ */
def tagAll(rawSequences: Seq[IndexedSeq[Sym]]): Seq[Option[IndexedSeq[(Sym, Tag)]]] = def tagAll(rawSequences: Seq[IndexedSeq[Sym]]): Seq[Option[IndexedSeq[(Sym, Tag)]]] =
(rawSequences zip tags(rawSequences)).map { case (ws, ts) => ts.map(ws zip _) } (rawSequences zip tags(rawSequences)).map { case (ws, ts) => ts.map(ws zip _) }

/** /**
* Tag each sequence using this model. * Tag each sequence using this model.
* *
Expand Down

0 comments on commit df4b283

Please sign in to comment.