Last active
February 12, 2020 01:54
-
-
Save duanebester/0f8741eaddaeb80cc376cb720dd98818 to your computer and use it in GitHub Desktop.
Extract Dates Flow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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