Skip to content

Commit 59ebad0

Browse files
committed
Formatting
1 parent 07bf13e commit 59ebad0

42 files changed

Lines changed: 108 additions & 225 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

server/src/main/kotlin/org/ivdnt/galahad/annotations/Annotations.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ enum class Annotation(@JsonValue val value: String) {
2020
companion object {
2121
// Used by Spring.
2222
@JsonCreator
23-
fun fromString(s: String): Annotation = entries.firstOrNull { it.value == s.lowercase() } ?: throw InvalidAnnotationException(
23+
fun fromString(s: String): Annotation =
24+
entries.firstOrNull { it.value == s.lowercase() } ?: throw InvalidAnnotationException(
2425
"Invalid annotation type $s, valid types are $entries"
2526
)
2627

server/src/main/kotlin/org/ivdnt/galahad/annotations/LayerSummary.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ data class LayerSummary(
88
) {
99
constructor(terms: Iterable<Term>) : this(
1010
annotations = terms.flatMap { it.annotations.keys }.groupingBy { it }
11-
.eachCount().toSortedMap { a, b -> Annotation.entries.indexOf(a).compareTo(Annotation.entries.indexOf(b)) })
11+
.eachCount().toSortedMap { a, b -> Annotation.entries.indexOf(a).compareTo(Annotation.entries.indexOf(b)) })
1212

1313
companion object {
1414
val EMPTY: LayerSummary = LayerSummary(emptyMap())

server/src/main/kotlin/org/ivdnt/galahad/app/Galahad.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import org.springframework.context.annotation.Configuration
1616
import org.springframework.core.convert.converter.Converter
1717
import org.springframework.scheduling.annotation.EnableScheduling
1818
import java.io.File
19-
import java.math.BigDecimal
2019
import java.util.*
21-
import java.util.regex.Matcher
22-
import java.util.regex.Pattern
2320

2421
var application_profile: String = System.getenv("spring.profiles.active") ?: "prod"
2522

server/src/main/kotlin/org/ivdnt/galahad/evaluation/CorpusEvaluation.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ class CorpusEvaluation(
1616
override fun ctor(key: String): JobEvaluation = ctor(JobPair.fromString(key))
1717
override fun throwNotFound(key: String): Nothing = throw JobNotFoundException(key)
1818

19-
val entities: CorpusEntities get() = object : ValidatedDiskValue<CorpusEntities>(dir.resolve(ENTITIES_FILE)) {
20-
override fun isValid(modified: Long) = modified >= corpus.modified
21-
override fun set(): CorpusEntities = CorpusEntities.create(corpus, this@CorpusEvaluation)
22-
}.readOrCreate()
19+
val entities: CorpusEntities
20+
get() = object : ValidatedDiskValue<CorpusEntities>(dir.resolve(ENTITIES_FILE)) {
21+
override fun isValid(modified: Long) = modified >= corpus.modified
22+
override fun set(): CorpusEntities = CorpusEntities.create(corpus, this@CorpusEvaluation)
23+
}.readOrCreate()
2324

2425
companion object {
2526
private const val ENTITIES_FILE = "entities.json"

server/src/main/kotlin/org/ivdnt/galahad/evaluation/DocumentEvaluation.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ class DocumentEvaluation(
2121
val refLayer: Layer get() = corpus.jobs.readOrThrow(jobs.reference).getLayer(name)
2222
val hypLayer: Layer get() = corpus.jobs.readOrThrow(jobs.hypothesis).getLayer(name)
2323

24-
val entities: DocumentEntities get() = object : ValidatedDiskValue<DocumentEntities>(dir.resolve(ENTITIES_FILE)) {
25-
override fun isValid(modified: Long) = modified >= corpus.documents.readOrThrow(name).modified
26-
override fun set(): DocumentEntities = DocumentEntities.create(refLayer)
27-
}.readOrCreate<DocumentEntities>()
24+
val entities: DocumentEntities
25+
get() = object : ValidatedDiskValue<DocumentEntities>(dir.resolve(ENTITIES_FILE)) {
26+
override fun isValid(modified: Long) = modified >= corpus.documents.readOrThrow(name).modified
27+
override fun set(): DocumentEntities = DocumentEntities.create(refLayer)
28+
}.readOrCreate<DocumentEntities>()
2829

29-
val distribution: DocumentDistribution get() = object : ValidatedDiskValue<DocumentDistribution>(dir.resolve(DISTRIBUTION_FILE)) {
30-
override fun isValid(modified: Long) = modified >= corpus.documents.readOrThrow(name).modified
31-
override fun set(): DocumentDistribution = DocumentDistribution.create(refLayer)
32-
}.readOrCreate<DocumentDistribution>()
30+
val distribution: DocumentDistribution
31+
get() = object : ValidatedDiskValue<DocumentDistribution>(dir.resolve(DISTRIBUTION_FILE)) {
32+
override fun isValid(modified: Long) = modified >= corpus.documents.readOrThrow(name).modified
33+
override fun set(): DocumentDistribution = DocumentDistribution.create(refLayer)
34+
}.readOrCreate<DocumentDistribution>()
3335

3436
companion object {
3537
private const val ENTITIES_FILE = "entities.json"

server/src/main/kotlin/org/ivdnt/galahad/evaluation/DocumentEvaluations.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class DocumentEvaluations(
99
dir: File,
1010
private val corpus: Corpus,
1111
private val jobs: JobPair,
12-
): GalahadFolderManager<DocumentEvaluation, String>(dir) {
12+
) : GalahadFolderManager<DocumentEvaluation, String>(dir) {
1313
override fun ctor(key: String): DocumentEvaluation = DocumentEvaluation(dir.resolve(key), corpus, jobs)
1414
override fun throwNotFound(key: String): Nothing = throw DocumentNotFoundException(key)
1515
}

server/src/main/kotlin/org/ivdnt/galahad/evaluation/JobEvaluation.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package org.ivdnt.galahad.evaluation
22

33
import org.ivdnt.galahad.corpora.Corpus
44
import org.ivdnt.galahad.evaluation.distribution.JobDistribution
5-
//import org.ivdnt.galahad.evaluation.distribution.JobDistribution
65
import org.ivdnt.galahad.evaluation.entities.JobEntities
76
import org.ivdnt.galahad.files.GalahadFolder
87
import org.ivdnt.galahad.files.ValidatedDiskValue
@@ -27,10 +26,11 @@ class JobEvaluation(
2726
override fun set(): JobEntities = JobEntities.create(corpus, documents)
2827
}.readOrCreate()
2928

30-
val distribution: JobDistribution get() = object : ValidatedDiskValue<JobDistribution>(dir.resolve(DISTRIBUTION_FILE)) {
31-
override fun isValid(modified: Long) = modified >= Math.max(refJob.modified, hypJob.modified)
32-
override fun set(): JobDistribution = JobDistribution.create(corpus, documents)
33-
}.readOrCreate()
29+
val distribution: JobDistribution
30+
get() = object : ValidatedDiskValue<JobDistribution>(dir.resolve(DISTRIBUTION_FILE)) {
31+
override fun isValid(modified: Long) = modified >= Math.max(refJob.modified, hypJob.modified)
32+
override fun set(): JobDistribution = JobDistribution.create(corpus, documents)
33+
}.readOrCreate()
3434

3535
companion object {
3636
private const val DISTRIBUTION_FILE = "distribution.json"

server/src/main/kotlin/org/ivdnt/galahad/evaluation/JobPair.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ class JobPair(
77
override fun toString(): String = "$reference/$hypothesis"
88

99
companion object {
10-
fun fromString(pair: String): JobPair = pair.split('/').let {JobPair(it[0], it[1])}
10+
fun fromString(pair: String): JobPair = pair.split('/').let { JobPair(it[0], it[1]) }
1111
}
1212
}

server/src/main/kotlin/org/ivdnt/galahad/evaluation/comparison/LayerComparison.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.ivdnt.galahad.evaluation.comparison
22

3-
import org.ivdnt.galahad.annotations.Annotation
43
import org.ivdnt.galahad.annotations.Layer
54
import org.ivdnt.galahad.annotations.Term
65
import org.ivdnt.galahad.export.DocumentExport

server/src/main/kotlin/org/ivdnt/galahad/evaluation/confusion/Confusion.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ open class Confusion(private val truncate: Boolean = true, val annotation: Annot
7777

7878
fun add(termComp: TermComparison) {
7979
add(
80-
termComp.hypoTerm.takeUnless { it == Term.EMPTY }?.annotationHeadOrMissing(annotation) ?: TermComparison.MISSING_MATCH,
81-
termComp.refTerm.takeUnless { it == Term.EMPTY }?.annotationHeadOrMissing(annotation) ?: TermComparison.MISSING_MATCH,
80+
termComp.hypoTerm.takeUnless { it == Term.EMPTY }?.annotationHeadOrMissing(annotation)
81+
?: TermComparison.MISSING_MATCH,
82+
termComp.refTerm.takeUnless { it == Term.EMPTY }?.annotationHeadOrMissing(annotation)
83+
?: TermComparison.MISSING_MATCH,
8284
termComp
8385
)
8486
}

0 commit comments

Comments
 (0)