pub struct KeywordExtractor;Expand description
关键字抽取器。
对应 Java: org.ofdrw.reader.keyword.KeywordExtractor
在 OFD 文档的文本内容中搜索关键字,返回匹配位置的页面和矩形区域。
注意:Java 版使用 AWT FontRenderContext 计算精确的字符边界,
Rust 版使用简化的文本宽度估算。对于精确排版,需要集成外部字体引擎。
Implementations§
Source§impl KeywordExtractor
impl KeywordExtractor
Sourcepub fn get_keyword_positions(
pages: &[OfdPage],
keyword: &str,
) -> Vec<KeywordPosition>
pub fn get_keyword_positions( pages: &[OfdPage], keyword: &str, ) -> Vec<KeywordPosition>
获取关键字在文档中的位置列表。
对应 Java: KeywordExtractor.getKeyWordPositionList(OFDReader, String)
搜索所有页面的文本内容,返回包含关键字的矩形区域。
§参数
pages: 已解析的页面列表。keyword: 要搜索的关键字。
Sourcepub fn get_keyword_positions_with_fonts(
pages: &[OfdPage],
keyword: &str,
font_sizes: &HashMap<String, f64>,
) -> Vec<KeywordPosition>
pub fn get_keyword_positions_with_fonts( pages: &[OfdPage], keyword: &str, font_sizes: &HashMap<String, f64>, ) -> Vec<KeywordPosition>
获取关键字坐标列表(带字体度量的精确版本)。
对应 Java: KeywordExtractor.getKeyWordPositionList(OFDReader, String)
此方法接受字体大小映射表,用于更精确地计算字符宽度。
§参数
pages: 已解析的页面列表。keyword: 要搜索的关键字。font_sizes: 字体大小映射(字体 ID -> 字号,单位毫米)。
Sourcepub fn get_keyword_positions_from_text_codes(
entries: &[TextCodeEntry],
keyword: &str,
) -> Vec<KeywordPosition>
pub fn get_keyword_positions_from_text_codes( entries: &[TextCodeEntry], keyword: &str, ) -> Vec<KeywordPosition>
从 TextCode 条目列表中搜索关键字位置(支持跨 TextCode 边界匹配)。
对应 Java: KeywordExtractor.getKeyWordPositionList(OFDReader, String[], int[])
此方法接受按阅读顺序排列的 TextCode 条目列表。当关键字被 TextCode 边界切断时(如“电子印章“分属两个 TextCode),算法会拼接相邻 TextCode 的文本内容来定位完整关键字。
§参数
entries: 按阅读顺序排列的 TextCode 条目列表。keyword: 要搜索的关键字。
§匹配模式
- 普通匹配:关键字完整包含在单个 TextCode 中。
- 前缀匹配:当前 TextCode 的内容是关键字的前缀,向后拼接。
- 后缀匹配:当前 TextCode 的末尾匹配关键字的开头,向后拼接。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KeywordExtractor
impl RefUnwindSafe for KeywordExtractor
impl Send for KeywordExtractor
impl Sync for KeywordExtractor
impl Unpin for KeywordExtractor
impl UnsafeUnpin for KeywordExtractor
impl UnwindSafe for KeywordExtractor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more