-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
0bdfa8b
commit 74b3dc3
Showing
48 changed files
with
371 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
lib/src/main/java/com/nikialeksey/arspell/AndroidStrings.kt
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
lib/src/main/java/com/nikialeksey/arspell/HunspellCheck.kt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
lib/src/main/java/com/nikialeksey/arspell/IgnoreKeysStrings.kt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
lib/src/main/java/com/nikialeksey/arspell/IgnoreKeysWords.kt
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
lib/src/main/java/com/nikialeksey/arspell/IgnoreValuesStrings.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
lib/src/main/java/com/nikialeksey/arspell/SimpleSentence.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
lib/src/main/java/com/nikialeksey/arspell/SimpleStrings.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
lib/src/main/java/com/nikialeksey/arspell/checks/DictionaryCheck.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.nikialeksey.arspell.checks | ||
|
||
import com.nikialeksey.arspell.Error | ||
import com.nikialeksey.arspell.dictionary.DictionaryError | ||
import com.nikialeksey.arspell.dictionary.Dictionary | ||
import com.nikialeksey.arspell.strings.Strings | ||
|
||
class DictionaryCheck( | ||
private val dictionary: Dictionary, | ||
private val strings: Strings | ||
) : SpellCheck { | ||
|
||
override fun check(): List<Error> { | ||
val result = mutableListOf<Error>() | ||
strings.asList()[0].sentences().asList()[0].words() | ||
for (string in strings.asList()) { | ||
for (sentence in string.sentences().asList()) { | ||
for (word in sentence.words()) { | ||
val asString = word.asString() | ||
if (!dictionary.isCorrect(asString)) { | ||
result.add(DictionaryError(word.key(), asString, dictionary)) | ||
} | ||
} | ||
} | ||
} | ||
return result | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
lib/src/main/java/com/nikialeksey/arspell/checks/HunspellCheck.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.nikialeksey.arspell.checks | ||
|
||
import com.atlascopco.hunspell.Hunspell | ||
import com.nikialeksey.arspell.Error | ||
import com.nikialeksey.arspell.dictionary.HunspellDictionary | ||
import com.nikialeksey.arspell.strings.Strings | ||
|
||
class HunspellCheck( | ||
private val origin: SpellCheck | ||
) : SpellCheck { | ||
|
||
constructor(hunspell: Hunspell, strings: Strings) : this( | ||
DictionaryCheck( | ||
HunspellDictionary( | ||
hunspell | ||
), strings | ||
) | ||
) | ||
|
||
override fun check(): List<Error> { | ||
return origin.check() | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
lib/src/main/java/com/nikialeksey/arspell/checks/LanguageToolCheck.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.nikialeksey.arspell.checks | ||
|
||
import com.nikialeksey.arspell.Error | ||
import com.nikialeksey.arspell.strings.Strings | ||
import org.languagetool.JLanguageTool | ||
|
||
class LanguageToolCheck( | ||
private val languageTool: JLanguageTool, | ||
private val strings: Strings | ||
) : SpellCheck { | ||
override fun check(): List<Error> { | ||
val errors = mutableListOf<Error>() | ||
|
||
for (string in strings.asList()) { | ||
val rules = languageTool.check(string.asString()) | ||
for (rule in rules) { | ||
errors.add(LanguageToolError(string.key(), rule)) | ||
} | ||
} | ||
|
||
return errors | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
lib/src/main/java/com/nikialeksey/arspell/checks/LanguageToolError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.nikialeksey.arspell.checks | ||
|
||
import com.nikialeksey.arspell.Error | ||
import org.languagetool.rules.RuleMatch | ||
|
||
class LanguageToolError( | ||
private val key: String, | ||
private val rule: RuleMatch | ||
) : Error { | ||
override fun key(): String { | ||
return key | ||
} | ||
|
||
override fun word(): String { | ||
return rule.sentence.text.substring(rule.fromPos, rule.toPos) | ||
} | ||
|
||
override fun suggests(): List<String> { | ||
return listOf(rule.message) + rule.suggestedReplacements | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
lib/src/main/java/com/nikialeksey/arspell/checks/SpellCheck.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.nikialeksey.arspell.checks | ||
|
||
import com.nikialeksey.arspell.Error | ||
|
||
interface SpellCheck { | ||
fun check(): List<Error> | ||
} |
2 changes: 1 addition & 1 deletion
2
...ava/com/nikialeksey/arspell/Dictionary.kt → ...ialeksey/arspell/dictionary/Dictionary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...va/com/nikialeksey/arspell/SimpleError.kt → ...sey/arspell/dictionary/DictionaryError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...om/nikialeksey/arspell/DictionaryGroup.kt → ...sey/arspell/dictionary/DictionaryGroup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nikialeksey/arspell/HunspellDictionary.kt → .../arspell/dictionary/HunspellDictionary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
lib/src/main/java/com/nikialeksey/arspell/sentences/IgnoreWordsSentence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.nikialeksey.arspell.sentences | ||
|
||
import com.nikialeksey.arspell.words.IgnoreValuesWords | ||
import com.nikialeksey.arspell.words.Words | ||
|
||
class IgnoreWordsSentence( | ||
private val origin: Sentence, | ||
private val words: Collection<String> | ||
) : Sentence { | ||
override fun key(): String { | ||
return origin.key() | ||
} | ||
|
||
override fun words(): Words { | ||
return IgnoreValuesWords(origin.words(), words) | ||
} | ||
|
||
} |
Oops, something went wrong.
74b3dc3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
10-5781f6ef
discovered inreadme.md
and submitted as #17. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.