pyeasyphd 0.1.2__py3-none-any.whl → 0.1.5__py3-none-any.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.

Potentially problematic release.


This version of pyeasyphd might be problematic. Click here for more details.

Files changed (41) hide show
  1. pyeasyphd/__init__.py +5 -0
  2. pyeasyphd/data/Templates/CSL/apa-no-ampersand.csl +2183 -0
  3. pyeasyphd/data/Templates/CSL/apa.csl +2133 -0
  4. pyeasyphd/data/Templates/CSL/ieee.csl +512 -0
  5. pyeasyphd/data/Templates/TEX/Article.tex +38 -0
  6. pyeasyphd/data/Templates/TEX/Article_Header.tex +29 -0
  7. pyeasyphd/data/Templates/TEX/Article_Tail.tex +3 -0
  8. pyeasyphd/data/Templates/TEX/Beamer_Header.tex +80 -0
  9. pyeasyphd/data/Templates/TEX/Beamer_Tail.tex +14 -0
  10. pyeasyphd/data/Templates/TEX/Style.tex +249 -0
  11. pyeasyphd/data/Templates/TEX/TEVC_Header.tex +52 -0
  12. pyeasyphd/data/Templates/TEX/TEVC_Tail.tex +4 -0
  13. pyeasyphd/data/Templates/TEX/eisvogel.beamer +700 -0
  14. pyeasyphd/data/Templates/TEX/eisvogel.latex +1040 -0
  15. pyeasyphd/data/Templates/TEX/eisvogel.tex +1064 -0
  16. pyeasyphd/data/Templates/TEX/math.tex +196 -0
  17. pyeasyphd/data/Templates/TEX/math_commands.tex +673 -0
  18. pyeasyphd/main/__init__.py +6 -7
  19. pyeasyphd/main/basic_input.py +59 -77
  20. pyeasyphd/main/pandoc_md_to.py +48 -47
  21. pyeasyphd/main/python_run_md.py +65 -24
  22. pyeasyphd/main/python_run_tex.py +52 -21
  23. pyeasyphd/pyeasyphd.py +20 -6
  24. pyeasyphd/pyeasyphd.sublime-settings +0 -10
  25. pyeasyphd/tools/__init__.py +5 -8
  26. pyeasyphd/tools/generate/generate_from_bibs.py +41 -37
  27. pyeasyphd/tools/generate/generate_html.py +48 -8
  28. pyeasyphd/tools/generate/generate_library.py +39 -26
  29. pyeasyphd/tools/generate/generate_links.py +14 -8
  30. pyeasyphd/tools/py_run_bib_md_tex.py +59 -111
  31. pyeasyphd/tools/search/data.py +12 -48
  32. pyeasyphd/tools/search/search_base.py +37 -10
  33. pyeasyphd/tools/search/search_core.py +108 -38
  34. pyeasyphd/tools/search/search_keywords.py +18 -16
  35. pyeasyphd/tools/search/search_writers.py +94 -32
  36. pyeasyphd/tools/search/utils.py +48 -9
  37. pyeasyphd/utils/utils.py +7 -6
  38. {pyeasyphd-0.1.2.dist-info → pyeasyphd-0.1.5.dist-info}/METADATA +3 -3
  39. pyeasyphd-0.1.5.dist-info/RECORD +43 -0
  40. pyeasyphd-0.1.2.dist-info/RECORD +0 -27
  41. {pyeasyphd-0.1.2.dist-info → pyeasyphd-0.1.5.dist-info}/WHEEL +0 -0
@@ -22,23 +22,14 @@ class PyRunBibMdTex(BasicInput):
22
22
  ) -> None:
23
23
  """Initialize the PyRunBibMdTex instance.
24
24
 
25
- Parameters
26
- ----------
27
- path_output : str
28
- Output directory path for processed files
29
- tex_md_flag : str, optional
30
- Flag indicating whether to process as LaTeX (".tex") or Markdown (".md"),
31
- by default ".md"
32
- template_name : str, optional
33
- Template type to use ("paper" or "beamer"), by default "paper"
34
- options : Dict[str, Any], optional
35
- Additional configuration options, by default {}
36
-
37
- Raises
38
- ------
39
- AssertionError
40
- If tex_md_flag is not ".tex" or ".md"
41
- If template_name is not "paper" or "beamer"
25
+ Args:
26
+ path_output (str): Output directory path for processed files.
27
+ tex_md_flag (str, optional): Flag indicating whether to process as LaTeX (".tex") or Markdown (".md"). Defaults to ".md".
28
+ template_name (str, optional): Template type to use ("paper" or "beamer"). Defaults to "paper".
29
+ options (Dict[str, Any], optional): Additional configuration options. Defaults to {}.
30
+
31
+ Raises:
32
+ AssertionError: If tex_md_flag is not ".tex" or ".md" or if template_name is not "paper" or "beamer".
42
33
  """
