1

I have to implement a function that trims prefixes from a given string. The list of prefixes could be very large so it will be costly to try regular Scala functions stripPrefix one after the other. So I've turned to Lucene in order to create a FSA that will be smaller and more efficient testing for prefixes.

Following this Stackoverflow question I discovered that the automaton I was looking for is the DaciukMihov Automaton. But then I don't know how to use the automaton for getting which was the prefix matched or not against the string. So I have 2 complementary questions:

  1. How do you use a generic Automaton in order to get the start and end characters of a match?
  2. How do you force the match to happen at the beginning of the string?
tonicebrian
  • 4,715
  • 5
  • 41
  • 65

0 Answers0