Skip to content

Commit

Permalink
Add entrySimilarityWeights in LabelerConf
Browse files Browse the repository at this point in the history
  • Loading branch information
sdercolin committed Apr 5, 2024
1 parent 061ff13 commit 5259454
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 42 deletions.
90 changes: 56 additions & 34 deletions docs/labeler-development.md

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion resources/common/labelers/audacity-labeler/labeler.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "audacity.default",
"version": 11,
"version": 12,
"serialVersion": 2,
"singleFile": false,
"extension": "txt",
Expand Down Expand Up @@ -31,6 +31,16 @@
"useStart": false
},
"decimalDigit": 4,
"entrySimilarityWeights": {
"name": 0,
"sample": 0.5,
"start": 0.25,
"end": 0.25,
"points": [],
"extras": [],
"tag": 0,
"threshold": 0.75
},
"properties": [
{
"name": "start",
Expand Down
12 changes: 11 additions & 1 deletion resources/common/labelers/nnsvs-singer-labeler/labeler.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nnsvs-singer.default",
"version": 9,
"version": 10,
"serialVersion": 2,
"singleFile": false,
"extension": "lab",
Expand Down Expand Up @@ -33,6 +33,16 @@
"useStart": false
},
"decimalDigit": 4,
"entrySimilarityWeights": {
"name": 0,
"sample": 0.5,
"start": 0.25,
"end": 0.25,
"points": [],
"extras": [],
"tag": 0,
"threshold": 0.75
},
"properties": [
{
"name": "start",
Expand Down
19 changes: 18 additions & 1 deletion resources/common/labelers/oto-labeler/labeler.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oto-plus.default",
"version": 27,
"version": 28,
"serialVersion": 2,
"singleFile": false,
"extension": "ini",
Expand Down Expand Up @@ -124,6 +124,23 @@
"useStart": true,
"useEnd": true
},
"entrySimilarityWeights": {
"name": 6,
"sample": 12,
"start": 1,
"end": 1,
"points": [
1,
1,
1,
1
],
"extras": [
0
],
"tag": 0,
"threshold": 0.75
},
"properties": [
{
"name": "left",
Expand Down
12 changes: 11 additions & 1 deletion resources/common/labelers/sinsy-labeler/labeler.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sinsy.default",
"version": 14,
"version": 15,
"serialVersion": 2,
"singleFile": false,
"extension": "lab",
Expand Down Expand Up @@ -31,6 +31,16 @@
"useStart": false
},
"decimalDigit": 4,
"entrySimilarityWeights": {
"name": 0,
"sample": 0.5,
"start": 0.25,
"end": 0.25,
"points": [],
"extras": [],
"tag": 0,
"threshold": 0.75
},
"properties": [
{
"name": "start",
Expand Down
19 changes: 18 additions & 1 deletion resources/common/labelers/utau-singer-labeler/labeler.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "utau-singer.default",
"version": 22,
"version": 23,
"serialVersion": 2,
"singleFile": false,
"extension": "ini",
Expand Down Expand Up @@ -121,6 +121,23 @@
"useEnd": true
},
"decimalDigit": 2,
"entrySimilarityWeights": {
"name": 6,
"sample": 12,
"start": 1,
"end": 1,
"points": [
1,
1,
1,
1
],
"extras": [
0
],
"tag": 0,
"threshold": 0.75
},
"properties": [
{
"name": "left",
Expand Down
6 changes: 5 additions & 1 deletion src/jvmMain/kotlin/com/sdercolin/vlabeler/io/ReloadLabel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ private fun AppState.reloadEntriesFromLabelFile(
sampleFiles = sampleFiles,
encoding = project.encoding,
)
val diff = computeEntryListDiff(project.currentModule.entries, entries)
val diff = computeEntryListDiff(
list1 = project.currentModule.entries,
list2 = entries,
weights = project.labelerConf.entrySimilarityWeights,
)
entries to diff
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.sdercolin.vlabeler.model

import androidx.compose.runtime.Immutable
import com.sdercolin.vlabeler.model.EntryListDiffItem.Add
import com.sdercolin.vlabeler.model.EntryListDiffItem.Edit
import com.sdercolin.vlabeler.model.EntryListDiffItem.Remove
import com.sdercolin.vlabeler.model.EntryListDiffItem.Unchanged
import kotlinx.serialization.Serializable

/**
* Represents a change in an entry list.
Expand All @@ -30,12 +32,14 @@ data class EntryListDiff(val items: List<EntryListDiffItem>)
* @param start Weight for the [Entry.start] property.
* @param end Weight for the [Entry.end] property.
* @param points Weights for the [Entry.points] property. The size of the list should match the size of the points list.
* If empty, the points will not be considered in the similarity score.
* If this array is empty or shorter than the points list, the missing weights will be considered as 0.
* @param extras Weights for the [Entry.extras] property. The size of the list should match the size of the extras list.
* If empty, the extras will not be considered in the similarity score.
* If this array is empty or shorter than the points list, the missing weights will be considered as 0.
* @param tag Weight for the [EntryNotes.tag] property.
* @param threshold The minimum similarity score for two entries to be considered as the same entry.
*/
@Serializable
@Immutable
data class EntrySimilarityWeights(
val name: Double = 0.5,
val sample: Double = 0.3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ import java.io.File
* @property postEditNextTrigger Trigger settings of `Go to next entry after editing` on start and end.
* @property postEditDoneTrigger Trigger settings of `Mark as done after editing` on start and end.
* @property decimalDigit Decimal digit count used in [properties] and [writer].
* @property entrySimilarityWeights Configuration for the weights of different properties in the similarity score
* calculation. See [EntrySimilarityWeights].
* @property properties Properties that are used in the following procedures. See [Property].
* @property parser Defines how data from the original label format are parsed.
* @property writer Defines how to write content in the original label format.
Expand Down Expand Up @@ -104,6 +106,7 @@ data class LabelerConf(
val postEditNextTrigger: PostEditTrigger = PostEditTrigger(),
val postEditDoneTrigger: PostEditTrigger = PostEditTrigger(),
val decimalDigit: Int? = 2,
val entrySimilarityWeights: EntrySimilarityWeights = EntrySimilarityWeights(),
val properties: List<Property> = listOf(),
val parser: Parser,
val writer: Writer,
Expand Down

0 comments on commit 5259454

Please sign in to comment.