43
34
  super().__init__(options)
44
35
 
@@ -48,6 +39,9 @@ class PyRunBibMdTex(BasicInput):
48
39
  assert self.template_name in ["paper", "beamer"], f"{template_name} must be `paper` or `beamer`."
49
40
  self.path_output = standard_path(path_output)
50
41
 
42
+ self.path_bibs = ""
43
+ self.path_figures = ""
44
+
51
45
  # Configuration options
52
46
  self.generate_html = options.get("generate_html", False)
53
47
  self.generate_tex = options.get("generate_tex", True)
@@ -65,8 +59,8 @@ class PyRunBibMdTex(BasicInput):
65
59
  self.delete_original_bib_in_output_folder = options.get("delete_original_bib_in_output_folder", False)
66
60
 
67
61
  # Initialize helper classes
68
- self._python_bib = PythonRunBib(self.full_json_c, self.full_json_j, self.options)
69
- self._python_writer = PythonWriters(self.full_json_c, self.full_json_j, self.options)
62
+ self._python_bib = PythonRunBib(self.options)
63
+ self._python_writer = PythonWriters(self.options)
70
64
 
71
65
  self._python_md = PythonRunMd(self.options)
72
66
  self._python_tex = PythonRunTex(self.options)
@@ -76,19 +70,13 @@ class PyRunBibMdTex(BasicInput):
76
70
  ) -> Tuple[List[str], List[str]]:
77
71
  """Process a list of Markdown or LaTeX files.
78
72
 
79
- Parameters
80
- ----------
81
- file_list_md_tex : List[str]
82
- List of input file paths (Markdown or LaTeX)
83
- output_prefix : str, optional
84
- Prefix for output files, by default ""
85
- output_level : str, optional
86
- Output directory level ("previous", "current", or "next"), by default "next"
87
-
88
- Returns
89
- -------
90
- Tuple[List[str], List[str]]
91
- Tuple containing processed Markdown content and LaTeX content
73
+ Args:
74
+ file_list_md_tex (List[str]): List of input file paths (Markdown or LaTeX).
75
+ output_prefix (str, optional): Prefix for output files. Defaults to "".
76
+ output_level (str, optional): Output directory level ("previous", "current", or "next"). Defaults to "next".
77
+
78
+ Returns:
79
+ Tuple[List[str], List[str]]: Tuple containing processed Markdown content and LaTeX content.
92
80
  """
93
81
  file_list_md_tex = [f for f in file_list_md_tex if f.endswith(self.tex_md_flag)]
94
82
  data_list_list = [read_list(standard_path(f), "r") for f in file_list_md_tex]
@@ -114,21 +102,14 @@ class PyRunBibMdTex(BasicInput):
114
102
  ) -> Tuple[List[str], List[str]]:
115
103
  """Process BibTeX, Markdown and LaTeX content.
116
104
 
117
- Parameters
118
- ----------
119
- output_prefix : str
120
- Prefix for output files
121
- data_list_md_tex : List[str]
122
- List of content lines (Markdown or LaTeX)
123
- original_bib_data : Union[List[str], str, Library]
124
- BibTeX data in various formats
125
- output_level : str, optional
126
- Output directory level ("previous", "current", or "next"), by default "next"
127
-
128
- Returns
129
- -------
130
- Tuple[List[str], List[str]]
131
- Tuple containing processed Markdown content and LaTeX content
105
+ Args:
106
+ output_prefix (str): Prefix for output files.
107
+ data_list_md_tex (List[str]): List of content lines (Markdown or LaTeX).
108
+ original_bib_data (Union[List[str], str, Library]): BibTeX data in various formats.
109
+ output_level (str, optional): Output directory level ("previous", "current", or "next"). Defaults to "next".
110
+
111
+ Returns:
112
+ Tuple[List[str], List[str]]: Tuple containing processed Markdown content and LaTeX content.
132
113
  """
