From 9c86a8202258f19024f71c4292cd8f0576cd0b1c Mon Sep 17 00:00:00 2001 From: George Basiev Date: Sun, 17 Dec 2023 00:25:25 +0300 Subject: [PATCH 1/3] RULE_VARIOUS_ABBREVIATIONS fix --- .../mundaneassignmentpolice/checker/rule/regex/RegexRule.kt | 2 +- .../github/darderion/mundaneassignmentpolice/rules/Rules.kt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/checker/rule/regex/RegexRule.kt b/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/checker/rule/regex/RegexRule.kt index 744e4fc1..936f01f1 100644 --- a/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/checker/rule/regex/RegexRule.kt +++ b/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/checker/rule/regex/RegexRule.kt @@ -50,6 +50,6 @@ open class RegexRule( }) } - return matches.toSet().toList() + return matches.sortedBy{it.first}.toSet().toList() } } \ No newline at end of file diff --git a/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt b/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt index aeb86024..dd01e944 100644 --- a/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt +++ b/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt @@ -622,6 +622,8 @@ val RULE_ORDER_OF_REFERENCES = RegexRuleBuilder() }.map { it.second } }.getRule() +val exclusionsForAbbreviations = arrayOf(Regex("или", RegexOption.IGNORE_CASE), Regex("по", RegexOption.IGNORE_CASE)) + val RULE_VARIOUS_ABBREVIATIONS = RegexRuleBuilder() .called("Использованы различные версии сокращения") .regex(Regex("""[a-zA-Zа-яА-Я]+""")) @@ -644,6 +646,9 @@ val RULE_VARIOUS_ABBREVIATIONS = RegexRuleBuilder() allWords[word.lowercase()]?.size!! > 1 else false + }.filter{ pair -> + val word = pair.first + exclusionsForAbbreviations.none { it.containsMatchIn(word) } }.map { it.second } }.getRule() From a4d58b804e4c5a0d59382117d6fcb9f7a49edf8e Mon Sep 17 00:00:00 2001 From: GeorgeBasiev Date: Fri, 31 May 2024 01:36:41 +0300 Subject: [PATCH 2/3] Changed Regex for abbreviations --- .../com/github/darderion/mundaneassignmentpolice/rules/Rules.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt b/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt index 27181349..388e333e 100644 --- a/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt +++ b/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt @@ -535,7 +535,7 @@ val exclusionsForAbbreviations = arrayOf(Regex("или", RegexOption.IGNORE_CASE val RULE_VARIOUS_ABBREVIATIONS = RegexRuleBuilder() .called("Использованы различные версии сокращения") .setDescription("Тексте работ (не в ссылках!) часто пишут github, Github и GitHub. При этом, во-первых правильное написание — это GitHub, а во-вторых, в общем случае подобная разнородность смотрится некрасиво. Сейчас правило часто захватывает web-ссылки и потому возможны ложные срабатывания, однако следует проверить все ли из них — ложные (практика показывает что нет)") - .regex(Regex("""[a-zA-Zа-яА-Я]+""")) + .regex(Regex("""[a-zA-Zа-яА-Я-_\.]+""")) .inArea(PDFRegion.EVERYWHERE.except(PDFArea.FOOTNOTE, PDFArea.BIBLIOGRAPHY)) .disallow { matches -> val abbreviations = hashSetOf() From cd078cbce7850d730d3dad938803855d274de6a7 Mon Sep 17 00:00:00 2001 From: GeorgeBasiev Date: Sun, 2 Jun 2024 23:29:17 +0300 Subject: [PATCH 3/3] small fix --- .../com/github/darderion/mundaneassignmentpolice/rules/Rules.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt b/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt index 388e333e..1db3f072 100644 --- a/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt +++ b/src/main/kotlin/com/github/darderion/mundaneassignmentpolice/rules/Rules.kt @@ -535,7 +535,7 @@ val exclusionsForAbbreviations = arrayOf(Regex("или", RegexOption.IGNORE_CASE val RULE_VARIOUS_ABBREVIATIONS = RegexRuleBuilder() .called("Использованы различные версии сокращения") .setDescription("Тексте работ (не в ссылках!) часто пишут github, Github и GitHub. При этом, во-первых правильное написание — это GitHub, а во-вторых, в общем случае подобная разнородность смотрится некрасиво. Сейчас правило часто захватывает web-ссылки и потому возможны ложные срабатывания, однако следует проверить все ли из них — ложные (практика показывает что нет)") - .regex(Regex("""[a-zA-Zа-яА-Я-_\.]+""")) + .regex(Regex("""[a-zA-Zа-яА-Я\-_\.]+""")) .inArea(PDFRegion.EVERYWHERE.except(PDFArea.FOOTNOTE, PDFArea.BIBLIOGRAPHY)) .disallow { matches -> val abbreviations = hashSetOf()