Skip to content

Commit

Permalink
fix dups task
Browse files Browse the repository at this point in the history
  • Loading branch information
arysin committed Oct 5, 2023
1 parent 0ed7a29 commit c342c54
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 39 deletions.
44 changes: 5 additions & 39 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,45 +135,11 @@ task sortDict(type: JavaExec) {
}


task dups {
doLast {
def dictDir = file("data/dict")

def files = dictDir.listFiles().findAll { it.name.endsWith('.lst') \
&& ! (it.name in ['dot-abbr.lst', 'geo-ukr-hydro.lst', 'geo-ukr-koatuu.lst']) }

def lines = files.collect { File f ->
boolean geo = f.name.contains('geo')
f.readLines()
.findAll { ! it.startsWith('#') && ! it.startsWith(' +cs=') }
.collect { it
// .replaceFirst(/^ \+cs=/, '')
.trim()
.replaceAll(/\s*#.*/, '')
.replaceAll(/( \/[a-z0-9]+)(\s+|$)/, '$1... ')
.replaceAll(/\.[^<.: ]+/, '...')
.replaceAll(/\s*:coll/, '')
.replaceAll(/:&adjp:(actv|pasv)(:(imperf|perf))+/, '')
}
.collect { line ->
geo ? "$line :geo" : line
}
}
.flatten()
.grep { it }

// lines = lines.grep { ! it.startsWith('#') }

def dups = lines.countBy{it}.grep{it.value > 1 }.collect{it.key}

java.text.Collator coll = java.text.Collator.getInstance(new Locale("uk", "UA"));
coll.setStrength(java.text.Collator.IDENTICAL)
coll.setDecomposition(java.text.Collator.NO_DECOMPOSITION)

task checkDups(type: JavaExec) {
classpath = sourceSets.test.runtimeClasspath
mainClass = "org.dict_uk.check.CheckDups"

println dups.toSorted(coll).join("\n")
println "Found ${dups.size} dups"
}
workingDir = projectDir
}

task checkAnim {
Expand Down Expand Up @@ -344,7 +310,7 @@ task testExpand(type: JavaExec, dependsOn: [reverseAffix, autogen, classes]) {
// Main targets
//

task expandForCorp(type: JavaExec, dependsOn: [reverseAffix, autogen/*, testExpand*/, dups]) {
task expandForCorp(type: JavaExec, dependsOn: [reverseAffix, autogen/*, testExpand*/, checkDups]) {
classpath = sourceSets.main.runtimeClasspath
mainClass = "org.dict_uk.expand.ExpandAll"

Expand Down
39 changes: 39 additions & 0 deletions src/test/groovy/org/dict_uk/check/CheckDups.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/env groovy

package org.dict_uk.check

def dictDir = new File("data/dict")

def files = dictDir.listFiles().findAll { it.name.endsWith('.lst') \
&& ! (it.name in ['dot-abbr.lst', 'geo-ukr-hydro.lst', 'geo-ukr-koatuu.lst']) }

def lines = files.collect { File f ->
boolean geo = f.name.contains('geo')
f.readLines()
.findAll { ! it.startsWith('#') && ! it.startsWith(' +cs=') }
.collect { it
// .replaceFirst(/^ \+cs=/, '')
.trim()
.replaceAll(/\s*#.*/, '')
.replaceAll(/( \/[a-z0-9]+)(\s+|$)/, '$1... ')
.replaceAll(/\.[^<.: ]+/, '...')
.replaceAll(/\s*:coll/, '')
.replaceAll(/:&adjp:(actv|pasv)(:(imperf|perf))+/, '')
}
.collect { line ->
geo ? "$line :geo" : line
}
}
.flatten()
.grep { it }

// lines = lines.grep { ! it.startsWith('#') }

def dups = lines.countBy{it}.grep{it.value > 1 }.collect{it.key.toString()}

java.text.Collator coll = java.text.Collator.getInstance(new Locale("uk", "UA"));
coll.setStrength(java.text.Collator.IDENTICAL)
coll.setDecomposition(java.text.Collator.NO_DECOMPOSITION)

println dups.toSorted(coll).join("\n")
println "Found ${dups.size()} dups"

0 comments on commit c342c54

Please sign in to comment.