Parse concatenated metadata string into authors, title, and journal.
(metas)
| 146 | return [] |
| 147 | |
| 148 | def parse_metadata(metas): |
| 149 | """ |
| 150 | Parse concatenated metadata string into authors, title, and journal. |
| 151 | """ |
| 152 | # Get and clean metas |
| 153 | metas = [item.replace('\n', ' ') for item in metas] |
| 154 | meta_string = ' '.join(metas) |
| 155 | |
| 156 | authors, title, journal = "", "", "" |
| 157 | |
| 158 | if len(metas) == 3: # author / title / journal |
| 159 | authors, title, journal = metas |
| 160 | else: |
| 161 | # Remove the year suffix (e.g., 2022a) from the metadata string |
| 162 | meta_string = re.sub(r'\.\s\d{4}[a-z]?\.', '.', meta_string) |
| 163 | # Regular expression to match the pattern |
| 164 | regex = r"^(.*?\.\s)(.*?)(\.\s.*|$)" |
| 165 | match = re.match(regex, meta_string, re.DOTALL) |
| 166 | if match: |
| 167 | authors = match.group(1).strip() if match.group(1) else "" |
| 168 | title = match.group(2).strip() if match.group(2) else "" |
| 169 | journal = match.group(3).strip() if match.group(3) else "" |
| 170 | |
| 171 | if journal.startswith('. '): |
| 172 | journal = journal[2:] |
| 173 | |
| 174 | return { |
| 175 | "meta_list": metas, |
| 176 | "meta_string": meta_string, |
| 177 | "authors": authors, |
| 178 | "title": title, |
| 179 | "journal": journal |
| 180 | } |
| 181 | |
| 182 | def create_dict_for_citation(ul_element): |
| 183 | citation_dict, futures, id_attrs = {}, [], [] |
no outgoing calls
no test coverage detected