133
114
  # Basic file names
134
115
  output_tex, output_md = output_prefix + ".tex", output_prefix + ".md"
@@ -168,21 +149,14 @@ class PyRunBibMdTex(BasicInput):
168
149
  ) -> Tuple[List[str], List[str]]:
169
150
  """Process BibTeX, Markdown and LaTeX content.
170
151
 
171
- Parameters
172
- ----------
173
- output_md : str
174
- Output Markdown filename
175
- output_tex : str
176
- Output LaTeX filename
177
- data_list_md_tex : List[str]
178
- List of content lines (Markdown or LaTeX)
179
- original_bib_data : Union[List[str], str, Library]
180
- BibTeX data in various formats
181
-
182
- Returns
183
- -------
184
- Tuple[List[str], List[str]]
185
- Tuple containing processed Markdown content and LaTeX content
152
+ Args:
153
+ output_md (str): Output Markdown filename.
154
+ output_tex (str): Output LaTeX filename.
155
+ data_list_md_tex (List[str]): List of content lines (Markdown or LaTeX).
156
+ original_bib_data (Union[List[str], str, Library]): BibTeX data in various formats.
157
+
158
+ Returns:
159
+ Tuple[List[str], List[str]]: Tuple containing processed Markdown content and LaTeX content.
186
160
  """
187
161
  # Copy figures if enabled
188
162
  if self.shutil_figures:
@@ -258,17 +232,12 @@ class PyRunBibMdTex(BasicInput):
258
232
  def search_figure_names(data_list: List[str], figure_postfixes: Optional[List[str]] = None) -> List[str]:
259
233
  """Search for figure filenames in content.
260
234
 
261
- Parameters
262
- ----------
263
- data_list : List[str]
264
- List of content lines to search
265
- figure_postfixes : Optional[List[str]], optional
266
- List of figure file extensions to look for, by default None
267
-
268
- Returns
269
- -------
270
- List[str]
271
- List of found figure filenames
235
+ Args:
236
+ data_list (List[str]): List of content lines to search.
237
+ figure_postfixes (Optional[List[str]], optional): List of figure file extensions to look for. Defaults to None.
238
+
239
+ Returns:
240
+ List[str]: List of found figure filenames.
272
241
  """
273
242
  if figure_postfixes is None:
274
243
  figure_postfixes = ["eps", "jpg", "png", "svg", "psd", "raw", "jpeg", "pdf"]
@@ -283,20 +252,11 @@ class PyRunBibMdTex(BasicInput):
283
252
  def shutil_copy_figures(fig_folder_name: str, path_fig: str, fig_names: List[str], path_output: str) -> None:
284
253
  """Copy figure files to output directory.
285
254
 
286
- Parameters
287
- ----------
288
- fig_folder_name : str
289
- Name of figures folder in output directory
290
- path_fig : str
291
- Source directory containing figures
292
- fig_names : List[str]
293
- List of figure filenames to copy
294
- path_output : str
295
- Output directory path
296
-
297
- Returns
298
- -------
299
- None
255
+ Args:
256
+ fig_folder_name (str): Name of figures folder in output directory.
257
+ path_fig (str): Source directory containing figures.
258
+ fig_names (List[str]): List of figure filenames to copy.
259
+ path_output (str): Output directory path.
300
260
  """
301
261
  if not os.path.exists(path_fig):
302
262
  print(f"{path_fig} does not existed.")
@@ -320,22 +280,16 @@ class PyRunBibMdTex(BasicInput):
320
280
  def search_cite_keys(data_list: List[str], tex_md_flag: str = ".tex") -> List[str]:
