feat: add latex_figure_context_extractor_mapper operator#923
feat: add latex_figure_context_extractor_mapper operator#923liyuyi-2001 wants to merge 4 commits intodatajuicer:mainfrom
Conversation
Summary of ChangesHello @liyuyi-2001, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a powerful new data processing operator that significantly enhances the ability to extract structured information from LaTeX documents. By intelligently parsing figure environments, identifying associated captions, labels, image paths, and crucially, the textual context that cites these figures, it enables the creation of rich, figure-centric datasets. This functionality is particularly valuable for research papers and technical documents, allowing for deeper analysis and organization of visual content and its narrative integration. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new latex_figure_context_extractor_mapper operator, which is a significant feature for processing LaTeX documents. The implementation is comprehensive, covering various figure and subfigure environments, and is accompanied by a thorough set of unit tests. My review identified a critical bug in the logic for parsing parent figure information when subfigures are present, which could lead to incorrect data extraction. I've provided a fix for this issue. Additionally, I've included a minor suggestion to improve code conciseness. Overall, this is a great contribution once the critical issue is addressed.
data_juicer/ops/mapper/latex_figure_context_extractor_mapper.py
Outdated
Show resolved
Hide resolved
data_juicer/ops/mapper/latex_figure_context_extractor_mapper.py
Outdated
Show resolved
Hide resolved
Add a new mapper operator that extracts figures and their citing context from LaTeX source. It parses figure/figure*/wrapfigure environments, handles subfigure environments and \subfigure/\subfloat commands, and finds prose paragraphs that cite each figure via \ref/\cref/\autoref. One input paper row fans out into N output figure rows (one per figure or subfigure). Samples without figures are dropped. Output fields: images, caption, label, citing_paragraphs, parent_caption, parent_label. Includes: - Operator implementation with recursive nested-brace regex support - Config entry in config_all.yaml - Registration in mapper __init__.py - Comprehensive unit tests (21 test cases) - Operator documentation (EN/CN) Made-with: Cursor
ebe11fb to
44659cc
Compare
yxdyc
left a comment
There was a problem hiding this comment.
plz resolve the gemini suggestion & my minor comment
others LGTM.
Made-with: Cursor
Gemini's valid suggestion has been resolved. I've also added a mapper in #932, which might address your comment. |
Made-with: Cursor
Keep both latex_figure_context_extractor_mapper (this PR) and latex_merge_tex_mapper (upstream) entries in config_all.yaml, mapper __init__.py, and docs/Operators.md. Made-with: Cursor
Summary
Add a new mapper operator
latex_figure_context_extractor_mapperthat extracts figures and their citing context from LaTeX source.What it does
figure,figure*,wrapfigureenvironmentssubfigureenvironments and\subfigure/\subfloatcommands\includegraphicspaths for each figure\ref/\cref/\Cref/\autorefOutput fields
imageslist[str]\includegraphicscaptionstrlabelstrciting_paragraphslist[str]parent_captionstrparent_labelstrChanges
data_juicer/ops/mapper/latex_figure_context_extractor_mapper.py— operator implementationdata_juicer/ops/mapper/__init__.py— registrationdata_juicer/config/config_all.yaml— config entrytests/ops/mapper/test_latex_figure_context_extractor_mapper.py— 21 unit testsdocs/operators/mapper/latex_figure_context_extractor_mapper.md— documentation (EN/CN)Testing