mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[daemon] LLM-17397 Fix IOU calculation to include end points
GitOrigin-RevId: 3bcf069a7d484ea9a58e54b53f859932c185be75
This commit is contained in:
committed by
intellij-monorepo-bot
parent
aede207fda
commit
a62242e94f
@@ -108,6 +108,11 @@ data class FileUpdate(
|
||||
|
||||
fun sanitizeText(text: String): String = text.replace("\r\n", "\n")
|
||||
|
||||
|
||||
/**
|
||||
* 0-based line numbers.
|
||||
* [start] and [end] are inclusive.
|
||||
*/
|
||||
interface Range {
|
||||
val start: Int
|
||||
val end: Int
|
||||
|
||||
@@ -13,7 +13,8 @@ import com.intellij.cce.evaluation.data.Range
|
||||
fun <T : Range> computeIOU(range1: T, range2: T): Double {
|
||||
// Calculate intersection
|
||||
val intersectionStart = maxOf(range1.start, range2.start)
|
||||
val intersectionEnd = minOf(range1.end, range2.end)
|
||||
// +1 because end is inclusive
|
||||
val intersectionEnd = minOf(range1.end + 1, range2.end + 1)
|
||||
|
||||
// If there's no intersection, return 0
|
||||
if (intersectionEnd < intersectionStart) {
|
||||
@@ -23,8 +24,8 @@ fun <T : Range> computeIOU(range1: T, range2: T): Double {
|
||||
val intersectionArea = intersectionEnd - intersectionStart
|
||||
|
||||
// Calculate union
|
||||
val range1Size = range1.end - range1.start
|
||||
val range2Size = range2.end - range2.start
|
||||
val range1Size = range1.end + 1 - range1.start
|
||||
val range2Size = range2.end + 1 - range2.start
|
||||
val unionArea = range1Size + range2Size - intersectionArea
|
||||
|
||||
// Return IOU
|
||||
|
||||
Reference in New Issue
Block a user