321
281
  r"""Extract citation keys from content according to their places.
322
282
 
323
- Parameters
324
- ----------
325
- data_list : List[str]
326
- List of content lines to search
327
- tex_md_flag : str, optional
328
- Flag indicating content format (".tex" or ".md"), by default ".tex"
329
-
330
- Returns
331
- -------
332
- List[str]
333
- List of found citation keys
334
-
335
- Notes
336
- -----
337
- For LaTeX, searches for \\cite, \\citep, \\citet patterns
338
- For Markdown, searches for [@key], @key; and ;@key] patterns
283
+ Args:
284
+ data_list (List[str]): List of content lines to search.
285
+ tex_md_flag (str, optional): Flag indicating content format (".tex" or ".md"). Defaults to ".tex".
286
+
287
+ Returns:
288
+ List[str]: List of found citation keys.
289
+
290
+ Note:
291
+ For LaTeX, searches for \\cite, \\citep, \\citet patterns.
292
+ For Markdown, searches for [@key], @key; and ;@key] patterns.
339
293
  """
340
294
  cite_key_list = []
341
295
  if tex_md_flag == ".tex":
@@ -360,14 +314,8 @@ class PyRunBibMdTex(BasicInput):
360
314
  def _cleanup_file(self, file_path: str) -> None:
361
315
  """Cleanup files and empty directories.
362
316
 
363
- Parameters
364
- ----------
365
- file_path : str
366
- Path to file to be removed
367
-
368
- Returns
369
- -------
370
- None
317
+ Args:
318
+ file_path (str): Path to file to be removed.
371
319
  """
372
320
  if os.path.exists(file_path):
373
321
  os.remove(file_path)
@@ -2,7 +2,11 @@ from typing import Any, Dict
2
2
 
3
3
 
4
4
  def obtain_search_keywords() -> Dict[str, Any]:
5
- """Keywords."""
5
+ """Obtain search keywords dictionary.
6
+
7
+ Returns:
8
+ Dict[str, Any]: Dictionary containing categorized search keywords.
9
+ """
6
10
  _h_ = "(?:| |-)" # hyphen
7
11
 
8
12
  evol = "evol(?:ution|utionary)" # 'evol(?:ution|utionary|ve|ved|ving)'
@@ -62,10 +66,7 @@ def obtain_search_keywords() -> Dict[str, Any]:
62
66
  [moea_d],
63
67
  [nsga],
64
68
  [f"multi{_h_}objective optimization"],
65
- [
66
- [f"multi{_h_}objective", "optimization"],
67
- [f"multi{_h_}objective optimization"],
68
- ],
69
+ [[f"multi{_h_}objective", "optimization"], [f"multi{_h_}objective optimization"]],
69
70
  [[f"multi{_h_}objective"], ["optimization"]],
70
71
  [f"multi{_h_}model optimization"],
71
72
  [[f"multi{_h_}model", "optimization"], [f"multi{_h_}model optimization"]],
@@ -75,36 +76,15 @@ def obtain_search_keywords() -> Dict[str, Any]:
75
76
  [[f"many{_h_}objective"], ["optimization"]],
76
77
  [f"dynamic multi{_h_}objective"],
77
78
  [f"dynamic {evol} multi{_h_}objective"],
78
- [
79
- ["dynamic", f"multi{_h_}objective"],
80
- [
81
- f"dynamic multi{_h_}objective",
82
- f"dynamic {evol} multi{_h_}objective"
83
- ]
84
- ],
79
+ [["dynamic", f"multi{_h_}objective"], [f"dynamic multi{_h_}objective", f"dynamic {evol} multi{_h_}objective"]],
85
80
  [f"dynamic multi{_h_}model"],
86
81
  [["dynamic", f"multi{_h_}model"], [f"dynamic multi{_h_}model"]],
87
82
  [f"dynamic many{_h_}objective"],
88
83
  [f"dynamic {evol} many{_h_}objective"],
89
- [
90
- ["dynamic", f"many{_h_}objective"],
91
- [
92
- f"dynamic many{_h_}objective",
93
- f"dynamic {evol} many{_h_}objective",
94
- ]
95
- ],
84
+ [["dynamic", f"many{_h_}objective"], [f"dynamic many{_h_}objective", f"dynamic {evol} many{_h_}objective"]],
96
85
  ["dynamic", "optimization"],
97
86
  ["dynamic", network],
98
- [
99
- ["dynamic"],
100
- [
101
- f"multi{_h_}objective",
102
- f"multi{_h_}model",
103
- f"many{_h_}objective",
104
- "optimization",
105
- network,
106
- ],
107
- ],
87
+ [["dynamic"], [f"multi{_h_}objective", f"multi{_h_}model", f"many{_h_}objective", "optimization", network]],
108
88
  [f"{uncertain} optimization"],
