Skip to content

Instantly share code, notes, and snippets.

@duanebester
Last active February 12, 2020 01:54
Show Gist options
  • Save duanebester/0f8741eaddaeb80cc376cb720dd98818 to your computer and use it in GitHub Desktop.
Save duanebester/0f8741eaddaeb80cc376cb720dd98818 to your computer and use it in GitHub Desktop.
Extract Dates Flow
def extractDates = Flow[OcrSuggestionsPersons].map(ocr => {
val sentences = sentenceDetector.sentDetect(ocr.ocr.replaceAll("\n", " ")).toList
import scala.collection.JavaConverters._
val dates = sentences.map(sentence => parser.parse(sentence))
.flatMap(dateGroups => dateGroups.asScala.toList)
.map(dateGroup => (dateGroup.getDates().asScala.toList.map(_.toString()), dateGroup.getText()))
OcrSuggestionsPersonsDates(ocr.ocr, ocr.suggestions, ocr.persons, dates)
})
// Update OCR Flow
val ocrFlow = imageOcr.via(spellCheck).via(extractPersons).via(extractDates)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment