Skip to content

Commit

Permalink
Merge pull request #6 from valencik/more-analyzers
Browse files Browse the repository at this point in the history
Add asciiFolderWithLower
  • Loading branch information
valencik authored Jun 22, 2022
2 parents 7b06df5 + e3fa6f8 commit 17f27a6
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 17f27a6

Please sign in to comment.