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

Method _search_base_for_thesis

onecite/pipeline/identifier.py:515–558  ·  view source on GitHub ↗

Search BASE (Bielefeld Academic Search Engine) for thesis

(self, query: str, year: Optional[int] = None)

Source from the content-addressed store, hash-verified

513 return None
514
515 def _search_base_for_thesis(self, query: str, year: Optional[int] = None) -> Optional[Dict]:
516 """Search BASE (Bielefeld Academic Search Engine) for thesis"""
517 try:
518 # Clean query
519 query_clean = re.sub(r'\b(phd|ph\.d\.|thesis|dissertation)\b', '', query, flags=re.IGNORECASE).strip()
520
521 base_query = f'dccoll:ftthesis {query_clean}'
522 if year:
523 base_query += f' dcyear:{year}'
524
525 params = {
526 'func': 'PerformSearch',
527 'query': base_query,
528 'hits': 3,
529 'format': 'json'
530 }
531
532 response = requests.get(self.base_search_url, params=params, timeout=10)
533
534 if response.status_code == 200:
535 data = response.json()
536 docs = data.get('response', {}).get('docs', [])
537
538 if docs:
539 doc = docs[0]
540
541 authors = doc.get('dcauthor', [])
542 if isinstance(authors, str):
543 authors = [authors]
544
545 return {
546 'source': 'base_search',
547 'title': doc.get('dctitle', [''])[0] if isinstance(doc.get('dctitle'), list) else doc.get('dctitle', ''),
548 'authors': authors,
549 'year': doc.get('dcyear', [''])[0] if isinstance(doc.get('dcyear'), list) else doc.get('dcyear'),
550 'school': doc.get('dccreator', [''])[0] if isinstance(doc.get('dccreator'), list) else doc.get('dccreator', 'Unknown'),
551 'url': doc.get('dclink', [''])[0] if isinstance(doc.get('dclink'), list) else doc.get('dclink', ''),
552 'type': 'thesis'
553 }
554
555 except Exception as e:
556 self.logger.warning(f"BASE search for thesis failed: {str(e)}")
557
558 return None
559
560 def _search_openaire_for_thesis(self, title: str, year: Optional[int] = None) -> Optional[Dict]:
561 """Search external providerRE for thesis/dissertation"""

Callers 3

test_base_searchMethod · 0.95
_detect_thesisMethod · 0.95
_fuzzy_searchMethod · 0.95

Calls 1

jsonMethod · 0.45

Tested by 1

test_base_searchMethod · 0.76