Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/epic/util/Arrays.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ object Arrays {
val ret = new Array[C](arr1.length * arr2.length)
var off = 0
var i = 0
while(i < arr1.length) {
while (i < arr1.length) {
var j = 0
while(j < arr2.length) {
while (j < arr2.length) {
ret(off) = f(arr1(i), arr2(j))
off += 1
j += 1
Expand All @@ -65,9 +65,9 @@ object Arrays {
val ret = new Array[Int](arr1.length * arr2.length)
var off = 0
var i = 0
while(i < arr1.length) {
while (i < arr1.length) {
var j = 0
while(j < arr2.length) {
while (j < arr2.length) {
ret(off) = arr1(i) + arr2(j) * secondScale
off += 1
j += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package epic.constraints

import epic.util.CacheBroker


/**
* A cached version of [[epic.constraints.LabeledSpanConstraints.Factory]].
* Uses the [[epic.util.CacheBroker]] infrastructure
Expand Down
15 changes: 5 additions & 10 deletions src/main/scala/epic/constraints/ChartConstraints.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,26 @@ import java.io.{DataOutput, DataInput}
case class ChartConstraints[L](top: LabeledSpanConstraints[L],
bot: LabeledSpanConstraints[L]) extends SpanConstraints with Serializable {


def isAllowedSpan(begin: Int, end: Int):Boolean = top.isAllowedSpan(begin, end) || bot.isAllowedSpan(begin, end)
def isAllowedSpan(begin: Int, end: Int): Boolean = top.isAllowedSpan(begin, end) || bot.isAllowedSpan(begin, end)
/** TODO */ // TODO
def hasMaximalLabel(begin: Int, end: Int):Boolean = ???

def hasMaximalLabel(begin: Int, end: Int): Boolean = ???

def maxSpanLengthStartingAt(begin: Int): Int = top.maxSpanLengthStartingAt(begin) max bot.maxSpanLengthStartingAt(begin)

def flatten = top | bot
def &(other: ChartConstraints[L]) = if(this eq other) this else ChartConstraints(top & other.top, bot & other.bot)
def &(other: ChartConstraints[L]) = if (this eq other) this else ChartConstraints(top & other.top, bot & other.bot)
def |(other: ChartConstraints[L]) = ChartConstraints(top | other.top, bot | other.bot)


}

object ChartConstraints {

def noSparsity[L]: ChartConstraints[L] = ChartConstraints[L](LabeledSpanConstraints.noConstraints[L], LabeledSpanConstraints.noConstraints[L])

def apply[L](top: TriangularArray[_ <: BitSet], bot: TriangularArray[_ <: BitSet]): ChartConstraints[L] = ChartConstraints(LabeledSpanConstraints(top), LabeledSpanConstraints(bot))

trait Factory[L, W] extends SpanConstraints.Factory[W] {
def constraints(w: IndexedSeq[W]): ChartConstraints[L]

def |(cf: Factory[L, W]) = new OrFactory(this, cf)
}

Expand Down Expand Up @@ -82,11 +79,9 @@ object ChartConstraints {
case _ =>
bot(t.begin,t.end) = BitSet(labelIndex(t.label))
}

ChartConstraints(LabeledSpanConstraints(top), LabeledSpanConstraints(bot))
}


implicit def serializerChartConstraints[L]:Serializer[ChartConstraints[L]] = new Serializer[ChartConstraints[L]] with Serializable {
def serialize(out: DataOutput, value: ChartConstraints[L]) {
implicitly[Serializer[LabeledSpanConstraints[L]]].serialize(out, value.top)
Expand All @@ -98,6 +93,6 @@ object ChartConstraints {
val bot = implicitly[Serializer[LabeledSpanConstraints[L]]].deserialize(in, available)
ChartConstraints(top, bot)
}

}

}
Loading