discoverygarden / islandora_hocr
This package is auto-updated.
Last update: 2024-09-11 12:24:39 UTC
README
简介
添加hOCR派生功能。
安装
按照常规安装,更多信息请参阅这里。
此模块包含一个迁移,可帮助创建用于在常见Islandora配置中使用的媒体使用术语。启用模块后,将暴露 islandora_hocr_media_uses
迁移以生成URI为 https://discoverygarden.ca/use#hocr
的媒体使用术语。
# Flow might be something like:
drush en islandora_hocr
drush migrate:import islandora_hocr_media_uses
配置
派生
必须创建并配置一个动作以生成hOCR派生。动作还必须由上下文触发,以便创建派生。有关更多信息,请参阅官方Islandora文档。
Solr
我们预计将使用Solr OCR Highlighting Plugin。其安装细节最终取决于安装的环境。
我们有一个环境变量,允许指定Solr实例上库的路径,以便我们可以将其路径添加到Solr的configset中
SOLR_HOCR_PLUGIN_PATH
: Solr可解析的路径,指向包含OCR Highlighting Plugin JAR的目录。
包含一些配置实体
- 用于执行标记的
islandora_hocr
字段类型。 - “选择带HOCR高亮的”
/select_ocr
请求处理器。
HOCR索引
我们为node
实体添加了从相关媒体索引HOCR的能力,利用了Solr OCR Highlighting Plugin
例如,您可能可以通过Search API Solr配置将islandora_hocr_field:content
属性添加到索引中,作为islandora_hocr_field
,作为一个全文 ("islandora_hocr")
字段。
这是一个旁白,但islandora_hocr_field:uri
目前是典型的:Solr OCR Highlighting插件还有一个字符过滤器,用于处理文件内容中的路径;然而,在网络通信的上下文中,这种访问可能并不总是可行的,特别是当涉及到访问控制时...因此,我们目前预计将推送每个页面的完整页级OCR文档。
使用方法
假设已按照上述方式配置索引,并具有islandora_hocr_field
,那么您可能可以通过以下方式进行程序性的Search API查询:
$index = \Drupal\search_api\Entity\Index::load('default_solr_index'); $query = $index->query(); // The search term(s). $query->keys('bravo'); // Additional conditions, as desired. $query->addCondition('type', 'islandora_object'); // Activate our highlighting behaviour. $query->setOption('islandora_hocr_properties', [ 'islandora_hocr_field' => [], ]); // Perform the query. $results = $query->execute(); // Get the additionally-populated property info, so we can identify what fields from the highlighted results correspond to which property. $info = $results->getQuery()->getOption('islandora_hocr_properties'); // This should be an associative array mapping language codes to Solr fields, // which can then be found in the $highlights below. $language_fields = $info['islandora_hocr_field']['language_fields']; // When processing the results, the foreach ($results as $result) { // Highlighting info can be acquired from the items. The format here is the // same as the format from https://dbmdz.github.io/solr-ocrhighlighting/0.8.3/query/#response-format // for the given item/document. $highlights = $result->getExtraData('islandora_hocr_highlights'); }
故障排除/问题
有问题或已解决问题?请联系discoverygarden。
已知问题
- Solr Cloud Package(不)兼容性:库的路径可能被省略;然而,在配置实体中条件包含前缀是有问题的。
维护者/赞助商
当前维护者
赞助商