109
89
  [[uncertain, "optimization"], [f"{uncertain} optimization"]],
110
90
  [[uncertain], ["optimization"]],
@@ -158,12 +138,7 @@ def obtain_search_keywords() -> Dict[str, Any]:
158
138
  ["active", "learning"],
159
139
  [
160
140
  ["supervised", "learning"],
161
- [
162
- f"semi{_h_}supervised",
163
- f"self{_h_}supervised",
164
- f"weakly{_h_}supervised",
165
- "unsupervised",
166
- ],
141
+ [f"semi{_h_}supervised", f"self{_h_}supervised", f"weakly{_h_}supervised", "unsupervised"],
167
142
  ],
168
143
  ["reinforcement", "learning", f"on{_h_}policy"],
169
144
  ["reinforcement", "learning", f"off{_h_}policy"],
@@ -174,15 +149,7 @@ def obtain_search_keywords() -> Dict[str, Any]:
174
149
  ["reinforcement", "learning", evol],
175
150
  [
176
151
  ["reinforcement", "learning"],
177
- [
178
- "offline",
179
- f"on{_h_}policy",
180
- f"off{_h_}policy",
181
- f"model{_h_}based",
182
- "deep",
183
- "continual",
184
- evol,
185
- ],
152
+ ["offline", f"on{_h_}policy", f"off{_h_}policy", f"model{_h_}based", "deep", "continual", evol],
186
153
  ],
187
154
  ["policy", "search"],
188
155
  [["policy"], ["policy", "search"]],
@@ -295,10 +262,7 @@ def obtain_search_keywords() -> Dict[str, Any]:
295
262
  ["upper", bound],
296
263
  ["lower", bound],
297
264
  [[converg], [evol, "swarm", "colony", "genetic", analy]],
298
- [
299
- ["time"],
300
- [evol, "swarm", "colony", "genetic", analy, "hitting", computation, run],
301
- ],
265
+ [["time"], [evol, "swarm", "colony", "genetic", analy, "hitting", computation, run]],
302
266
  [[theor], [evol, "swarm", "colony", "genetic", analy]],
303
267
  [[bound], [evol, "swarm", "colony", "genetic", analy, "upper", "lower"]],
304
268
  [["complexity"], [evol, "swarm", "colony", "genetic", analy]],
@@ -10,7 +10,16 @@ from .search_writers import WriteInitialResult, WriteSeparateResult
10
10
 
11
11
 
12
12
  def search_keywords_core(keywords_list_list: List[List[str]], library: Library, field: str) -> Tuple[Library, Library]:
13
- """Search keywords in `field` such as `title` or `abstract` or `keywords`."""
13
+ """Search keywords in specified field such as title, abstract, or keywords.
14
+
15
+ Args:
16
+ keywords_list_list (List[List[str]]): List of keyword lists to search for.
17
+ library (Library): Bibliography library to search.
18
+ field (str): Field to search in (e.g., 'title', 'abstract', 'keywords').
19
+
20
+ Returns:
21
+ Tuple[Library, Library]: Tuple containing (matching_library, non_matching_library).
22
+ """
14
23
  search_library = []
15
24
  no_search_library = []
16
25
 
