Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit 3e64562

Browse files
committed
Merge branch 'hotfix/2.0.1' into release
2 parents ee73449 + a8e53cc commit 3e64562

File tree

9 files changed

+247
-185
lines changed

9 files changed

+247
-185
lines changed

biomedicus-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<artifactId>biomedicus</artifactId>
2323
<groupId>edu.umn.biomedicus</groupId>
24-
<version>2.0.0</version>
24+
<version>2.0.1</version>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>
2727

biomedicus-core/src/main/kotlin/edu/umn/biomedicus/measures/Quantifiers.kt

Lines changed: 70 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package edu.umn.biomedicus.measures
1818

19-
import com.google.inject.Inject
20-
import com.google.inject.Singleton
2119
import edu.umn.biomedicus.annotations.Setting
2220
import edu.umn.biomedicus.common.SequenceDetector
2321
import edu.umn.biomedicus.framework.TagEx
@@ -26,6 +24,7 @@ import edu.umn.biomedicus.sentences.Sentence
2624
import edu.umn.biomedicus.tokenization.ParseToken
2725
import edu.umn.biomedicus.tokenization.Token
2826
import edu.umn.nlpengine.*
27+
import javax.inject.Inject
2928

3029
/**
3130
* A type of indefinite quantifier
@@ -51,23 +50,23 @@ enum class IndefiniteQuantifierType {
5150
*
5251
* @property startIndex the start of cue phrase
5352
* @property endIndex the end of the cue phrase
54-
* @property type
53+
* @property indefiniteQuantifierType
5554
*/
5655
@LabelMetadata(classpath = "biomedicus.v2", distinct = true)
5756
data class IndefiniteQuantifierCue(
58-
override val startIndex: Int,
59-
override val endIndex: Int,
60-
val type: String
57+
override val startIndex: Int,
58+
override val endIndex: Int,
59+
val indefiniteQuantifierType: String
6160
) : Label() {
6261
constructor(
63-
textRange: TextRange,
64-
type: String
62+
textRange: TextRange,
63+
type: String
6564
) : this(textRange.startIndex, textRange.endIndex, type)
6665

6766
constructor(
68-
startIndex: Int,
69-
endIndex: Int,
70-
indefiniteQuantifierType: IndefiniteQuantifierType
67+
startIndex: Int,
68+
endIndex: Int,
69+
indefiniteQuantifierType: IndefiniteQuantifierType
7170
) : this(startIndex, endIndex, indefiniteQuantifierType.toString())
7271
}
7372

@@ -83,21 +82,25 @@ data class FuzzyValue(override val startIndex: Int, override val endIndex: Int)
8382
*/
8483
@LabelMetadata(classpath = "biomedicus.v2", distinct = true)
8584
data class StandaloneQuantifier(
86-
override val startIndex: Int,
87-
override val endIndex: Int
85+
override val startIndex: Int,
86+
override val endIndex: Int
8887
) : Label()
8988

9089
/**
9190
* An amount of something. Modifies a unit
9291
*/
9392
@LabelMetadata(classpath = "biomedicus.v2", distinct = true)
9493
data class Quantifier(
95-
override val startIndex: Int,
96-
override val endIndex: Int,
97-
val isExact: Boolean
94+
override val startIndex: Int,
95+
override val endIndex: Int,
96+
val isExact: Boolean
9897
) : Label() {
9998

100-
constructor(range: TextRange, isExact: Boolean) : this(range.startIndex, range.endIndex, isExact)
99+
constructor(range: TextRange, isExact: Boolean) : this(
100+
range.startIndex,
101+
range.endIndex,
102+
isExact
103+
)
101104
}
102105

