MCPcopy Create free account
hub / github.com/HzaCode/OneCite / _extract_zenodo_info

Method _extract_zenodo_info

onecite/pipeline/identifier.py:316–379  ·  view source on GitHub ↗

Extract Zenodo/Figshare dataset information

(self, text: str)

Source from the content-addressed store, hash-verified

314 return None
315
316 def _extract_zenodo_info(self, text: str) -> Optional[Dict]:
317 """Extract Zenodo/Figshare dataset information"""
318 try:
319 zenodo_pattern = r'10\.5281/zenodo\.(\d+)'
320 match = re.search(zenodo_pattern, text)
321
322 if match:
323 zenodo_id = match.group(1)
324 doi = f"10.5281/zenodo.{zenodo_id}"
325
326 url = f"https://zenodo.org/api/records/{zenodo_id}"
327 response = requests.get(url, timeout=10)
328
329 if response.status_code == 200:
330 data = response.json()
331 metadata = data.get('metadata', {})
332
333 return {
334 'source': 'zenodo',
335 'type': 'dataset',
336 'is_dataset': True,
337 'doi': doi,
338 'title': metadata.get('title', ''),
339 'authors': [creator.get('name', '') for creator in metadata.get('creators', [])],
340 'year': metadata.get('publication_date', '')[:4] if metadata.get('publication_date') else None,
341 'publisher': 'Zenodo',
342 'url': f"https://zenodo.org/record/{zenodo_id}",
343 'version': metadata.get('version', ''),
344 'resource_type': metadata.get('resource_type', {}).get('type', 'dataset')
345 }
346
347 figshare_pattern = r'10\.6084/m9\.figshare\.(\d+)'
348 match = re.search(figshare_pattern, text)
349
350 if match:
351 doi = match.group(0)
352 return {
353 'source': 'figshare',
354 'type': 'dataset',
355 'is_dataset': True,
356 'doi': doi,
357 'publisher': 'Figshare',
358 'url': f"https://doi.org/{doi}"
359 }
360
361 # DataCite DOIs often start with specific prefixes
362 datacite_patterns = [
363 r'10\.5061/', # Dryad
364 r'10\.6078/', # DataONE
365 r'10\.7910/', # DVN/Dataverse
366 ]
367
368 for pattern in datacite_patterns:
369 match = re.search(pattern + r'[^\s,}]+', text)
370 if match:
371 doi = match.group(0)
372 datacite_info = self._query_datacite(doi)
373 if datacite_info:

Calls 2

_query_dataciteMethod · 0.95
jsonMethod · 0.45

Tested by 3