Skip to content

Commit

Permalink
Merge pull request #492 from guardian/rm/bump-languagetool
Browse files Browse the repository at this point in the history
Bump languagetool to 6.4
  • Loading branch information
rhystmills authored Feb 4, 2025
2 parents 60113a9 + 2070f96 commit fd70638
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions apps/checker/app/matchers/LanguageToolMatcher.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package matchers

import com.gu.typerighter.model.{Category, LTRule, LTRuleXML, RuleMatch}

import java.io.File
import org.languagetool._
import org.languagetool.language.{BritishEnglish}
import org.languagetool.rules.spelling.morfologik.suggestions_ordering.SuggestionsOrdererConfig
import org.languagetool.rules.{Rule => LanguageToolRule}
import play.api.Logging
Expand All @@ -13,7 +15,8 @@ import scala.concurrent.{ExecutionContext, Future}
import org.languagetool.rules.patterns.PatternRuleLoader
import org.languagetool.rules.patterns.AbstractPatternRule
import utils.{Matcher, MatcherCompanion}
import scala.xml.{XML, Attribute, Null, Text}

import scala.xml.{Attribute, Null, Text, XML}
import scala.util.Try
import scala.util.Success
import scala.util.Failure
Expand Down Expand Up @@ -111,7 +114,12 @@ class LanguageToolFactory(
val loader = new PatternRuleLoader()
getXMLStreamFromLTRules(rules) flatMap { xmlStream =>
{
Try(loader.getRules(xmlStream, "languagetool-generated-xml").asScala.toList)
Try(
loader
.getRules(xmlStream, "languagetool-generated-xml", new BritishEnglish())
.asScala
.toList
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class LanguageToolMatcherTest extends AsyncFlatSpec with Matchers {
val eventuallyMatches = instance.check(request)

val expectedMatchMessages =
List("Did you mean <suggestion>fewer</suggestion>? The noun tests is countable.")
List("Did you mean <suggestion>fewer</suggestion>? The noun \"tests\" is countable.")
val expectedMatchCategoryIds = List("GRAMMAR")
eventuallyMatches map { matches =>
matches.map(_.message) shouldBe expectedMatchMessages
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ThisBuild / scalacOptions := Seq(
// See https://support.snyk.io/hc/en-us/articles/9590215676189-Deeply-nested-Scala-projects-have-dependencies-truncated
ThisBuild / asciiGraphWidth := 999999999

val languageToolVersion = "6.0"
val languageToolVersion = "6.4"
val awsSdkVersion = "1.12.749"
val capiModelsVersion = "17.5.1"
val capiClientVersion = "19.2.1"
Expand Down

0 comments on commit fd70638

Please sign in to comment.