Skip to content

Instantly share code, notes, and snippets.

@duanebester
Last active February 12, 2020 01:48
Show Gist options
  • Save duanebester/29f38e6b64328b18d858d52ccf76306b to your computer and use it in GitHub Desktop.
Save duanebester/29f38e6b64328b18d858d52ccf76306b to your computer and use it in GitHub Desktop.
Extract Persons Flow
def extractPersons = Flow[OcrSuggestions].map(ocr => {
val tokens = tokenizer.tokenize(ocr.ocr)
val spans:Array[Span] = personFinderME.find(tokens)
val persons = spans.toList.map(span => tokens(span.getStart()))
OcrSuggestionsPersons(ocr.ocr, ocr.suggestions, persons)
})
// Update OCR Flow
val ocrFlow = imageOcr.via(spellCheck).via(extractPersons)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment