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

Method _extract_arxiv_id

onecite/pipeline/identifier.py:790–803  ·  view source on GitHub ↗

Extract arXiv ID from text

(self, text: str)

Source from the content-addressed store, hash-verified

788 return []
789
790 def _extract_arxiv_id(self, text: str) -> Optional[str]:
791 """Extract arXiv ID from text"""
792 # Match both old (e.g., 1706.03762) and new (e.g., arxiv:1706.03762) formats
793 arxiv_patterns = [
794 r'arxiv[:\s]*(\d{4}\.\d{4,5})', # New format
795 r'\b(\d{4}\.\d{4,5})\b', # Standalone ID
796 r'arXiv:(\d{4}\.\d{4,5})', # With arXiv prefix
797 ]
798
799 for pattern in arxiv_patterns:
800 match = re.search(pattern, text, re.IGNORECASE)
801 if match:
802 return match.group(1)
803 return None
804
805 def _extract_arxiv_id_from_url(self, url: str) -> Optional[str]:
806 """Extract arXiv ID from arXiv URL"""

Callers 2

Calls

no outgoing calls

Tested by 1