fabricatio 0.2.7.dev3__cp312-cp312-win_amd64.whl → 0.2.7.dev5__cp312-cp312-win_amd64.whl
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/_rust.cp312-win_amd64.pyd +0 -0
- fabricatio/actions/article.py +26 -19
- fabricatio/models/extra/article_base.py +291 -0
- fabricatio/models/extra/article_main.py +45 -174
- fabricatio/models/extra/article_outline.py +52 -141
- fabricatio/models/extra/article_proposal.py +12 -14
- fabricatio/models/generic.py +79 -6
- fabricatio-0.2.7.dev5.data/scripts/tdown.exe +0 -0
- fabricatio-0.2.7.dev5.dist-info/METADATA +181 -0
- {fabricatio-0.2.7.dev3.dist-info → fabricatio-0.2.7.dev5.dist-info}/RECORD +12 -11
- fabricatio-0.2.7.dev3.data/scripts/tdown.exe +0 -0
- fabricatio-0.2.7.dev3.dist-info/METADATA +0 -436
- {fabricatio-0.2.7.dev3.dist-info → fabricatio-0.2.7.dev5.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.7.dev3.dist-info → fabricatio-0.2.7.dev5.dist-info}/licenses/LICENSE +0 -0
@@ -1,13 +1,22 @@
|
|
1
1
|
"""ArticleBase and ArticleSubsection classes for managing hierarchical document components."""
|
2
2
|
|
3
|
-
from abc import abstractmethod
|
4
3
|
from itertools import chain
|
5
|
-
from typing import Generator, List, Self, Tuple,
|
6
|
-
|
7
|
-
from fabricatio.
|
4
|
+
from typing import Generator, List, Self, Tuple, override
|
5
|
+
|
6
|
+
from fabricatio.journal import logger
|
7
|
+
from fabricatio.models.extra.article_base import (
|
8
|
+
ArticleBase,
|
9
|
+
ArticleOutlineBase,
|
10
|
+
ArticleRef,
|
11
|
+
ChapterBase,
|
12
|
+
SectionBase,
|
13
|
+
SubSectionBase,
|
14
|
+
)
|
15
|
+
from fabricatio.models.extra.article_outline import (
|
16
|
+
ArticleOutline,
|
17
|
+
)
|
8
18
|
from fabricatio.models.generic import CensoredAble, Display, PersistentAble, WithRef
|
9
19
|
from fabricatio.models.utils import ok
|
10
|
-
from loguru import logger
|
11
20
|
|
12
21
|
|
13
22
|
class Paragraph(CensoredAble):
|
@@ -23,62 +32,19 @@ class Paragraph(CensoredAble):
|
|
23
32
|
"""List of sentences forming the paragraph's content."""
|
24
33
|
|
25
34
|
|
26
|
-
class
|
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):
|
35
|
+
class ArticleSubsection(ArticleOutlineBase, SubSectionBase):
|
67
36
|
"""Atomic argumentative unit with technical specificity."""
|
68
37
|
|
69
38
|
paragraphs: List[Paragraph]
|
70
39
|
"""List of Paragraph objects containing the content of the subsection."""
|
71
40
|
|
72
|
-
def
|
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:
|
41
|
+
def update_from_inner(self, other: Self) -> Self:
|
79
42
|
"""Updates the current instance with the attributes of another instance."""
|
80
43
|
logger.debug(f"Updating SubSection {self.title}")
|
81
|
-
self
|
44
|
+
SubSectionBase.update_from(self, other)
|
45
|
+
ArticleOutlineBase.update_from(self, other)
|
46
|
+
self.paragraphs.clear()
|
47
|
+
self.paragraphs.extend(other.paragraphs)
|
82
48
|
return self
|
83
49
|
|
84
50
|
def to_typst_code(self) -> str:
|
@@ -90,100 +56,37 @@ class ArticleSubsection(ArticleBase):
|
|
90
56
|
return f"=== {self.title}\n" + "\n\n".join("".join(p.sentences) for p in self.paragraphs)
|
91
57
|
|
92
58
|
|
93
|
-
class ArticleSection(
|
59
|
+
class ArticleSection(ArticleOutlineBase, SectionBase[ArticleSubsection]):
|
94
60
|
"""Atomic argumentative unit with high-level specificity."""
|
95
61
|
|
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
62
|
|
133
63
|
|
134
|
-
class ArticleChapter(
|
64
|
+
class ArticleChapter(ArticleOutlineBase, ChapterBase[ArticleSection]):
|
135
65
|
"""Thematic progression implementing research function."""
|
136
66
|
|
137
|
-
sections: List[ArticleSection]
|
138
|
-
"""List of ArticleSection objects containing the content of the chapter."""
|
139
67
|
|
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
68
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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):
|
69
|
+
class Article(
|
70
|
+
Display,
|
71
|
+
CensoredAble,
|
72
|
+
WithRef[ArticleOutline],
|
73
|
+
PersistentAble,
|
74
|
+
ArticleBase[ArticleChapter],
|
75
|
+
):
|
170
76
|
"""Represents a complete academic paper specification, incorporating validation constraints.
|
171
77
|
|
172
78
|
This class integrates display, censorship processing, article structure referencing, and persistence capabilities,
|
173
79
|
aiming to provide a comprehensive model for academic papers.
|
174
80
|
"""
|
175
81
|
|
176
|
-
|
177
|
-
"""
|
82
|
+
abstract: str
|
83
|
+
"""Contains a summary of the academic paper."""
|
178
84
|
|
179
85
|
title: str
|
180
86
|
"""Represents the title of the academic paper."""
|
181
87
|
|
182
|
-
|
183
|
-
"""
|
184
|
-
|
185
|
-
chapters: List[ArticleChapter]
|
186
|
-
"""Contains a list of chapters in the academic paper, each chapter is an ArticleChapter object."""
|
88
|
+
language: str
|
89
|
+
"""Written language of the article. SHALL be aligned to the language of the article outline provided."""
|
187
90
|
|
188
91
|
def finalized_dump(self) -> str:
|
189
92
|
"""Exports the article in `typst` format.
|
@@ -229,56 +132,24 @@ class Article(Display, CensoredAble, WithRef[ArticleOutline], PersistentAble):
|
|
229
132
|
article.chapters.append(article_chapter)
|
230
133
|
return article
|
231
134
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
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:
|
135
|
+
@override
|
136
|
+
def iter_dfs(
|
137
|
+
self,
|
138
|
+
) -> Generator[ArticleChapter | ArticleSection | ArticleSubsection, None, None]:
|
139
|
+
return super().iter_dfs()
|
140
|
+
|
141
|
+
def deref(self, ref: ArticleRef) -> ArticleOutlineBase:
|
271
142
|
"""Resolves a reference to the corresponding section or subsection in the article.
|
272
143
|
|
273
144
|
Args:
|
274
145
|
ref (ArticleRef): The reference to resolve.
|
275
146
|
|
276
147
|
Returns:
|
277
|
-
|
148
|
+
ArticleOutlineBase: The corresponding section or subsection.
|
278
149
|
"""
|
279
150
|
return ok(ref.deref(self), f"{ref} not found in {self.title}")
|
280
151
|
|
281
|
-
def gather_dependencies(self, article:
|
152
|
+
def gather_dependencies(self, article: ArticleOutlineBase) -> List[ArticleOutlineBase]:
|
282
153
|
"""Gathers dependencies for all sections and subsections in the article.
|
283
154
|
|
284
155
|
This method should be called after the article is fully constructed.
|
@@ -292,11 +163,11 @@ class Article(Display, CensoredAble, WithRef[ArticleOutline], PersistentAble):
|
|
292
163
|
|
293
164
|
return list(set(depends + supports))
|
294
165
|
|
295
|
-
def gather_dependencies_recursive(self, article:
|
166
|
+
def gather_dependencies_recursive(self, article: ArticleOutlineBase) -> List[ArticleOutlineBase]:
|
296
167
|
"""Gathers all dependencies recursively for the given article.
|
297
168
|
|
298
169
|
Args:
|
299
|
-
article (
|
170
|
+
article (ArticleOutlineBase): The article to gather dependencies for.
|
300
171
|
|
301
172
|
Returns:
|
302
173
|
List[ArticleBase]: A list of all dependencies for the given article.
|
@@ -335,7 +206,7 @@ class Article(Display, CensoredAble, WithRef[ArticleOutline], PersistentAble):
|
|
335
206
|
|
336
207
|
def iter_dfs_with_deps(
|
337
208
|
self, chapter: bool = True, section: bool = True, subsection: bool = True
|
338
|
-
) -> Generator[Tuple[
|
209
|
+
) -> Generator[Tuple[ArticleOutlineBase, List[ArticleOutlineBase]], None, None]:
|
339
210
|
"""Iterates through the article in a depth-first manner, yielding each component and its dependencies.
|
340
211
|
|
341
212
|
Args:
|
@@ -1,134 +1,57 @@
|
|
1
1
|
"""A module containing the ArticleOutline class, which represents the outline of an academic paper."""
|
2
2
|
|
3
|
-
from
|
4
|
-
from typing import TYPE_CHECKING, Generator, List, Optional, Tuple, Union, overload
|
3
|
+
from typing import Generator, List, Optional, Self, Tuple, Union, override
|
5
4
|
|
6
5
|
import regex
|
6
|
+
from fabricatio.models.extra.article_base import (
|
7
|
+
ArticleBase,
|
8
|
+
ArticleOutlineBase,
|
9
|
+
ChapterBase,
|
10
|
+
SectionBase,
|
11
|
+
SubSectionBase,
|
12
|
+
)
|
7
13
|
from fabricatio.models.extra.article_proposal import ArticleProposal
|
8
|
-
from fabricatio.models.generic import
|
14
|
+
from fabricatio.models.generic import CensoredAble, Display, PersistentAble, WithRef
|
9
15
|
from fabricatio.models.utils import ok
|
10
|
-
from pydantic import Field
|
11
16
|
|
12
|
-
if TYPE_CHECKING:
|
13
|
-
from fabricatio.models.extra.article_main import Article, ArticleBase
|
14
17
|
|
15
|
-
|
16
|
-
class ReferringType(str, Enum):
|
17
|
-
"""Enumeration of different types of references that can be made in an article."""
|
18
|
-
|
19
|
-
CHAPTER: str = "chapter"
|
20
|
-
SECTION: str = "section"
|
21
|
-
SUBSECTION: str = "subsection"
|
22
|
-
|
23
|
-
|
24
|
-
class ArticleRef(CensoredAble):
|
25
|
-
"""Reference to a specific chapter, section or subsection within the article. You SHALL not refer to an article component that is external and not present within our own article."""
|
26
|
-
|
27
|
-
referred_chapter_title: str
|
28
|
-
"""`title` Field of the referenced chapter"""
|
29
|
-
|
30
|
-
referred_section_title: Optional[str] = None
|
31
|
-
"""`title` Field of the referenced section. Defaults to None if not applicable, which means the reference is pointing to the entire chapter."""
|
32
|
-
|
33
|
-
referred_subsection_title: Optional[str] = None
|
34
|
-
"""`title` Field of the referenced subsection. Defaults to None if not applicable, which means the reference is pointing to the entire section."""
|
35
|
-
|
36
|
-
def __hash__(self) -> int:
|
37
|
-
"""Overrides the default hash function to ensure consistent hashing across instances."""
|
38
|
-
return hash((self.referred_chapter_title, self.referred_section_title, self.referred_subsection_title))
|
39
|
-
|
40
|
-
@overload
|
41
|
-
def deref(self, article: "Article") -> Optional["ArticleBase"]:
|
42
|
-
"""Dereference the reference to the actual section or subsection within the provided article."""
|
43
|
-
|
44
|
-
@overload
|
45
|
-
def deref(self, article: "ArticleOutline") -> Optional["ArticleOutlineBase"]:
|
46
|
-
"""Dereference the reference to the actual section or subsection within the provided article."""
|
47
|
-
|
48
|
-
def deref(self, article: Union["ArticleOutline", "Article"]) -> Union["ArticleOutlineBase", "ArticleBase", None]:
|
49
|
-
"""Dereference the reference to the actual section or subsection within the provided article.
|
50
|
-
|
51
|
-
Args:
|
52
|
-
article (ArticleOutline | Article): The article to dereference the reference from.
|
53
|
-
|
54
|
-
Returns:
|
55
|
-
ArticleBase | ArticleOutline | None: The dereferenced section or subsection, or None if not found.
|
56
|
-
"""
|
57
|
-
chap = next((chap for chap in article.chapters if chap.title == self.referred_chapter_title), None)
|
58
|
-
if self.referred_section_title is None or chap is None:
|
59
|
-
return chap
|
60
|
-
sec = next((sec for sec in chap.sections if sec.title == self.referred_section_title), None)
|
61
|
-
if self.referred_subsection_title is None or sec is None:
|
62
|
-
return sec
|
63
|
-
return next((subsec for subsec in sec.subsections if subsec.title == self.referred_subsection_title), None)
|
64
|
-
|
65
|
-
@property
|
66
|
-
def referring_type(self) -> ReferringType:
|
67
|
-
"""Determine the type of reference based on the presence of specific attributes."""
|
68
|
-
if self.referred_subsection_title is not None:
|
69
|
-
return ReferringType.SUBSECTION
|
70
|
-
if self.referred_section_title is not None:
|
71
|
-
return ReferringType.SECTION
|
72
|
-
return ReferringType.CHAPTER
|
73
|
-
|
74
|
-
|
75
|
-
class ArticleOutlineBase(Base):
|
76
|
-
"""Base class for article outlines."""
|
77
|
-
|
78
|
-
writing_aim: List[str]
|
79
|
-
"""Required: List of specific rhetorical objectives (3-5 items).
|
80
|
-
Format: Each item must be an actionable phrase starting with a verb.
|
81
|
-
Example: ['Establish metric validity', 'Compare with baseline approaches',
|
82
|
-
'Justify threshold selection']"""
|
83
|
-
depend_on: List[ArticleRef]
|
84
|
-
"""Required: List of all essential ArticleRef objects identifying components this section builds upon.
|
85
|
-
Format: Each reference must point to a previously defined chapter, section, or subsection.
|
86
|
-
Note: Circular dependencies are not permitted."""
|
87
|
-
support_to: List[ArticleRef]
|
88
|
-
"""Required: List of all essential ArticleRef objects identifying components this section provides evidence for.
|
89
|
-
Format: Each reference must point to a specific chapter, section, or subsection.
|
90
|
-
Note: References form a directed acyclic graph in the document structure."""
|
91
|
-
|
92
|
-
description: str
|
93
|
-
"""Description of the research component in academic style."""
|
94
|
-
title: str
|
95
|
-
"""Title of the research component in academic style."""
|
96
|
-
|
97
|
-
|
98
|
-
class ArticleSubsectionOutline(ArticleOutlineBase):
|
18
|
+
class ArticleSubsectionOutline(ArticleOutlineBase, SubSectionBase):
|
99
19
|
"""Atomic research component specification for academic paper generation."""
|
100
20
|
|
101
21
|
|
102
|
-
class ArticleSectionOutline(ArticleOutlineBase):
|
103
|
-
"""A slightly more detailed research component specification for academic paper generation."""
|
104
22
|
|
105
|
-
|
106
|
-
"""
|
23
|
+
class ArticleSectionOutline(ArticleOutlineBase, SectionBase[ArticleSubsectionOutline]):
|
24
|
+
"""A slightly more detailed research component specification for academic paper generation, Must contain subsections."""
|
107
25
|
|
108
26
|
|
109
|
-
|
110
|
-
|
27
|
+
def update_from_inner(self, other: Self) -> Self:
|
28
|
+
"""Updates the current instance with the attributes of another instance."""
|
29
|
+
super().update_from_inner(other)
|
30
|
+
super(ArticleOutlineBase, self).update_from_inner(other)
|
31
|
+
return self
|
111
32
|
|
112
|
-
sections: List[ArticleSectionOutline] = Field(min_length=1)
|
113
|
-
"""Standard academic progression implementing chapter goals:
|
114
|
-
1. Context Establishment
|
115
|
-
2. Technical Presentation
|
116
|
-
3. Empirical Validation
|
117
|
-
4. Comparative Analysis
|
118
|
-
5. Synthesis
|
119
33
|
|
120
|
-
|
121
|
-
"""
|
34
|
+
class ArticleChapterOutline(ArticleOutlineBase, ChapterBase[ArticleSectionOutline]):
|
35
|
+
"""Macro-structural unit implementing standard academic paper organization. Must contain sections."""
|
122
36
|
|
37
|
+
def update_from_inner(self, other: Self) -> Self:
|
38
|
+
"""Updates the current instance with the attributes of another instance."""
|
39
|
+
super().update_from_inner(other)
|
40
|
+
super(ArticleOutlineBase, self).update_from_inner(other)
|
41
|
+
return self
|
123
42
|
|
124
|
-
class ArticleOutline(Display, CensoredAble, WithRef[ArticleProposal], PersistentAble):
|
125
|
-
"""Complete academic paper blueprint with hierarchical validation."""
|
126
43
|
|
127
|
-
|
128
|
-
|
44
|
+
class ArticleOutline(
|
45
|
+
Display,
|
46
|
+
CensoredAble,
|
47
|
+
WithRef[ArticleProposal],
|
48
|
+
PersistentAble,
|
49
|
+
ArticleBase[ArticleChapterOutline],
|
50
|
+
):
|
51
|
+
"""A class representing the outline of an academic paper."""
|
129
52
|
|
130
|
-
|
131
|
-
"""
|
53
|
+
abstract: str
|
54
|
+
"""The abstract is a concise summary of the academic paper's main findings."""
|
132
55
|
|
133
56
|
prospect: str
|
134
57
|
"""Consolidated research statement with four pillars:
|
@@ -136,17 +59,13 @@ class ArticleOutline(Display, CensoredAble, WithRef[ArticleProposal], Persistent
|
|
136
59
|
2. Methodological Response: Technical approach
|
137
60
|
3. Empirical Validation: Evaluation strategy
|
138
61
|
4. Scholarly Impact: Field contributions
|
62
|
+
"""
|
139
63
|
|
140
|
-
|
141
|
-
|
142
|
-
across 50+ languages, enabling efficient architecture discovery with
|
143
|
-
60% reduced search costs.'"""
|
144
|
-
|
145
|
-
chapters: List[ArticleChapterOutline]
|
146
|
-
"""List of ArticleChapterOutline objects representing the academic paper's structure."""
|
64
|
+
title: str
|
65
|
+
"""Title of the academic paper."""
|
147
66
|
|
148
|
-
|
149
|
-
"""
|
67
|
+
language: str
|
68
|
+
"""Written language of the article. SHALL be aligned to the language of the article proposal provided."""
|
150
69
|
|
151
70
|
def finalized_dump(self) -> str:
|
152
71
|
"""Generates standardized hierarchical markup for academic publishing systems.
|
@@ -177,26 +96,16 @@ class ArticleOutline(Display, CensoredAble, WithRef[ArticleProposal], Persistent
|
|
177
96
|
lines.append(f"=== {i}.{j}.{k} {subsection.title}")
|
178
97
|
return "\n".join(lines)
|
179
98
|
|
180
|
-
|
181
|
-
|
99
|
+
@override
|
100
|
+
def iter_dfs(
|
101
|
+
self,
|
102
|
+
) -> Generator[ArticleChapterOutline | ArticleSectionOutline | ArticleSubsectionOutline, None, None]:
|
103
|
+
return super().iter_dfs()
|
104
|
+
def find_illegal(self) -> Optional[Tuple[ArticleOutlineBase, str]]:
|
105
|
+
"""Finds the first illegal component in the outline.
|
182
106
|
|
183
107
|
Returns:
|
184
|
-
ArticleOutlineBase:
|
185
|
-
"""
|
186
|
-
for chapter in self.chapters:
|
187
|
-
for section in chapter.sections:
|
188
|
-
yield from section.subsections
|
189
|
-
yield section
|
190
|
-
yield chapter
|
191
|
-
|
192
|
-
def resolve_ref_error(self) -> str:
|
193
|
-
"""Resolve reference errors in the article outline.
|
194
|
-
|
195
|
-
Returns:
|
196
|
-
str: Error message indicating reference errors in the article outline.
|
197
|
-
|
198
|
-
Notes:
|
199
|
-
This function is designed to find all invalid `ArticleRef` objs in `depend_on` and `support_to` fields, which will be added to the final error summary.
|
108
|
+
Tuple[ArticleOutlineBase, str]: A tuple containing the illegal component and an error message.
|
200
109
|
"""
|
201
110
|
summary = ""
|
202
111
|
for component in self.iter_dfs():
|
@@ -206,15 +115,17 @@ class ArticleOutline(Display, CensoredAble, WithRef[ArticleProposal], Persistent
|
|
206
115
|
for ref in component.support_to:
|
207
116
|
if not ref.deref(self):
|
208
117
|
summary += f"Invalid internal reference in {component.__class__.__name__} titled `{component.title}` at `support_to` field, because the referred {ref.referring_type} is not exists within the article, see the original obj dump: {ref.model_dump()}\n"
|
209
|
-
|
210
|
-
|
118
|
+
summary += component.introspect()
|
119
|
+
if summary:
|
120
|
+
return component, summary
|
121
|
+
return None
|
211
122
|
|
212
123
|
@classmethod
|
213
124
|
def from_typst_code(
|
214
125
|
cls, typst_code: str, title: str = "", article_language: str = "en", prospect: str = "", abstract: str = ""
|
215
126
|
) -> "ArticleOutline":
|
216
127
|
"""Parses a Typst code string and creates an ArticleOutline instance."""
|
217
|
-
self = cls(
|
128
|
+
self = cls(language=article_language, prospect=prospect, abstract=abstract, chapters=[], title=title)
|
218
129
|
stack = [self] # 根节点为ArticleOutline实例
|
219
130
|
|
220
131
|
for line in typst_code.splitlines():
|
@@ -3,7 +3,6 @@
|
|
3
3
|
from typing import Dict, List
|
4
4
|
|
5
5
|
from fabricatio.models.generic import AsPrompt, CensoredAble, Display, PersistentAble, WithRef
|
6
|
-
from pydantic import Field
|
7
6
|
|
8
7
|
|
9
8
|
class ArticleProposal(CensoredAble, Display, WithRef[str], AsPrompt, PersistentAble):
|
@@ -12,26 +11,25 @@ class ArticleProposal(CensoredAble, Display, WithRef[str], AsPrompt, PersistentA
|
|
12
11
|
Guides LLM in generating comprehensive research proposals with clearly defined components.
|
13
12
|
"""
|
14
13
|
|
15
|
-
|
16
|
-
"""
|
17
|
-
|
18
|
-
title: str = Field(...)
|
19
|
-
"""Paper title in academic style (Title Case, 8-15 words). Example: 'Exploring Neural Architecture Search for Low-Resource Machine Translation'"""
|
14
|
+
technical_approaches: List[str]
|
15
|
+
"""Technical approaches"""
|
20
16
|
|
21
|
-
|
22
|
-
"""
|
23
|
-
Example: ['
|
17
|
+
research_methods: List[str]
|
18
|
+
"""Methodological components (list of techniques/tools).
|
19
|
+
Example: ['Differentiable architecture search', 'Transformer-based search space', 'Multi-lingual perplexity evaluation']"""
|
24
20
|
|
25
21
|
research_aim: List[str]
|
26
22
|
"""Primary research objectives (list of 2-4 measurable goals).
|
27
23
|
Example: ['Develop parameter-efficient NAS framework', 'Establish cross-lingual architecture transfer metrics']"""
|
28
24
|
|
29
|
-
|
30
|
-
"""
|
31
|
-
Example: ['
|
25
|
+
focused_problem: List[str]
|
26
|
+
"""Specific research problem(s) or question(s) addressed (list of 1-3 concise statements).
|
27
|
+
Example: ['NAS computational overhead in low-resource settings', 'Architecture transferability across language pairs']"""
|
32
28
|
|
33
|
-
|
34
|
-
"""
|
29
|
+
title: str
|
30
|
+
"""Paper title in academic style (Title Case, 8-15 words). Example: 'Exploring Neural Architecture Search for Low-Resource Machine Translation'"""
|
31
|
+
language: str
|
32
|
+
"""Written language of the article. SHALL be aligned to the language of the article briefing provided."""
|
35
33
|
|
36
34
|
def _as_prompt_inner(self) -> Dict[str, str]:
|
37
35
|
return {"ArticleBriefing": self.referenced, "ArticleProposal": self.display()}
|