-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49f7357
commit 4a0c357
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package extraction | ||
|
||
import cats.syntax.either._ | ||
import model.manifest.Blob | ||
import model.{English, Languages} | ||
import org.apache.commons.io.FileUtils | ||
import services.index.{Index, Pages} | ||
import services.{ScratchSpace, TranscribeConfig} | ||
import utils.FfMpeg.FfMpegSubprocessCrashedException | ||
import utils._ | ||
import utils.attempt.{Failure, FfMpegFailure, UnknownFailure} | ||
|
||
import java.io.File | ||
import scala.concurrent.ExecutionContext | ||
|
||
class EmbeddingExtractor(index: Index, pages: Pages, scratchSpace: ScratchSpace, transcribeConfig: TranscribeConfig)(implicit executionContext: ExecutionContext) extends FileExtractor(scratchSpace) with Logging { | ||
val mimeTypes: Set[String] = Set( | ||
"application/pdf" | ||
) | ||
|
||
def canProcessMimeType: String => Boolean = mimeTypes.contains | ||
|
||
override def indexing = true | ||
// set a low priority as transcription takes a long time, we don't want to block up the workers | ||
override def priority = 1 | ||
|
||
override def extract(blob: Blob, file: File, params: ExtractionParams): Either[Failure, Unit] = { | ||
logger.info(s"Running embedding extractor '${blob.uri.value}'") | ||
|
||
// Get the pages from elasticsearch | ||
for { | ||
page <- pages.getAllPages(blob.uri) | ||
} yield { | ||
// Run page through embedding model | ||
// Write embeddings to a vector field against the page | ||
} | ||
|
||
Right(()) | ||
} | ||
} |
This file contains 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
This file contains 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