fixed the .gradle file indentation and updated the Editorconfig rules
This commit is contained in:
parent
e3d0bac90f
commit
3a25c9f52f
7 changed files with 525 additions and 525 deletions
|
|
@ -1,65 +1,65 @@
|
|||
class Wrapper {
|
||||
static def getDictionaryLineData(String line, String delimiter) {
|
||||
String[] parts = line.split(delimiter, 2)
|
||||
String word = parts[0]
|
||||
String transcription = parts.length > 1 && parts[1] =~ "^[a-zA-Z]+\$" ? parts[1] : ""
|
||||
static def getDictionaryLineData(String line, String delimiter) {
|
||||
String[] parts = line.split(delimiter, 2)
|
||||
String word = parts[0]
|
||||
String transcription = parts.length > 1 && parts[1] =~ "^[a-zA-Z]+\$" ? parts[1] : ""
|
||||
|
||||
int frequency
|
||||
try {
|
||||
int partsElement = transcription.isEmpty() ? 1 : 2
|
||||
frequency = (parts.length > partsElement ? parts[partsElement] : "0") as int
|
||||
} catch (Exception ignored) {
|
||||
frequency = -1
|
||||
}
|
||||
int frequency
|
||||
try {
|
||||
int partsElement = transcription.isEmpty() ? 1 : 2
|
||||
frequency = (parts.length > partsElement ? parts[partsElement] : "0") as int
|
||||
} catch (Exception ignored) {
|
||||
frequency = -1
|
||||
}
|
||||
|
||||
return [word, transcription, frequency]
|
||||
}
|
||||
return [word, transcription, frequency]
|
||||
}
|
||||
|
||||
|
||||
static def wordToDigitSequence(Locale locale, String word, HashMap<String, String> sounds, boolean isTranscribed) {
|
||||
def sequence = new StringBuilder()
|
||||
static def wordToDigitSequence(Locale locale, String word, HashMap<String, String> sounds, boolean isTranscribed) {
|
||||
def sequence = new StringBuilder()
|
||||
|
||||
final String normalizedWord = isTranscribed ? word : word.toUpperCase(locale)
|
||||
String currentSound = ""
|
||||
final String normalizedWord = isTranscribed ? word : word.toUpperCase(locale)
|
||||
String currentSound = ""
|
||||
|
||||
for (int i = 0, end = normalizedWord.length() - 1; i <= end; i++) {
|
||||
char currentChar = normalizedWord.charAt(i)
|
||||
char nextChar = i < end ? normalizedWord.charAt(i + 1) : 0
|
||||
int nextCharType = Character.getType(nextChar)
|
||||
for (int i = 0, end = normalizedWord.length() - 1; i <= end; i++) {
|
||||
char currentChar = normalizedWord.charAt(i)
|
||||
char nextChar = i < end ? normalizedWord.charAt(i + 1) : 0
|
||||
int nextCharType = Character.getType(nextChar)
|
||||
|
||||
currentSound += currentChar
|
||||
currentSound += currentChar
|
||||
|
||||
// charAt(i) returns "ΐ" as three separate characters, but they must be treated as one.
|
||||
if (
|
||||
locale.getLanguage() == "el"
|
||||
&& (nextCharType == Character.NON_SPACING_MARK || nextCharType == Character.ENCLOSING_MARK || nextCharType == Character.COMBINING_SPACING_MARK)
|
||||
) {
|
||||
continue
|
||||
}
|
||||
// charAt(i) returns "ΐ" as three separate characters, but they must be treated as one.
|
||||
if (
|
||||
locale.getLanguage() == "el"
|
||||
&& (nextCharType == Character.NON_SPACING_MARK || nextCharType == Character.ENCLOSING_MARK || nextCharType == Character.COMBINING_SPACING_MARK)
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (!isTranscribed || i == end || Character.isUpperCase(nextChar)) {
|
||||
if (!sounds.containsKey(currentSound)) {
|
||||
throw new IllegalArgumentException("Sound or layout entry '${currentSound}' does not belong to the language sound list: ${sounds}.")
|
||||
} else {
|
||||
sequence << sounds.get(currentSound)
|
||||
currentSound = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isTranscribed || i == end || Character.isUpperCase(nextChar)) {
|
||||
if (!sounds.containsKey(currentSound)) {
|
||||
throw new IllegalArgumentException("Sound or layout entry '${currentSound}' does not belong to the language sound list: ${sounds}.")
|
||||
} else {
|
||||
sequence << sounds.get(currentSound)
|
||||
currentSound = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sequence.isEmpty()) {
|
||||
throw new IllegalArgumentException("The word does not contain any valid sounds.")
|
||||
}
|
||||
if (sequence.isEmpty()) {
|
||||
throw new IllegalArgumentException("The word does not contain any valid sounds.")
|
||||
}
|
||||
|
||||
return sequence.toString()
|
||||
}
|
||||
return sequence.toString()
|
||||
}
|
||||
|
||||
|
||||
static def getLanguageHash(File definitionFile, File dictionaryFile) {
|
||||
def definitionHash = definitionFile != null && definitionFile.exists() ? definitionFile.text.digest("SHA-256") : ""
|
||||
def dictionaryHash = dictionaryFile != null && dictionaryFile.exists() ? dictionaryFile.text.digest("SHA-256") : ""
|
||||
return definitionHash + dictionaryHash
|
||||
}
|
||||
static def getLanguageHash(File definitionFile, File dictionaryFile) {
|
||||
def definitionHash = definitionFile != null && definitionFile.exists() ? definitionFile.text.digest("SHA-256") : ""
|
||||
def dictionaryHash = dictionaryFile != null && dictionaryFile.exists() ? dictionaryFile.text.digest("SHA-256") : ""
|
||||
return definitionHash + dictionaryHash
|
||||
}
|
||||
}
|
||||
|
||||
ext.DictionaryTools = Wrapper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue