Identify a single entry
(self, raw_entry: RawEntry,
interactive_callback: Callable[[List[Dict]], int])
| 75 | return identified_entries |
| 76 | |
| 77 | def _identify_single_entry(self, raw_entry: RawEntry, |
| 78 | interactive_callback: Callable[[List[Dict]], int]) -> IdentifiedEntry: |
| 79 | """Identify a single entry""" |
| 80 | identified_entry: IdentifiedEntry = { |
| 81 | 'id': raw_entry['id'], |
| 82 | 'raw_text': raw_entry['raw_text'], |
| 83 | 'doi': None, |
| 84 | 'arxiv_id': None, |
| 85 | 'url': None, |
| 86 | 'metadata': {}, |
| 87 | 'status': 'identification_failed' |
| 88 | } |
| 89 | |
| 90 | # If valid DOI already exists, verify it against Crossref / DataCite |
| 91 | if raw_entry.get('doi'): |
| 92 | if self._validate_doi(raw_entry['doi']): |
| 93 | real_metadata = self._verify_doi_and_get_metadata(raw_entry['doi']) |
| 94 | if real_metadata: |
| 95 | # DOI resolved. We deliberately do NOT perform a fuzzy |
| 96 | # string comparison between the user's raw text and the |
| 97 | # canonical metadata here. Downstream downstream workflows |
| 98 | # (e.g. the `sci` skill) perform a semantic abstract-vs- |
| 99 | # claim check on the enriched record, which is strictly |
| 100 | # stronger than any bibliographic-string similarity score |
| 101 | # OneCite could produce and would create false reassurance |
| 102 | # for those downstream tools. |
| 103 | identified_entry['doi'] = raw_entry['doi'] |
| 104 | identified_entry['metadata'] = real_metadata |
| 105 | identified_entry['status'] = 'identified' |
| 106 | return identified_entry |
| 107 | else: |
| 108 | self.logger.warning(f"Entry {raw_entry['id']} has valid DOI format but DOI does not exist: {raw_entry['doi']}") |
| 109 | # Continue to fuzzy search as fallback |
| 110 | |
| 111 | github_info = self._extract_github_info(raw_entry['raw_text']) |
| 112 | if github_info: |
| 113 | identified_entry['metadata'] = github_info |
| 114 | identified_entry['url'] = github_info.get('url') |
| 115 | identified_entry['status'] = 'identified' |
| 116 | self.logger.info(f"Entry {raw_entry['id']} identified as GitHub repository: {github_info.get('repo')}") |
| 117 | return identified_entry |
| 118 | |
| 119 | zenodo_info = self._extract_zenodo_info(raw_entry['raw_text']) |
| 120 | if zenodo_info: |
| 121 | identified_entry['doi'] = zenodo_info.get('doi') |
| 122 | identified_entry['metadata'] = zenodo_info |
| 123 | identified_entry['status'] = 'identified' |
| 124 | self.logger.info(f"Entry {raw_entry['id']} identified as Zenodo dataset") |
| 125 | return identified_entry |
| 126 | |
| 127 | thesis_info = self._detect_thesis(raw_entry['raw_text']) |
| 128 | if thesis_info: |
| 129 | identified_entry['metadata'] = thesis_info |
| 130 | identified_entry['status'] = 'identified' |
| 131 | self.logger.info(f"Entry {raw_entry['id']} identified as thesis") |
| 132 | return identified_entry |
| 133 | |
| 134 | arxiv_id = self._extract_arxiv_id(raw_entry['raw_text']) |
no test coverage detected