@@ -36,31 +45,35 @@ def search_keywords_core(keywords_list_list: List[List[str]], library: Library,
36
45
 
37
46
 
38
47
  class SearchInitialResult(BasicInput):
39
- """Search initial result.
48
+ """Class for searching and processing initial results.
40
49
 
41
50
  Args:
42
- options: dict
51
+ options (dict): Configuration options.
43
52
 
44
53
  Attributes:
45
- options: dict
46
-
47
- print_on_screen (bool = False): print on screen
48
- deepcopy_library_for_every_field (bool = False): deepcopy library for every field
54
+ options (dict): Configuration options.
55
+ print_on_screen (bool): Whether to print results on screen. Defaults to False.
56
+ deepcopy_library_for_every_field (bool): Whether to deep copy library for every field. Defaults to False.
49
57
  """
50
58
 
51
59
  def __init__(self, options: dict) -> None:
60
+ """Initialize SearchInitialResult with configuration options.
61
+
62
+ Args:
63
+ options (dict): Configuration options.
64
+ """
52
65
  self.options = options
53
66
  super().__init__(options)
54
67
 
55
68
  self.print_on_screen: bool = options.get("print_on_screen", False)
56
69
  self.deepcopy_library_for_every_field = options.get("deepcopy_library_for_every_field", False)
57
70
 
58
- self._python_bib = PythonRunBib(self.full_json_c, self.full_json_j, options)
71
+ self._python_bib = PythonRunBib(options)
59
72
 
60
73
  _options = {}
61
74
  _options["empty_entry_cite_keys"] = True
62
75
  _options.update(self.options)
63
- self._python_writer = PythonWriters(self.full_json_c, self.full_json_j, _options)
76
+ self._python_writer = PythonWriters(_options)
64
77
 
65
78
  def main(
66
79
  self,
@@ -73,7 +86,21 @@ class SearchInitialResult(BasicInput):
73
86
  output_prefix: str,
74
87
  path_separate: str,
75
88
  ) -> Tuple[List[str], Dict[str, List[List[str]]], Dict[str, int], Library]:
76
- """Search."""
89
+ """Main search method for processing search results.
90
+
91
+ Args:
92
+ search_field_list (List[str]): List of fields to search.
93
+ path_initial (str): Path to initial directory.
94
+ library (Library): Bibliography library to search.
95
+ keywords_type (str): Type of keywords being searched.
96
+ keywords_list_list (List[List[str]]): List of keyword lists.
97
+ combine_keywords (str): Combined keywords string.
98
+ output_prefix (str): Prefix for output files.
99
+ path_separate (str): Path to separate directory.
100
+
101
+ Returns:
102
+ Tuple[List[str], Dict[str, List[List[str]]], Dict[str, int], Library]: Tuple containing error messages, field data, field numbers, and remaining library.
103
+ """
77
104
  error_pandoc_md_md, field_data_dict, no_search_library = [], {}, library
78
105
  field_number_dict: Dict[str, int] = {}
79
106
 
@@ -24,37 +24,45 @@ from .utils import keywords_type_for_title, switch_keywords_list, switch_keyword
24
24
 
25
25
 
26
26
  class SearchResultsCore(BasicInput):
27
- """Generate tex, md, html, and pdf.
27
+ """Core class for generating tex, md, html, and pdf from search results.
28
28
 
29
29
  Args:
30
- path_storage (str): the path of storage `abbr`
31
- path_output (str): the path of output `abbr`
32
- path_separate (str): the path of separate `abbr`
33
- j_conf_abbr (str): the abbreviation of journal or conference
34
- options (dict): options
30
+ path_storage (str): Path to storage directory for bibliography files.
31
+ path_output (str): Path to output directory for generated files.
32
+ path_separate (str): Path to separate directory for individual results.
33
+ j_conf_abbr (str): Abbreviation of journal or conference.
34
+ options (dict): Configuration options.
35
35
 
36
36
  Attributes:
37
- path_storage (str): the path of storage
38
- path_output (str): the path of output
39
- path_separate (str): the path of separate
40
- j_conf_abbr (str): the abbreviation of journal or conference
41
-
42
- is_standard_bib_file_name (bool = True): whether the bib file name is standard
43
- keywords_type_list (List[str] = []): keywords type list
44
- keywords_dict (dict = {}): keywords dict
45
- delete_redundant_files (bool = True): delete redundant files
46
- generate_basic_md (bool = False): generate basic md
47
- generate_beauty_md (bool = False): generate beauty md
48
- generate_complex_md (bool = True): generate complex md
49
- generate_tex (bool = False): generate tex
50
- first_field_second_keywords (bool = True): first field second keywords
51
- deepcopy_library_for_every_field (bool = False): deepcopy library for every field
52
- deepcopy_library_for_every_keywords (bool = False): deepcopy library for every keywords
37
+ path_storage (str): Path to storage directory.
38
+ path_output (str): Path to output directory.
39
+ path_separate (str): Path to separate directory.
40
+ j_conf_abbr (str): Abbreviation of journal or conference.
41
+ is_standard_bib_file_name (bool): Whether the bib file name follows standard format.
42
+ keywords_type_list (List[str]): List of keyword types to search.
43
+ keywords_dict (dict): Dictionary of keywords for searching.
44
+ delete_redundant_files (bool): Whether to delete redundant files after processing.
45
+ generate_basic_md (bool): Whether to generate basic markdown files.
46
+ generate_beauty_md (bool): Whether to generate beautiful markdown files.
47
+ generate_complex_md (bool): Whether to generate complex markdown files.
48
+ generate_tex (bool): Whether to generate LaTeX files.
49
+ first_field_second_keywords (bool): Whether to search fields first, then keywords.
50
+ deepcopy_library_for_every_field (bool): Whether to deep copy library for every field.
51
+ deepcopy_library_for_every_keywords (bool): Whether to deep copy library for every keywords.
53
52
  """
54
53
 
55
54
  def __init__(
56
55
  self, path_storage: str, path_output: str, path_separate: str, j_conf_abbr: str, options: Dict[str, Any]
57
56
  ) -> None:
57
+ """Initialize SearchResultsCore with paths and configuration.
58
+
59
+ Args:
60
+ path_storage (str): Path to storage directory for bibliography files.
61
+ path_output (str): Path to output directory for generated files.
62
+ path_separate (str): Path to separate directory for individual results.
63
+ j_conf_abbr (str): Abbreviation of journal or conference.
64
+ options (Dict[str, Any]): Configuration options.
65
+ """
58
66
  super().__init__(options)
59
67
  self.path_storage: str = standard_path(path_storage)
60
68
  self.path_output: str = standard_path(path_output)
@@ -96,9 +104,17 @@ class SearchResultsCore(BasicInput):
96
104
  self.deepcopy_library_for_every_keywords = options.get("deepcopy_library_for_every_keywords", False)
97
105
 
98
106
  # for bib
99
- self._python_bib = PythonRunBib(self.full_json_c, self.full_json_j, options)
107
+ self._python_bib = PythonRunBib(options)
100
108
 
101
109
  def optimize(self, search_year_list: List[str] = []) -> Dict[str, Dict[str, Dict[str, Dict[str, int]]]]:
110
+ """Optimize search results for given years.
111
+
112
+ Args:
113
+ search_year_list (List[str], optional): List of years to search. Defaults to [].
114
+
115
+ Returns:
116
+ Dict[str, Dict[str, Dict[str, Dict[str, int]]]]: Nested dictionary containing search results.
117
+ """
102
118
  search_year_list = list(set([str(i) for i in search_year_list]))
103
119
 
104
120
  data_list = self._obtain_full_files_data(self.path_storage, "bib", search_year_list)
@@ -107,6 +123,16 @@ class SearchResultsCore(BasicInput):
107
123
  return entry_type_keyword_type_keyword_field_number_dict
108
124
 
109
125
  def _obtain_full_files_data(self, path_storage: str, extension: str, search_year_list: List[str] = []) -> List[str]:
126
+ """Obtain data from all files with specified extension in storage path.
127
+
128
+ Args:
129
+ path_storage (str): Path to storage directory.
130
+ extension (str): File extension to search for.
131
+ search_year_list (List[str], optional): List of years to filter by. Defaults to [].
132
+
133
+ Returns:
134
+ List[str]: Combined content from all matching files.
135
+ """
110
136
  regex = None
111
137
  if self.is_standard_bib_file_name and search_year_list:
112
138
  regex = re.compile(f'({"|".join(search_year_list)})')
@@ -123,6 +149,15 @@ class SearchResultsCore(BasicInput):
123
149
  return combine_content_in_list([read_list(f, "r") for f in sort_int_str(file_list)], None)
124
150
 
125
151
  def optimize_core(self, data_list: List[str], search_year_list) -> Dict[str, Dict[str, Dict[str, Dict[str, int]]]]:
152
+ """Core optimization logic for processing bibliography data.
153
+
154
+ Args:
155
+ data_list (List[str]): List of bibliography data strings.
156
+ search_year_list: List of years to search.
157
+
158
+ Returns:
159
+ Dict[str, Dict[str, Dict[str, Dict[str, int]]]]: Nested dictionary containing search results.
160
+ """
126
161
  print("\n" + "*" * 9 + f" Search in {self.j_conf_abbr} " + "*" * 9)
127
162
 
128
163
  entry_type_year_volume_number_month_entry_dict = self._python_bib.parse_to_nested_entries_dict(data_list)
@@ -176,18 +211,25 @@ class SearchResultsCore(BasicInput):
176
211
  return entry_type_keyword_type_keyword_field_number_dict
177
212
 
178
213
  def _optimize_fields_keyword(self, keywords_type, library, output_prefix, p_origin, p_separate, p_combine):
214
+ """Optimize search by fields first, then keywords.
215
+
216
+ Args:
217
+ keywords_type: Type of keywords to search.
218
+ library: Bibliography library to search.
219
+ output_prefix (str): Prefix for output files.
220
+ p_origin (str): Path to origin directory.
221
+ p_separate (str): Path to separate directory.
222
+ p_combine (str): Path to combine directory.
223
+
224
+ Returns:
225
+ dict: Dictionary containing keyword field numbers.
226
+ """
179
227
  no_search_library = library
180
228
 
181
229
  keyword_field_number_dict_ = {}
182
230
  for field in self.search_field_list:
183
231
  keyword_field_number_dict, no_search_library = self.core_optimize(
184
- [field],
185
- keywords_type,
186
- no_search_library,
187
- output_prefix,
188
- p_origin,
189
- p_separate,
190
- p_combine,
232
+ [field], keywords_type, no_search_library, output_prefix, p_origin, p_separate, p_combine
191
233
  )
192
234
 
193
235
  if self.deepcopy_library_for_every_field:
@@ -198,16 +240,23 @@ class SearchResultsCore(BasicInput):
198
240
  return keyword_field_number_dict_
199
241
 
200
242
  def _optimize_keywords_field(self, keywords_type, library, output_prefix, p_origin, p_separate, p_combine):
243
+ """Optimize search by keywords first, then fields.
244
+
245
+ Args:
246
+ keywords_type: Type of keywords to search.
247
+ library: Bibliography library to search.
248
+ output_prefix (str): Prefix for output files.
249
+ p_origin (str): Path to origin directory.
250
+ p_separate (str): Path to separate directory.
251
+ p_combine (str): Path to combine directory.
252
+
253
+ Returns:
254
+ dict: Dictionary containing keyword field numbers.
255
+ """
201
256
  no_search_library = library
202
257
 
203
258
  keyword_field_number_dict, no_search_library = self.core_optimize(
204
- self.search_field_list,
205
- keywords_type,
206
- no_search_library,
207
- output_prefix,
208
- p_origin,
209
- p_separate,
210
- p_combine,
259
+ self.search_field_list, keywords_type, no_search_library, output_prefix, p_origin, p_separate, p_combine
211
260
  )
212
261
  return keyword_field_number_dict
213
262
 
@@ -221,6 +270,20 @@ class SearchResultsCore(BasicInput):
221
270
  p_separate: str,
222
271
  p_combine: str,
223
272
  ) -> Tuple[Dict[str, Dict[str, int]], Library]:
