fabricatio 0.2.7.dev2__tar.gz → 0.2.7.dev3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/PKG-INFO +1 -1
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/extract_and_inject/extract_and_inject.py +1 -1
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/extract_article/extract.py +1 -1
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/pyproject.toml +1 -1
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/actions/article.py +4 -1
- fabricatio-0.2.7.dev3/python/fabricatio/actions/article_rag.py +35 -0
- fabricatio-0.2.7.dev3/python/fabricatio/models/extra/article_essence.py +226 -0
- fabricatio-0.2.7.dev3/python/fabricatio/models/extra/article_main.py +359 -0
- fabricatio-0.2.7.dev3/python/fabricatio/models/extra/article_outline.py +276 -0
- fabricatio-0.2.7.dev3/python/fabricatio/models/extra/article_proposal.py +37 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/generic.py +35 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/utils.py +6 -4
- fabricatio-0.2.7.dev3/templates.tar.gz +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/uv.lock +1 -1
- fabricatio-0.2.7.dev2/python/fabricatio/models/extra.py +0 -811
- fabricatio-0.2.7.dev2/templates.tar.gz +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/.gitignore +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/.python-version +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/Cargo.lock +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/Cargo.toml +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/LICENSE +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/Makefile +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/README.md +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/correct/correct.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/correct/correct_loop.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/extract_and_inject/.gitignore +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/extract_and_inject/article_rag.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/extract_and_inject/ask.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/llm_usages/llm_usage.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/make_a_rating/rating.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/make_diary/diary.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/minor/hello_fabricatio.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/minor/write_a_poem.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/propose_task/propose.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/reviewer/review.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/search_bibtex/.gitignore +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/search_bibtex/search.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/simple_chat/chat.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/simple_rag/simple_rag.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/task_handle/handle_task.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/write_article/.gitignore +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/write_article/write_article.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/write_outline/.gitignore +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/write_outline/write_outline.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/write_outline/write_outline_corrected.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/__init__.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/_rust.pyi +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/_rust_instances.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/actions/output.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/actions/rag.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/capabilities/correct.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/capabilities/rag.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/capabilities/rating.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/capabilities/review.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/capabilities/task.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/config.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/core.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/decorators.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/fs/__init__.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/fs/readers.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/action.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/events.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/role.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/task.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/models/usages.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/parser.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/workflows/articles.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/python/fabricatio/workflows/rag.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/src/bib_tools.rs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/src/hash.rs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/src/hbs_helpers.rs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/src/lib.rs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/src/templates.rs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/as_prompt.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/co_validation.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/correct.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/create_json_obj.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/generic_string.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/liststr.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/pathstr.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/rate_fine_grind.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/refined_query.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/review_string.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/templates/built-in/write-github-readme.hbs +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/tests/test_config.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/tests/test_models/test_action.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/tests/test_models/test_advanced.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/tests/test_models/test_generic.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/tests/test_models/test_role.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/tests/test_models/test_task.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/tests/test_models/test_tool.py +0 -0
- {fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/tests/test_models/test_usages.py +0 -0
{fabricatio-0.2.7.dev2 → fabricatio-0.2.7.dev3}/examples/extract_and_inject/extract_and_inject.py
RENAMED
@@ -8,7 +8,7 @@ from fabricatio import Action, Event, Role, Task, WorkFlow, logger
|
|
8
8
|
from fabricatio.actions.article import ExtractArticleEssence
|
9
9
|
from fabricatio.actions.rag import InjectToDB
|
10
10
|
from fabricatio.fs.curd import dump_text, gather_files
|
11
|
-
from fabricatio.models.extra import ArticleEssence
|
11
|
+
from fabricatio.models.extra.article_essence import ArticleEssence
|
12
12
|
from fabricatio.models.utils import ok
|
13
13
|
from pydantic import HttpUrl
|
14
14
|
|
@@ -7,7 +7,7 @@ from fabricatio import Event, Role, Task, WorkFlow, logger
|
|
7
7
|
from fabricatio.actions.article import ExtractArticleEssence
|
8
8
|
|
9
9
|
if TYPE_CHECKING:
|
10
|
-
from fabricatio.models.extra import ArticleEssence
|
10
|
+
from fabricatio.models.extra.article_essence import ArticleEssence
|
11
11
|
|
12
12
|
|
13
13
|
async def main() -> None:
|
@@ -6,7 +6,10 @@ from typing import Any, Callable, List, Optional
|
|
6
6
|
from fabricatio.fs import safe_text_read
|
7
7
|
from fabricatio.journal import logger
|
8
8
|
from fabricatio.models.action import Action
|
9
|
-
from fabricatio.models.extra import
|
9
|
+
from fabricatio.models.extra.article_essence import ArticleEssence
|
10
|
+
from fabricatio.models.extra.article_main import Article
|
11
|
+
from fabricatio.models.extra.article_outline import ArticleOutline
|
12
|
+
from fabricatio.models.extra.article_proposal import ArticleProposal
|
10
13
|
from fabricatio.models.task import Task
|
11
14
|
from fabricatio.models.utils import ok
|
12
15
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"""A module for writing articles using RAG (Retrieval-Augmented Generation) capabilities."""
|
2
|
+
|
3
|
+
from typing import Optional
|
4
|
+
|
5
|
+
from fabricatio.capabilities.rag import RAG
|
6
|
+
from fabricatio.journal import logger
|
7
|
+
from fabricatio.models.action import Action
|
8
|
+
from fabricatio.models.extra.article_main import Article
|
9
|
+
from fabricatio.models.extra.article_outline import ArticleOutline
|
10
|
+
|
11
|
+
|
12
|
+
class GenerateArticleRAG(Action, RAG):
|
13
|
+
"""Write an article based on the provided outline."""
|
14
|
+
|
15
|
+
output_key: str = "article"
|
16
|
+
|
17
|
+
async def _execute(self, article_outline: ArticleOutline, **cxt) -> Optional[Article]:
|
18
|
+
"""Write an article based on the provided outline."""
|
19
|
+
logger.info(f"Writing an article based on the outline:\n{article_outline.title}")
|
20
|
+
refined_q = await self.arefined_query(article_outline.display())
|
21
|
+
return await self.propose(
|
22
|
+
Article,
|
23
|
+
article_outline.display(),
|
24
|
+
**self.prepend_sys_msg(f"{await self.aretrieve_compact(refined_q)}\n{self.briefing}"),
|
25
|
+
)
|
26
|
+
|
27
|
+
|
28
|
+
class WriteArticleFineGrind(Action, RAG):
|
29
|
+
"""Fine-grind an article based on the provided outline."""
|
30
|
+
|
31
|
+
output_key: str = "article"
|
32
|
+
|
33
|
+
async def _execute(self, article_outline: ArticleOutline, **cxt) -> Optional[Article]:
|
34
|
+
"""Fine-grind an article based on the provided outline."""
|
35
|
+
logger.info(f"Fine-grinding an article based on the outline:\n{article_outline.title}")
|
@@ -0,0 +1,226 @@
|
|
1
|
+
"""ArticleEssence: Semantic fingerprint of academic paper for structured analysis."""
|
2
|
+
|
3
|
+
from typing import List
|
4
|
+
|
5
|
+
from fabricatio.models.generic import Display, PrepareVectorization, ProposedAble
|
6
|
+
from pydantic import BaseModel, Field
|
7
|
+
|
8
|
+
|
9
|
+
class Equation(BaseModel):
|
10
|
+
"""Mathematical formalism specification for research contributions.
|
11
|
+
|
12
|
+
Encodes equations with dual representation: semantic meaning and typeset-ready notation.
|
13
|
+
"""
|
14
|
+
|
15
|
+
description: str
|
16
|
+
"""Equation significance structured in three elements:
|
17
|
+
1. Physical/conceptual meaning of the equation.
|
18
|
+
2. Role in technical workflow (e.g., derivation, optimization, or analysis).
|
19
|
+
3. Relationship to the paper's core contribution (e.g., theoretical foundation, empirical validation).
|
20
|
+
Example: "Defines constrained search space dimensionality reduction. Used in architecture optimization phase (Section 3.2). Enables 40% parameter reduction."
|
21
|
+
"""
|
22
|
+
|
23
|
+
latex_code: str
|
24
|
+
"""LaTeX representation following academic typesetting standards:
|
25
|
+
- Must use equation environment (e.g., `equation`, `align`).
|
26
|
+
- Multiline equations must align at '=' using `&`.
|
27
|
+
- Include unit annotations where applicable.
|
28
|
+
Example: "\\begin{equation} \\mathcal{L}_{NAS} = \\alpha \\|\\theta\\|_2 + \\beta H(p) \\end{equation}"
|
29
|
+
"""
|
30
|
+
|
31
|
+
|
32
|
+
class Figure(BaseModel):
|
33
|
+
"""Visual component specification for technical communication.
|
34
|
+
|
35
|
+
Combines graphical assets with structured academic captioning.Extracted from the article provided
|
36
|
+
"""
|
37
|
+
|
38
|
+
description: str
|
39
|
+
"""Figure interpretation guide containing:
|
40
|
+
1. Key visual elements mapping (e.g., axes, legends, annotations).
|
41
|
+
2. Data representation methodology (e.g., visualization type, statistical measures).
|
42
|
+
3. Connection to research findings (e.g., supports hypothesis, demonstrates performance).
|
43
|
+
Example: "Architecture search space topology (left) vs. convergence curves (right). Demonstrates NAS efficiency gains through constrained search."
|
44
|
+
"""
|
45
|
+
|
46
|
+
figure_caption: str
|
47
|
+
"""Complete caption following Nature-style guidelines:
|
48
|
+
1. Brief overview statement (首句总结).
|
49
|
+
2. Technical detail layer (e.g., data sources, experimental conditions).
|
50
|
+
3. Result implication (e.g., key insights, implications for future work).
|
51
|
+
Example: "Figure 3: Differentiable NAS framework. (a) Search space topology with constrained dimensions. (b) Training convergence across language pairs. Dashed lines indicate baseline methods."
|
52
|
+
"""
|
53
|
+
|
54
|
+
figure_serial_number: int
|
55
|
+
"""The Image serial number extracted from the Markdown article provided, the path usually in the form of ``, in this case the serial number is `1`"""
|
56
|
+
|
57
|
+
|
58
|
+
class Algorithm(BaseModel):
|
59
|
+
"""Algorithm specification for research contributions."""
|
60
|
+
|
61
|
+
title: str
|
62
|
+
"""Algorithm title with technical focus descriptor (e.g., 'Gradient Descent Optimization').
|
63
|
+
|
64
|
+
Tip: Do not attempt to translate the original element titles when generating JSON.
|
65
|
+
"""
|
66
|
+
|
67
|
+
description: str
|
68
|
+
"""Algorithm description with technical focus descriptor:
|
69
|
+
- Includes input/output specifications.
|
70
|
+
- Describes key steps and their purpose.
|
71
|
+
- Explains its role in the research workflow.
|
72
|
+
Example: "Proposed algorithm for neural architecture search. Inputs include search space constraints and training data. Outputs optimized architecture."
|
73
|
+
"""
|
74
|
+
|
75
|
+
|
76
|
+
class Table(BaseModel):
|
77
|
+
"""Table specification for research contributions."""
|
78
|
+
|
79
|
+
title: str
|
80
|
+
"""Table title with technical focus descriptor (e.g., 'Comparison of Model Performance Metrics').
|
81
|
+
|
82
|
+
Tip: Do not attempt to translate the original element titles when generating JSON.
|
83
|
+
"""
|
84
|
+
|
85
|
+
description: str
|
86
|
+
"""Table description with technical focus descriptor:
|
87
|
+
- Includes data source and structure.
|
88
|
+
- Explains key columns/rows and their significance.
|
89
|
+
- Connects to research findings or hypotheses.
|
90
|
+
Example: "Performance metrics for different architectures. Columns represent accuracy, F1-score, and inference time. Highlights efficiency gains of proposed method."
|
91
|
+
"""
|
92
|
+
|
93
|
+
|
94
|
+
class Highlightings(BaseModel):
|
95
|
+
"""Technical showcase aggregator for research artifacts.
|
96
|
+
|
97
|
+
Curates core scientific components with machine-parseable annotations.
|
98
|
+
"""
|
99
|
+
|
100
|
+
highlighted_equations: List[Equation]
|
101
|
+
"""3-5 pivotal equations representing theoretical contributions:
|
102
|
+
- Each equation must be wrapped in $$ for display math.
|
103
|
+
- Contain at least one novel operator/symbol.
|
104
|
+
- Be referenced in Methods/Results sections.
|
105
|
+
Example: Equation describing proposed loss function.
|
106
|
+
"""
|
107
|
+
|
108
|
+
highlighted_algorithms: List[Algorithm]
|
109
|
+
"""1-2 key algorithms demonstrating methodological contributions:
|
110
|
+
- Include pseudocode or step-by-step descriptions.
|
111
|
+
- Highlight innovation in computational approach.
|
112
|
+
Example: Algorithm for constrained search space exploration.
|
113
|
+
|
114
|
+
Tip: Do not attempt to translate the original element titles when generating JSON.
|
115
|
+
"""
|
116
|
+
|
117
|
+
highlighted_figures: List[Figure]
|
118
|
+
"""4-6 key figures demonstrating:
|
119
|
+
1. Framework overview (1 required).
|
120
|
+
2. Quantitative results (2-3 required).
|
121
|
+
3. Ablation studies (1 optional).
|
122
|
+
Each must appear in Results/Discussion chapters.
|
123
|
+
Example: Figure showing architecture topology and convergence curves.
|
124
|
+
"""
|
125
|
+
|
126
|
+
highlighted_tables: List[Table]
|
127
|
+
"""2-3 key tables summarizing:
|
128
|
+
- Comparative analysis of methods.
|
129
|
+
- Empirical results supporting claims.
|
130
|
+
Example: Table comparing model performance across datasets.
|
131
|
+
|
132
|
+
Tip: Do not attempt to translate the original element titles when generating JSON.
|
133
|
+
"""
|
134
|
+
|
135
|
+
|
136
|
+
class ArticleEssence(ProposedAble, Display, PrepareVectorization):
|
137
|
+
"""Semantic fingerprint of academic paper for structured analysis.
|
138
|
+
|
139
|
+
Encodes research artifacts with dual human-machine interpretability.
|
140
|
+
"""
|
141
|
+
|
142
|
+
title: str = Field(...)
|
143
|
+
"""Exact title of the original article without any modification.
|
144
|
+
Must be preserved precisely from the source material without:
|
145
|
+
- Translation
|
146
|
+
- Paraphrasing
|
147
|
+
- Adding/removing words
|
148
|
+
- Altering style or formatting
|
149
|
+
"""
|
150
|
+
|
151
|
+
authors: List[str]
|
152
|
+
"""Original author names exactly as they appear in the source document. No translation or paraphrasing.
|
153
|
+
Extract complete list without any modifications or formatting changes."""
|
154
|
+
|
155
|
+
keywords: List[str]
|
156
|
+
"""Original keywords exactly as they appear in the source document. No translation or paraphrasing.
|
157
|
+
Extract the complete set without modifying format or terminology."""
|
158
|
+
|
159
|
+
publication_year: int
|
160
|
+
"""Publication timestamp in ISO 8601 (YYYY format)."""
|
161
|
+
|
162
|
+
highlightings: Highlightings
|
163
|
+
"""Technical highlight reel containing:
|
164
|
+
- Core equations (Theory)
|
165
|
+
- Key algorithms (Implementation)
|
166
|
+
- Critical figures (Results)
|
167
|
+
- Benchmark tables (Evaluation)"""
|
168
|
+
|
169
|
+
domain: List[str]
|
170
|
+
"""Domain tags for research focus."""
|
171
|
+
|
172
|
+
abstract: str = Field(...)
|
173
|
+
"""Three-paragraph structured abstract:
|
174
|
+
Paragraph 1: Problem & Motivation (2-3 sentences)
|
175
|
+
Paragraph 2: Methodology & Innovations (3-4 sentences)
|
176
|
+
Paragraph 3: Results & Impact (2-3 sentences)
|
177
|
+
Total length: 150-250 words"""
|
178
|
+
|
179
|
+
core_contributions: List[str]
|
180
|
+
"""3-5 technical contributions using CRediT taxonomy verbs.
|
181
|
+
Each item starts with action verb.
|
182
|
+
Example:
|
183
|
+
- 'Developed constrained NAS framework'
|
184
|
+
- 'Established cross-lingual transfer metrics'"""
|
185
|
+
|
186
|
+
technical_novelty: List[str]
|
187
|
+
"""Patent-style claims with technical specificity.
|
188
|
+
Format: 'A [system/method] comprising [novel components]...'
|
189
|
+
Example:
|
190
|
+
'A neural architecture search system comprising:
|
191
|
+
a differentiable constrained search space;
|
192
|
+
multi-lingual transferability predictors...'"""
|
193
|
+
|
194
|
+
research_problems: List[str]
|
195
|
+
"""Problem statements as how/why questions.
|
196
|
+
Example:
|
197
|
+
- 'How to reduce NAS computational overhead while maintaining search diversity?'
|
198
|
+
- 'Why do existing architectures fail in low-resource cross-lingual transfer?'"""
|
199
|
+
|
200
|
+
limitations: List[str]
|
201
|
+
"""Technical limitations analysis containing:
|
202
|
+
1. Constraint source (data/method/theory)
|
203
|
+
2. Impact quantification
|
204
|
+
3. Mitigation pathway
|
205
|
+
Example:
|
206
|
+
'Methodology constraint: Single-objective optimization (affects 5% edge cases),
|
207
|
+
mitigated through future multi-task extension'"""
|
208
|
+
|
209
|
+
future_work: List[str]
|
210
|
+
"""Research roadmap items with 3 horizons:
|
211
|
+
1. Immediate extensions (1 year)
|
212
|
+
2. Mid-term directions (2-3 years)
|
213
|
+
3. Long-term vision (5+ years)
|
214
|
+
Example:
|
215
|
+
'Short-term: Adapt framework for vision transformers (ongoing with CVPR submission)'"""
|
216
|
+
|
217
|
+
impact_analysis: List[str]
|
218
|
+
"""Bibliometric impact projections:
|
219
|
+
- Expected citation counts (next 3 years)
|
220
|
+
- Target application domains
|
221
|
+
- Standard adoption potential
|
222
|
+
Example:
|
223
|
+
'Predicted 150+ citations via integration into MMEngine (Alibaba OpenMMLab)'"""
|
224
|
+
|
225
|
+
def _prepare_vectorization_inner(self) -> str:
|
226
|
+
return self.model_dump_json()
|
@@ -0,0 +1,359 @@
|
|
1
|
+
"""ArticleBase and ArticleSubsection classes for managing hierarchical document components."""
|
2
|
+
|
3
|
+
from abc import abstractmethod
|
4
|
+
from itertools import chain
|
5
|
+
from typing import Generator, List, Self, Tuple, final
|
6
|
+
|
7
|
+
from fabricatio.models.extra.article_outline import ArticleOutline, ArticleOutlineBase, ArticleRef
|
8
|
+
from fabricatio.models.generic import CensoredAble, Display, PersistentAble, WithRef
|
9
|
+
from fabricatio.models.utils import ok
|
10
|
+
from loguru import logger
|
11
|
+
|
12
|
+
|
13
|
+
class Paragraph(CensoredAble):
|
14
|
+
"""Structured academic paragraph blueprint for controlled content generation."""
|
15
|
+
|
16
|
+
description: str
|
17
|
+
"""Functional summary of the paragraph's role in document structure."""
|
18
|
+
|
19
|
+
writing_aim: List[str]
|
20
|
+
"""Specific communicative objectives for this paragraph's content."""
|
21
|
+
|
22
|
+
sentences: List[str]
|
23
|
+
"""List of sentences forming the paragraph's content."""
|
24
|
+
|
25
|
+
|
26
|
+
class ArticleBase(CensoredAble, Display, ArticleOutlineBase, PersistentAble):
|
27
|
+
"""Foundation for hierarchical document components with dependency tracking."""
|
28
|
+
|
29
|
+
@abstractmethod
|
30
|
+
def to_typst_code(self) -> str:
|
31
|
+
"""Converts the component into a Typst code snippet for rendering."""
|
32
|
+
|
33
|
+
def _update_pre_check(self, other: Self) -> Self:
|
34
|
+
if not isinstance(other, self.__class__):
|
35
|
+
raise TypeError(f"Cannot update from a non-{self.__class__} instance.")
|
36
|
+
if self.title != other.title:
|
37
|
+
raise ValueError("Cannot update from a different title.")
|
38
|
+
return self
|
39
|
+
|
40
|
+
@abstractmethod
|
41
|
+
def resolve_update_error(self, other: Self) -> str:
|
42
|
+
"""Resolve update errors in the article outline.
|
43
|
+
|
44
|
+
Returns:
|
45
|
+
str: Error message indicating update errors in the article outline.
|
46
|
+
"""
|
47
|
+
|
48
|
+
@abstractmethod
|
49
|
+
def _update_from_inner(self, other: Self) -> Self:
|
50
|
+
"""Updates the current instance with the attributes of another instance."""
|
51
|
+
|
52
|
+
@final
|
53
|
+
def update_from(self, other: Self) -> Self:
|
54
|
+
"""Updates the current instance with the attributes of another instance."""
|
55
|
+
return self._update_pre_check(other)._update_from_inner(other)
|
56
|
+
|
57
|
+
def __eq__(self, other: "ArticleBase") -> bool:
|
58
|
+
"""Compares two ArticleBase objects based on their model_dump_json representation."""
|
59
|
+
return self.model_dump_json() == other.model_dump_json()
|
60
|
+
|
61
|
+
def __hash__(self) -> int:
|
62
|
+
"""Calculates a hash value for the ArticleBase object based on its model_dump_json representation."""
|
63
|
+
return hash(self.model_dump_json())
|
64
|
+
|
65
|
+
|
66
|
+
class ArticleSubsection(ArticleBase):
|
67
|
+
"""Atomic argumentative unit with technical specificity."""
|
68
|
+
|
69
|
+
paragraphs: List[Paragraph]
|
70
|
+
"""List of Paragraph objects containing the content of the subsection."""
|
71
|
+
|
72
|
+
def resolve_update_error(self, other: Self) -> str:
|
73
|
+
"""Resolve update errors in the article outline."""
|
74
|
+
if self.title != other.title:
|
75
|
+
return f"Title `{other.title}` mismatched, expected `{self.title}`. "
|
76
|
+
return ""
|
77
|
+
|
78
|
+
def _update_from_inner(self, other: Self) -> Self:
|
79
|
+
"""Updates the current instance with the attributes of another instance."""
|
80
|
+
logger.debug(f"Updating SubSection {self.title}")
|
81
|
+
self.paragraphs = other.paragraphs
|
82
|
+
return self
|
83
|
+
|
84
|
+
def to_typst_code(self) -> str:
|
85
|
+
"""Converts the component into a Typst code snippet for rendering.
|
86
|
+
|
87
|
+
Returns:
|
88
|
+
str: Typst code snippet for rendering.
|
89
|
+
"""
|
90
|
+
return f"=== {self.title}\n" + "\n\n".join("".join(p.sentences) for p in self.paragraphs)
|
91
|
+
|
92
|
+
|
93
|
+
class ArticleSection(ArticleBase):
|
94
|
+
"""Atomic argumentative unit with high-level specificity."""
|
95
|
+
|
96
|
+
subsections: List[ArticleSubsection]
|
97
|
+
"""List of ArticleSubsection objects containing the content of the section."""
|
98
|
+
|
99
|
+
def resolve_update_error(self, other: Self) -> str:
|
100
|
+
"""Resolve update errors in the article outline."""
|
101
|
+
if (s_len := len(self.subsections)) == 0:
|
102
|
+
return ""
|
103
|
+
|
104
|
+
if s_len != len(other.subsections):
|
105
|
+
return f"Subsections length mismatched, expected {len(self.subsections)}, got {len(other.subsections)}"
|
106
|
+
|
107
|
+
sub_sec_err_seq = [
|
108
|
+
out for s, o in zip(self.subsections, other.subsections, strict=True) if (out := s.resolve_update_error(o))
|
109
|
+
]
|
110
|
+
|
111
|
+
if sub_sec_err_seq:
|
112
|
+
return "\n".join(sub_sec_err_seq)
|
113
|
+
return ""
|
114
|
+
|
115
|
+
def _update_from_inner(self, other: Self) -> Self:
|
116
|
+
"""Updates the current instance with the attributes of another instance."""
|
117
|
+
if len(self.subsections) == 0:
|
118
|
+
self.subsections = other.subsections
|
119
|
+
return self
|
120
|
+
|
121
|
+
for self_subsec, other_subsec in zip(self.subsections, other.subsections, strict=True):
|
122
|
+
self_subsec.update_from(other_subsec)
|
123
|
+
return self
|
124
|
+
|
125
|
+
def to_typst_code(self) -> str:
|
126
|
+
"""Converts the section into a Typst formatted code snippet.
|
127
|
+
|
128
|
+
Returns:
|
129
|
+
str: The formatted Typst code snippet.
|
130
|
+
"""
|
131
|
+
return f"== {self.title}\n" + "\n\n".join(subsec.to_typst_code() for subsec in self.subsections)
|
132
|
+
|
133
|
+
|
134
|
+
class ArticleChapter(ArticleBase):
|
135
|
+
"""Thematic progression implementing research function."""
|
136
|
+
|
137
|
+
sections: List[ArticleSection]
|
138
|
+
"""List of ArticleSection objects containing the content of the chapter."""
|
139
|
+
|
140
|
+
def resolve_update_error(self, other: Self) -> str:
|
141
|
+
"""Resolve update errors in the article outline."""
|
142
|
+
if (s_len := len(self.sections)) == 0:
|
143
|
+
return ""
|
144
|
+
|
145
|
+
if s_len != len(other.sections):
|
146
|
+
return f"Sections length mismatched, expected {len(self.sections)}, got {len(other.sections)}"
|
147
|
+
sec_err_seq = [
|
148
|
+
out for s, o in zip(self.sections, other.sections, strict=True) if (out := s.resolve_update_error(o))
|
149
|
+
]
|
150
|
+
if sec_err_seq:
|
151
|
+
return "\n".join(sec_err_seq)
|
152
|
+
return ""
|
153
|
+
|
154
|
+
def _update_from_inner(self, other: Self) -> Self:
|
155
|
+
"""Updates the current instance with the attributes of another instance."""
|
156
|
+
if len(self.sections) == 0:
|
157
|
+
self.sections = other.sections
|
158
|
+
return self
|
159
|
+
|
160
|
+
for self_sec, other_sec in zip(self.sections, other.sections, strict=True):
|
161
|
+
self_sec.update_from(other_sec)
|
162
|
+
return self
|
163
|
+
|
164
|
+
def to_typst_code(self) -> str:
|
165
|
+
"""Converts the chapter into a Typst formatted code snippet for rendering."""
|
166
|
+
return f"= {self.title}\n" + "\n\n".join(sec.to_typst_code() for sec in self.sections)
|
167
|
+
|
168
|
+
|
169
|
+
class Article(Display, CensoredAble, WithRef[ArticleOutline], PersistentAble):
|
170
|
+
"""Represents a complete academic paper specification, incorporating validation constraints.
|
171
|
+
|
172
|
+
This class integrates display, censorship processing, article structure referencing, and persistence capabilities,
|
173
|
+
aiming to provide a comprehensive model for academic papers.
|
174
|
+
"""
|
175
|
+
|
176
|
+
article_language: str
|
177
|
+
"""Written language of the article. SHALL be aligned to the language of the article outline provided."""
|
178
|
+
|
179
|
+
title: str
|
180
|
+
"""Represents the title of the academic paper."""
|
181
|
+
|
182
|
+
abstract: str
|
183
|
+
"""Contains a summary of the academic paper."""
|
184
|
+
|
185
|
+
chapters: List[ArticleChapter]
|
186
|
+
"""Contains a list of chapters in the academic paper, each chapter is an ArticleChapter object."""
|
187
|
+
|
188
|
+
def finalized_dump(self) -> str:
|
189
|
+
"""Exports the article in `typst` format.
|
190
|
+
|
191
|
+
Returns:
|
192
|
+
str: Strictly formatted outline with typst formatting.
|
193
|
+
"""
|
194
|
+
return "\n\n".join(c.to_typst_code() for c in self.chapters)
|
195
|
+
|
196
|
+
@classmethod
|
197
|
+
def from_outline(cls, outline: ArticleOutline) -> "Article":
|
198
|
+
"""Generates an article from the given outline.
|
199
|
+
|
200
|
+
Args:
|
201
|
+
outline (ArticleOutline): The outline to generate the article from.
|
202
|
+
|
203
|
+
Returns:
|
204
|
+
Article: The generated article.
|
205
|
+
"""
|
206
|
+
# Set the title from the outline
|
207
|
+
article = Article(**outline.model_dump(include={"title", "abstract"}), chapters=[])
|
208
|
+
|
209
|
+
for chapter in outline.chapters:
|
210
|
+
# Create a new chapter
|
211
|
+
article_chapter = ArticleChapter(
|
212
|
+
sections=[],
|
213
|
+
**chapter.model_dump(exclude={"sections"}),
|
214
|
+
)
|
215
|
+
for section in chapter.sections:
|
216
|
+
# Create a new section
|
217
|
+
article_section = ArticleSection(
|
218
|
+
subsections=[],
|
219
|
+
**section.model_dump(exclude={"subsections"}),
|
220
|
+
)
|
221
|
+
for subsection in section.subsections:
|
222
|
+
# Create a new subsection
|
223
|
+
article_subsection = ArticleSubsection(
|
224
|
+
paragraphs=[],
|
225
|
+
**subsection.model_dump(),
|
226
|
+
)
|
227
|
+
article_section.subsections.append(article_subsection)
|
228
|
+
article_chapter.sections.append(article_section)
|
229
|
+
article.chapters.append(article_chapter)
|
230
|
+
return article
|
231
|
+
|
232
|
+
def chap_iter(self) -> Generator[ArticleChapter, None, None]:
|
233
|
+
"""Iterates over all chapters in the article.
|
234
|
+
|
235
|
+
Yields:
|
236
|
+
ArticleChapter: Each chapter in the article.
|
237
|
+
"""
|
238
|
+
yield from self.chapters
|
239
|
+
|
240
|
+
def section_iter(self) -> Generator[ArticleSection, None, None]:
|
241
|
+
"""Iterates over all sections in the article.
|
242
|
+
|
243
|
+
Yields:
|
244
|
+
ArticleSection: Each section in the article.
|
245
|
+
"""
|
246
|
+
for chap in self.chapters:
|
247
|
+
yield from chap.sections
|
248
|
+
|
249
|
+
def subsection_iter(self) -> Generator[ArticleSubsection, None, None]:
|
250
|
+
"""Iterates over all subsections in the article.
|
251
|
+
|
252
|
+
Yields:
|
253
|
+
ArticleSubsection: Each subsection in the article.
|
254
|
+
"""
|
255
|
+
for sec in self.section_iter():
|
256
|
+
yield from sec.subsections
|
257
|
+
|
258
|
+
def iter_dfs(self) -> Generator[ArticleBase, None, None]:
|
259
|
+
"""Performs a depth-first search (DFS) through the article structure.
|
260
|
+
|
261
|
+
Returns:
|
262
|
+
Generator[ArticleBase]: Each component in the article structure.
|
263
|
+
"""
|
264
|
+
for chap in self.chap_iter():
|
265
|
+
for sec in chap.sections:
|
266
|
+
yield from sec.subsections
|
267
|
+
yield sec
|
268
|
+
yield chap
|
269
|
+
|
270
|
+
def deref(self, ref: ArticleRef) -> ArticleBase:
|
271
|
+
"""Resolves a reference to the corresponding section or subsection in the article.
|
272
|
+
|
273
|
+
Args:
|
274
|
+
ref (ArticleRef): The reference to resolve.
|
275
|
+
|
276
|
+
Returns:
|
277
|
+
ArticleBase: The corresponding section or subsection.
|
278
|
+
"""
|
279
|
+
return ok(ref.deref(self), f"{ref} not found in {self.title}")
|
280
|
+
|
281
|
+
def gather_dependencies(self, article: ArticleBase) -> List[ArticleBase]:
|
282
|
+
"""Gathers dependencies for all sections and subsections in the article.
|
283
|
+
|
284
|
+
This method should be called after the article is fully constructed.
|
285
|
+
"""
|
286
|
+
depends = [self.deref(a) for a in article.depend_on]
|
287
|
+
|
288
|
+
supports = []
|
289
|
+
for a in self.iter_dfs():
|
290
|
+
if article in {self.deref(b) for b in a.support_to}:
|
291
|
+
supports.append(a)
|
292
|
+
|
293
|
+
return list(set(depends + supports))
|
294
|
+
|
295
|
+
def gather_dependencies_recursive(self, article: ArticleBase) -> List[ArticleBase]:
|
296
|
+
"""Gathers all dependencies recursively for the given article.
|
297
|
+
|
298
|
+
Args:
|
299
|
+
article (ArticleBase): The article to gather dependencies for.
|
300
|
+
|
301
|
+
Returns:
|
302
|
+
List[ArticleBase]: A list of all dependencies for the given article.
|
303
|
+
"""
|
304
|
+
q = self.gather_dependencies(article)
|
305
|
+
|
306
|
+
deps = []
|
307
|
+
while q:
|
308
|
+
a = q.pop()
|
309
|
+
deps.extend(self.gather_dependencies(a))
|
310
|
+
|
311
|
+
deps = list(
|
312
|
+
chain(
|
313
|
+
filter(lambda x: isinstance(x, ArticleChapter), deps),
|
314
|
+
filter(lambda x: isinstance(x, ArticleSection), deps),
|
315
|
+
filter(lambda x: isinstance(x, ArticleSubsection), deps),
|
316
|
+
)
|
317
|
+
)
|
318
|
+
|
319
|
+
# Initialize result containers
|
320
|
+
formatted_code = ""
|
321
|
+
processed_components = []
|
322
|
+
|
323
|
+
# Process all dependencies
|
324
|
+
while deps:
|
325
|
+
component = deps.pop()
|
326
|
+
# Skip duplicates
|
327
|
+
if (component_code := component.to_typst_code()) in formatted_code:
|
328
|
+
continue
|
329
|
+
|
330
|
+
# Add this component
|
331
|
+
formatted_code += component_code
|
332
|
+
processed_components.append(component)
|
333
|
+
|
334
|
+
return processed_components
|
335
|
+
|
336
|
+
def iter_dfs_with_deps(
|
337
|
+
self, chapter: bool = True, section: bool = True, subsection: bool = True
|
338
|
+
) -> Generator[Tuple[ArticleBase, List[ArticleBase]], None, None]:
|
339
|
+
"""Iterates through the article in a depth-first manner, yielding each component and its dependencies.
|
340
|
+
|
341
|
+
Args:
|
342
|
+
chapter (bool, optional): Whether to include chapter components. Defaults to True.
|
343
|
+
section (bool, optional): Whether to include section components. Defaults to True.
|
344
|
+
subsection (bool, optional): Whether to include subsection components. Defaults to True.
|
345
|
+
|
346
|
+
Yields:
|
347
|
+
Tuple[ArticleBase, List[ArticleBase]]: Each component and its dependencies.
|
348
|
+
"""
|
349
|
+
if all((not chapter, not section, not subsection)):
|
350
|
+
raise ValueError("At least one of chapter, section, or subsection must be True.")
|
351
|
+
|
352
|
+
for component in self.iter_dfs():
|
353
|
+
if not chapter and isinstance(component, ArticleChapter):
|
354
|
+
continue
|
355
|
+
if not section and isinstance(component, ArticleSection):
|
356
|
+
continue
|
357
|
+
if not subsection and isinstance(component, ArticleSubsection):
|
358
|
+
continue
|
359
|
+
yield component, (self.gather_dependencies_recursive(component))
|