Skip to content

Commit

Permalink
Add asciiFolderWithLower
Browse files Browse the repository at this point in the history
  • Loading branch information
valencik committed Jun 22, 2022
1 parent 7b06df5 commit e3fa6f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lucene/src/main/scala/textmogrify/lucene/Analyzers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@ object Analyzers {
}
}

def asciiFolderWithLower(): Analyzer =
new Analyzer {
protected def createComponents(fieldName: String): TokenStreamComponents = {
val source = new StandardTokenizer()
val tokens = new LowerCaseFilter(source)
new TokenStreamComponents(source, new ASCIIFoldingFilter(tokens))
}
}

}
8 changes: 8 additions & 0 deletions lucene/src/test/scala/textmogrify/lucene/AnalyzersSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ class AnalyzersSuite extends CatsEffectSuite {
assertIO(actual, Vector("I", "like", "jalapenos"))
}

test("asciiFolderLower should fold and lowercase") {
val tokenizer = AnalyzerResource.tokenizer[IO](Analyzers.asciiFolderWithLower())
val actual = tokenizer.use { f =>
f("I Like Jalapeños")
}
assertIO(actual, Vector("i", "like", "jalapenos"))
}

}

0 comments on commit e3fa6f8

Please sign in to comment.