103106
private val test: (String, Token) -> Boolean = { word, token: Token ->
@@ -109,21 +112,21 @@ private val test: (String, Token) -> Boolean = { word, token: Token ->
109112
* [IndefiniteQuantifierType] and also detects [FuzzyValue].
110113
*/
111114
class IndefiniteQuantifierDetector(
112-
private val left: SequenceDetector<String, Token>,
113-
private val right: SequenceDetector<String, Token>,
114-
private val local: SequenceDetector<String, Token>,
115-
private val fuzzy: SequenceDetector<String, Token>
115+
private val left: SequenceDetector<String, Token>,
116+
private val right: SequenceDetector<String, Token>,
117+
private val local: SequenceDetector<String, Token>,
118+
private val fuzzy: SequenceDetector<String, Token>
116119
) : DocumentsProcessor {
117120
@Inject internal constructor(
118-
@Setting("measures.indefiniteQuantifiers.leftPath") leftPath: String,
119-
@Setting("measures.indefiniteQuantifiers.rightPath") rightPath: String,
120-
@Setting("measures.indefiniteQuantifiers.localPath") localPath: String,
121-
@Setting("measures.indefiniteQuantifiers.fuzzyPath") fuzzyPath: String
121+
@Setting("measures.indefiniteQuantifiers.leftPath") leftPath: String,
122+
@Setting("measures.indefiniteQuantifiers.rightPath") rightPath: String,
123+
@Setting("measures.indefiniteQuantifiers.localPath") localPath: String,
124+
@Setting("measures.indefiniteQuantifiers.fuzzyPath") fuzzyPath: String
122125
) : this(
123-
SequenceDetector.loadFromFile(leftPath, test),
124-
SequenceDetector.loadFromFile(rightPath, test),
125-
SequenceDetector.loadFromFile(localPath, test),
126-
SequenceDetector.loadFromFile(fuzzyPath, test)
126+
SequenceDetector.loadFromFile(leftPath, test),
127+
SequenceDetector.loadFromFile(rightPath, test),
128+
SequenceDetector.loadFromFile(localPath, test),
129+
SequenceDetector.loadFromFile(fuzzyPath, test)
127130
)
128131

129132
override fun process(document: Document) {
@@ -137,25 +140,39 @@ class IndefiniteQuantifierDetector(
137140
val sentenceTokens = tokens.inside(sentence).asList()
138141

139142
left.detectAll(sentenceTokens).forEach {
140-
cueLabeler.add(IndefiniteQuantifierCue(sentenceTokens[it.first].startIndex,
141-
sentenceTokens[it.last].endIndex, IndefiniteQuantifierType.LEFT.name))
143+
cueLabeler.add(
144+
IndefiniteQuantifierCue(
145+
sentenceTokens[it.first].startIndex,
146+
sentenceTokens[it.last].endIndex, IndefiniteQuantifierType.LEFT.name
147+
)
148+
)
142149
}
143150

144151
right.detectAll(sentenceTokens).forEach {
145-
cueLabeler.add(IndefiniteQuantifierCue(sentenceTokens[it.first].startIndex,
146-
sentenceTokens[it.last].endIndex, IndefiniteQuantifierType.RIGHT.name))
152+
cueLabeler.add(
153+
IndefiniteQuantifierCue(
154+
sentenceTokens[it.first].startIndex,
155+
sentenceTokens[it.last].endIndex, IndefiniteQuantifierType.RIGHT.name
156+
)
157+
)
147158
}
148159

149160
local.detectAll(sentenceTokens).forEach {
150-
cueLabeler.add(IndefiniteQuantifierCue(sentenceTokens[it.first].startIndex,
151-
sentenceTokens[it.last].endIndex, IndefiniteQuantifierType.LOCAL.name))
161+
cueLabeler.add(
162+
IndefiniteQuantifierCue(
163+
sentenceTokens[it.first].startIndex,
164+
sentenceTokens[it.last].endIndex, IndefiniteQuantifierType.LOCAL.name
165+
)
166+
)
152167
}
153168

154169
fuzzy.detectAll(sentenceTokens).forEach {
155-
fuzzyLabeler.add(FuzzyValue(
170+
fuzzyLabeler.add(
171+
FuzzyValue(
156172
sentenceTokens[it.first].startIndex,
157173
sentenceTokens[it.last].endIndex
158-
))
174+
)
175+
)
159176
}
160177
}
161178
}
@@ -165,10 +182,10 @@ class IndefiniteQuantifierDetector(
165182
* Detects instances of [StandaloneQuantifier] labels.
166183
*/
167184
class StandaloneQuantifierDetector(
168-
val detector: SequenceDetector<String, Token>
185+
val detector: SequenceDetector<String, Token>
169186
) : DocumentsProcessor {
170187
@Inject constructor(
171-
@Setting("measures.standaloneQuantifiersPath") path: String
188+
@Setting("measures.standaloneQuantifiersPath") path: String
172189
) : this(SequenceDetector.loadFromFile(path, test))
173190

174191
override fun process(document: Document) {
@@ -178,13 +195,17 @@ class StandaloneQuantifierDetector(
178195
val labeler = document.labeler<StandaloneQuantifier>()
179196

180197
sentences
181-
.map { tokens.inside(it).asList() }
182-
.forEach { sentenceTokens ->
183-
detector.detectAll(sentenceTokens).forEach {
184-
labeler.add(StandaloneQuantifier(sentenceTokens[it.first].startIndex,
185-
sentenceTokens[it.last].endIndex))
186-
}
198+
.map { tokens.inside(it).asList() }
199+
.forEach { sentenceTokens ->
200+
detector.detectAll(sentenceTokens).forEach {
201+
labeler.add(
202+
StandaloneQuantifier(
203+
sentenceTokens[it.first].startIndex,
204+
sentenceTokens[it.last].endIndex
205+
)
206+
)
187207
}
208+
}
188209
}
189210
}
190211

@@ -193,10 +214,12 @@ class StandaloneQuantifierDetector(
193214
*/
194215
class QuantifierDetector(private val expr: TagEx) : DocumentsProcessor {
195216
@Inject constructor(factory: TagExFactory) : this(
196-
factory.parse("""([?indef:IndefiniteQuantifierCue] ->)?
217+
factory.parse(
218+
"""([?indef:IndefiniteQuantifierCue] ->)?
197219
([?NumberRange] | [?Number] | [?fuzz:FuzzyValue]
198220
| [?PosTag<getPartOfSpeech=eDT> ParseToken<getText="a">])"""
199-
))
221+
)
222+
)
200223

201224
override fun process(document: Document) {
202225
val labeler = document.labeler<Quantifier>()

biomedicus-distribution/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<artifactId>biomedicus</artifactId>
2323
<groupId>edu.umn.biomedicus</groupId>
24-
<version>2.0.0</version>
24+
<version>2.0.1</version>
2525
</parent>
2626
<packaging>pom</packaging>
2727
<modelVersion>4.0.0</modelVersion>

biomedicus-rtf/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<artifactId>biomedicus</artifactId>
2323
<groupId>edu.umn.biomedicus</groupId>
24-
<version>2.0.0</version>
24+
<version>2.0.1</version>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>
2727

biomedicus-uima/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<artifactId>biomedicus</artifactId>
2323
<groupId>edu.umn.biomedicus</groupId>
24-
<version>2.0.0</version>
24+
<version>2.0.1</version>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>
2727

biomedicus-uima/src/main/kotlin/edu/umn/biomedicus/uima/labels/AutoAdapters.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class AutoAdapters @Inject constructor(
7979
}
8080

8181

82+
val reservedProperties = setOf("Type")
83+
8284
/**
8385
* An auto-adapter from a [Label] to an auto-generated UIMA type.
8486
*/
@@ -183,6 +185,7 @@ class AutoAdapter<T : Label>(
183185
property: KProperty1<T, *>,
184186
parameter: KParameter
185187
): PropertyMapping<*> {
188+
if (reservedProperties.contains(property.name)) error("${property.name} is reserved.")
186189
return when (property.returnType.classifier) {
187190
Boolean::class -> {
188191
checkPrimitiveProperty(property)

0 commit comments

Comments
 (0)