citation
BibTypeRule
dataclass
BibTypeRule(entry_type: str, standard_name: str = 'default', required_fields: List[str] = list(), suggested_fields: List[str] = list(), optional_fields: List[str] = list(), forbidden_fields: List[str] = list(), field_mappings: Dict[str, str] = dict(), formatting: FormattingRules = FormattingRules(), output: OutputRules = OutputRules(), version: str = '1.0')
Rules for a specific BibTeX entry type.
to_dict
to_dict() -> Dict[str, Any]
Convert to dictionary for serialization.
Source code in ures/literature/citation/rules/data_type.py
63 64 65 | |
FormattingRules
dataclass
FormattingRules(year_range: tuple[int, int] = (1000, 2100), page_separator: str = '--', proceedings_style: str = 'full')
Formatting rules for bibliography entries.
OutputRules
dataclass
OutputRules(field_order: List[str] = list(), conditional_fields: Dict[str, str] = dict(), required_middlewares: List[Type[BlockMiddleware]] = list(), max_authors: int = 5)
Output formatting rules.
CitationInfo
dataclass
CitationInfo(key: str, sources: List[CitationSource] = list(), bibliography: Optional[Entry] = None)
The data structure to hold citation information.
OutputOnlyDesiredFieldsMiddleware
OutputOnlyDesiredFieldsMiddleware(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Keep only desired fields in the output.
Source code in ures/literature/citation/middlewares.py
329 330 331 | |
OutputCleanupNoneResultMiddleware
OutputCleanupNoneResultMiddleware(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Cleanup entries that are invalid or have missing required fields.
Source code in ures/literature/citation/middlewares.py
30 31 32 | |
OutputLimitMaxAuthors
OutputLimitMaxAuthors(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Keep only desired fields in the output.
Source code in ures/literature/citation/middlewares.py
362 363 364 | |
TypeNormalizationMiddleware
TypeNormalizationMiddleware(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Normalize entry types (conference -> inproceedings, etc.)
Source code in ures/literature/citation/middlewares.py
30 31 32 | |
RuleBasedValidationMiddleware
RuleBasedValidationMiddleware(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Validate entries against predefined rules.
Source code in ures/literature/citation/middlewares.py
264 265 266 | |
transform_entry
transform_entry(entry: Entry, *args, **kwargs)
Validate entry using dataclass rules.
Source code in ures/literature/citation/middlewares.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
AcmConferenceVenueMiddleware
AcmConferenceVenueMiddleware(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Put the conference city on the field ACM actually prints.
ACM-Reference-Format appends location or city to the booktitle
and prints address after the publisher. Zotero's BibTeX export has
only address for Place, and that Place is the venue city. BibLaTeX
venue is the event location. For ACM and the default style, move the venue city onto location
when location and city are empty. A publisher address is
left in place when venue already holds the city. Books and IEEE
entries are unchanged.
Source code in ures/literature/citation/middlewares.py
30 31 32 | |
FieldNormalizationMiddleware
FieldNormalizationMiddleware(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Normalize field names (journaltitle -> journal, etc.)
Source code in ures/literature/citation/middlewares.py
30 31 32 | |
transform_entry
transform_entry(entry: Entry, *args, **kwargs) -> Entry
Transform entry fields.
Source code in ures/literature/citation/middlewares.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
LanguageAsciiNormalizationMiddleware
LanguageAsciiNormalizationMiddleware(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Source code in ures/literature/citation/middlewares.py
30 31 32 | |
normalize_language
normalize_language(language_str: str) -> Any
Normalize language string to ISO 639-1 code.
Source code in ures/literature/citation/middlewares.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
ProceedingsNormalizationMiddleware
ProceedingsNormalizationMiddleware(rule_register: Optional[BibRuleRegister] = None)
Bases: CitationMiddleware
Source code in ures/literature/citation/middlewares.py
30 31 32 | |
normailize_proceedings
normailize_proceedings(proceedings_str: str) -> str
Normalize proceedings string to standard format.
Source code in ures/literature/citation/middlewares.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
CitationManager
CitationManager(bibliography_files: Optional[Union[Union[str, Path], List[Union[str, Path]]]] = None, bibliography_style: str = 'default')
Load bibliography files and import citations from TeX or BBL sources.
Examples:
>>> from ures.literature import CitationManager
>>> manager = CitationManager(bibliography_style="acm")
>>> manager.citations
[]
Source code in ures/literature/citation/__init__.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
import_citations
import_citations(files: List[Union[str, Path]], cleanup: bool = False) -> dict[str, CitationInfo]
Import citations from the given files.
Parameters:
-
files(List[Union[str, Path]]) –List of file paths to import citations from.
-
cleanup(bool, default:False) –Whether to clean up the citations previously stored. Defaults to False.
Returns:
-
dict[str, CitationInfo]–List[CitationInfo]: List of imported citations.
Source code in ures/literature/citation/__init__.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
display_invalid_citations
display_invalid_citations() -> None
Display citations that do not have corresponding bibliography entries.
Source code in ures/literature/citation/__init__.py
143 144 145 146 147 148 149 150 151 152 | |
to_library
to_library() -> bibtexparser.Library
Convert all citations to a bibtexparser Library.
Source code in ures/literature/citation/__init__.py
154 155 156 157 158 159 160 161 162 | |
save_bibliography
save_bibliography(file_path: str, middlewares: Optional[List[Union[Type[BlockMiddleware], BlockMiddleware]]] = None) -> None
Save all bibliography entries to a BibTeX file.
Parameters:
-
file_path(Union[str, Path]) –Path to save the BibTeX file.
-
middlewares(Optional[List[Type[CitationMiddleware]]], default:None) –List of middleware classes to process the entries before saving. If None, no additional middleware will be applied. Defaults to None.
Source code in ures/literature/citation/__init__.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |