This commit is contained in:
@@ -3,9 +3,7 @@ import logging
|
||||
import hashlib
|
||||
from typing import List, Optional
|
||||
from fastapi import HTTPException
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
from inse import config
|
||||
from inse import util
|
||||
from inse.logic import es_client
|
||||
from inse.models.author import Author
|
||||
@@ -25,26 +23,11 @@ def _enrich_author_data(author_data) -> Optional[CustomAuthor]:
|
||||
else:
|
||||
return None
|
||||
author_id = author_data.get("id", "") or ""
|
||||
display_name = author_data.get("display_name", "") or ""
|
||||
works_count = author_data.get("works_count", 0) or 0
|
||||
cited_by_count = author_data.get("cited_by_count", 0) or 0
|
||||
|
||||
# 1. Determine Title & Status
|
||||
h = int(hashlib.md5(author_id.encode('utf-8')).hexdigest(), 16)
|
||||
|
||||
is_prof = works_count > 50 or cited_by_count > 500
|
||||
|
||||
if is_prof:
|
||||
if not display_name.startswith("Prof."):
|
||||
display_name = f"Prof. Dr. {display_name}"
|
||||
else:
|
||||
if not (display_name.startswith("Dr.") or display_name.startswith("Prof.")):
|
||||
prefix = "Dr. " if works_count > 10 else "M.Sc. "
|
||||
display_name = f"{prefix}{display_name}"
|
||||
|
||||
author_data["display_name"] = display_name
|
||||
|
||||
# 2. Assign relevance rating (deterministic suitability chip)
|
||||
# Experimental suitability rating
|
||||
suitability_score = h % 100
|
||||
if suitability_score < 15:
|
||||
relevance_rating = "Sehr geeignet"
|
||||
@@ -53,7 +36,7 @@ def _enrich_author_data(author_data) -> Optional[CustomAuthor]:
|
||||
else:
|
||||
relevance_rating = "Möglich"
|
||||
|
||||
# Resilient sanitization of IDs to protect against model type conflicts
|
||||
# Resilient sanitization of IDs to protect against model type conflicts (Generated)
|
||||
ids = author_data.get("ids")
|
||||
if isinstance(ids, dict):
|
||||
ids_copy = dict(ids)
|
||||
|
||||
Reference in New Issue
Block a user