MCPcopy Create free account
hub / github.com/ResearAI/DeepReviewer-v2 / parse_metadata

Function parse_metadata

pasa/pasa/utils.py:148–180  ·  view source on GitHub ↗

Parse concatenated metadata string into authors, title, and journal.

(metas)

Source from the content-addressed store, hash-verified

146 return []
147
148def 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
182def create_dict_for_citation(ul_element):
183 citation_dict, futures, id_attrs = {}, [], []

Callers 1

create_dict_for_citationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected