1
0
Fork 0

Easier contraction typing (#289)

* removed isPunctiationPartOfWords hack and created a new contraction input method that allows typing just anything, instead of predefined list coming from the dictionary

* updated the common compound words and contractions in Bulgarian, Dutch, English and French

* removed some non-sense and rarely used English words

* fixed crashing when trying to find words with apostrophes in the database

* fixed a crash when trying to capitalize single character strings

* improved dictionary validation at build time: spaces are now disallowed
This commit is contained in:
Dimo Karaivanov 2023-06-20 09:29:48 +03:00 committed by GitHub
parent cf766334d6
commit 241a4125b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 389 additions and 35214 deletions

View file

@ -86,29 +86,6 @@ def getReleaseVersion = { ->
return "${getVersionName()} (${getCurrentGitHash()})"
}
def isPunctuationInWordsAllowed (String dictionaryFile) {
boolean isAllowed = false
file("${project.projectDir}/src/io/github/sspanak/tt9/languages/definitions").listFiles().each { file ->
boolean isTheDefinitionFile = false
file.eachLine {line ->
if (line.contains(dictionaryFile)) {
isTheDefinitionFile = true
}
}
if (isTheDefinitionFile) {
file.eachLine {line ->
if (line.matches(".+?isPunctuationPartOfWords\\s*=\\s*true.+?")) {
isAllowed = true
}
}
}
}
return isAllowed
}
task validateDictionaries {
inputs.dir fileTree(dir:'assets', excludes:['dict.properties'])
outputs.file "${project.buildDir}/dict.validation.txt"
@ -116,7 +93,6 @@ task validateDictionaries {
doLast {
final String CSV_DELIMITER = ' ' // TAB
final GEOGRAPHICAL_NAME = ~"[A-Z]\\w+-[^\\n]+"
final PUNCTUATION_CHARS = ~".*?\\p{Punct}(?<!-).*?"
final MAX_ERRORS = 50
String errors = ""
@ -131,7 +107,6 @@ task validateDictionaries {
println "Validating dictionary: " + file.name
def isPunctuationAllowed = isPunctuationInWordsAllowed(file.name)
def uniqueWords = [:]
int lineNumber = 0
@ -151,6 +126,13 @@ task validateDictionaries {
return
}
if (line.contains(" ")) {
isFileValid = false
errorCount++
errors += "Dictionary '" + file.name + "' is invalid. Found space on line " + lineNumber + ". Make sure each word is on a new line. Phrases are not allowed.\n"
return
}
String[] parts = line.split(CSV_DELIMITER, 2)
String word = parts[0]
String frequency = parts.length > 1 ? parts[1] : ""
@ -179,12 +161,6 @@ task validateDictionaries {
errors += "Dictionary '" + file.name + "' is invalid. Found a single letter: '" + word + "' on line " + lineNumber + ". Only uppercase single letters are allowed. The rest of the alphabet will be added automatically.\n"
}
if (!isPunctuationAllowed && word.matches(PUNCTUATION_CHARS)) {
isFileValid = false
errorCount++
errors += "Dictionary '" + file.name + "' is invalid. Found a punctuation mark in word: '" + word + "' on line " + lineNumber + ". Remove all punctuation characters when the language definition disallows them or update the definition.\n"
}
String uniqueWordKey = word ==~ GEOGRAPHICAL_NAME ? word : word.toLowerCase()
if (uniqueWords[uniqueWordKey] != null && uniqueWords[uniqueWordKey] == true) {
isFileValid = false
@ -235,21 +211,12 @@ android {
defaultConfig {
minSdkVersion 19
//noinspection ExpiredTargetSdkVersion
targetSdk 30
versionCode getVersionCode()
versionName getVersionName()
}
// http://stackoverflow.com/a/19130098
// signingConfigs {
// release {
// storeFile file(System.getenv("KEYSTORE"))
// storePassword System.getenv("KEYSTORE_PASS")
// keyAlias System.getenv("KEY_ALIAS")
// keyPassword System.getenv("KEY_ALIAS_PASS")
// }
// }
//
buildTypes {
debug { data ->
data.buildConfigField 'String', 'VERSION_FULL', "\"${getDebugVersion()}\""