273
+ """Core optimization method for processing search results.
274
+
275
+ Args:
276
+ search_field_list (List[str]): List of fields to search.
277
+ keywords_type: Type of keywords to search.
278
+ library (Library): Bibliography library to search.
279
+ output_prefix (str): Prefix for output files.
280
+ p_origin (str): Path to origin directory.
281
+ p_separate (str): Path to separate directory.
282
+ p_combine (str): Path to combine directory.
283
+
284
+ Returns:
285
+ Tuple[Dict[str, Dict[str, int]], Library]: Tuple containing keyword field numbers and remaining library.
286
+ """
224
287
  error_pandoc_md_md: List[str] = []
225
288
  save_field_data_dict: Dict[str, List[List[str]]] = {}
226
289
  keyword_field_number_dict: Dict[str, Dict[str, int]] = {}
@@ -290,7 +353,14 @@ class SearchResultsCore(BasicInput):
290
353
  return keyword_field_number_dict, no_search_library
291
354
 
292
355
  def delete_files(self, keywords_type: str, p_origin: str, p_separate: str, p_combine: str) -> None:
293
- """Delete some redundant files."""
356
+ """Delete redundant files after processing.
357
+
358
+ Args:
359
+ keywords_type (str): Type of keywords being processed.
360
+ p_origin (str): Path to origin directory.
361
+ p_separate (str): Path to separate directory.
362
+ p_combine (str): Path to combine directory.
363
+ """
294
364
  # for initial tex md bib
295
365
  if os.path.exists(p_origin):
296
366
  shutil.rmtree(p_origin)