Merge branch 'dev' of nes.uni-due.de:lbs/smartguide into feature/keywords-analysis
This commit is contained in:
@@ -53,7 +53,6 @@ from inse.patents.service import (
|
||||
router as patents_service_router,
|
||||
)
|
||||
|
||||
from inse.works.purpose_router import router as works_purpose_router
|
||||
from inse.works.v2.router import router as works_v2_router
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -86,7 +85,6 @@ app.include_router(institution_patents_router)
|
||||
app.include_router(org_patents_router)
|
||||
app.include_router(institutions_router)
|
||||
app.include_router(topics_service_router)
|
||||
app.include_router(works_purpose_router)
|
||||
app.include_router(works_service_router)
|
||||
app.include_router(persons_service_router)
|
||||
app.include_router(funders_service_router)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
Pydantic models for publication works.
|
||||
"""
|
||||
|
||||
from enum import StrEnum
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
|
||||
@@ -42,38 +41,3 @@ class WorkPage(BaseModel):
|
||||
class WorkList(BaseModel):
|
||||
elements: List[Work] = Field(default_factory=list, description="All works.")
|
||||
total: int = Field(default=0, description="The total number of works.")
|
||||
|
||||
|
||||
class WorkPurpose(StrEnum):
|
||||
"""Represents the purpose of a work."""
|
||||
|
||||
BASIC_RESEARCH = "Basic Research"
|
||||
APPLIED_RESEARCH = "Applied Research"
|
||||
NON_RESEARCH = "Non-Research"
|
||||
EXPERIMENTAL_DEVELOPMENT = "Experimental Development"
|
||||
NOT_CLASSIFIED = "Not Classified"
|
||||
|
||||
|
||||
class SpecificWorkPurpose(BaseModel):
|
||||
"""Represents the purpose of a specific work, including its ID, purpose, and optional reasoning."""
|
||||
|
||||
raw_oa_work_id: str = Field(description="The raw OpenAlex work id.")
|
||||
publication_year: Optional[int] = Field(
|
||||
default=None, description="The publication year of the work."
|
||||
)
|
||||
purpose: WorkPurpose = Field(description="The purpose of the work.")
|
||||
reasoning: Optional[str] = Field(
|
||||
default=None, description="The reasoning behind the purpose determination."
|
||||
)
|
||||
|
||||
|
||||
class AuthorWorkPurposes(BaseModel):
|
||||
"""Represents the purposes of an author, including their ID and a list of specific work purposes."""
|
||||
|
||||
raw_oa_author_id: str = Field(description="The raw OpenAlex author id.")
|
||||
total: int = Field(
|
||||
default=0, description="The total number of works for the author."
|
||||
)
|
||||
purposes: List[SpecificWorkPurpose] = Field(
|
||||
default_factory=list, description="The list of specific work purposes."
|
||||
)
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Path
|
||||
|
||||
from inse.tags import Tags
|
||||
from inse.works.model import AuthorWorkPurposes, SpecificWorkPurpose
|
||||
|
||||
from inse.works import purpose_service
|
||||
|
||||
WORKS_PREFIX = "/api/purpose"
|
||||
|
||||
router = APIRouter(prefix=WORKS_PREFIX, tags=[Tags.WORKS])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{raw_oa_work_id}/purpose",
|
||||
operation_id="getWorkPurpose",
|
||||
summary="Returns the purpose of a work based on its ID.",
|
||||
)
|
||||
async def get_work_purpose(
|
||||
raw_oa_work_id: Annotated[str, Path(description="The raw OpenAlex work id.")],
|
||||
) -> SpecificWorkPurpose:
|
||||
return await purpose_service.get_work_purpose(raw_oa_work_id=raw_oa_work_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{raw_oa_author_id}/purposes",
|
||||
operation_id="getAuthorWorkPurposes",
|
||||
summary="Returns the purposes of an author based on their ID.",
|
||||
)
|
||||
async def get_author_work_purposes(
|
||||
raw_oa_author_id: Annotated[str, Path(description="The raw OpenAlex author id.")],
|
||||
) -> AuthorWorkPurposes:
|
||||
return await purpose_service.get_author_work_purposes(
|
||||
raw_oa_author_id=raw_oa_author_id
|
||||
)
|
||||
@@ -1,166 +0,0 @@
|
||||
import logging
|
||||
from typing import Dict, List
|
||||
|
||||
|
||||
from inse.exceptions import NotFoundException
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex
|
||||
from inse.works.model import AuthorWorkPurposes, SpecificWorkPurpose, WorkPurpose
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
async def get_work_purpose(raw_oa_work_id: str) -> SpecificWorkPurpose:
|
||||
raw_oa_work_id = raw_oa_work_id.strip().upper()
|
||||
|
||||
response = await elasticsearch.get(
|
||||
index=ESIndex.OPENALEX_WORKS_WILDCARD,
|
||||
doc_id=raw_oa_work_id,
|
||||
source=["title", "abstract"],
|
||||
)
|
||||
|
||||
logger.debug(f"Elasticsearch response for work id {raw_oa_work_id}: {response}")
|
||||
|
||||
source = response.get("_source", {})
|
||||
if not source:
|
||||
raise NotFoundException(f"Work with id {raw_oa_work_id} not found.")
|
||||
|
||||
logger.debug(f"Found work source for id {raw_oa_work_id}: {source}")
|
||||
|
||||
return SpecificWorkPurpose(
|
||||
raw_oa_work_id=raw_oa_work_id,
|
||||
publication_year=source.get("publication_year"),
|
||||
purpose=WorkPurpose.NON_RESEARCH, # TODO: Replace with actual purpose determination logic
|
||||
reasoning="This is a placeholder reasoning for the purpose determination.",
|
||||
)
|
||||
|
||||
|
||||
async def get_author_work_purposes(raw_oa_author_id: str) -> AuthorWorkPurposes:
|
||||
raw_oa_author_id = raw_oa_author_id.strip().upper()
|
||||
logger.debug(f"Retrieving work purposes for author {raw_oa_author_id}")
|
||||
relevant_work_information = await get_relevant_work_information(raw_oa_author_id)
|
||||
logger.debug(
|
||||
f"Retrieved work ids for author {raw_oa_author_id}: {list(relevant_work_information.keys())}"
|
||||
)
|
||||
work_ids = list(relevant_work_information.keys())
|
||||
raw_work_ids = list(map(_extract_raw_work_id, work_ids))
|
||||
logger.debug(
|
||||
f"Extracted raw work ids for author {raw_oa_author_id}: {raw_work_ids}"
|
||||
)
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.WORK_CLASSIFICATIONS,
|
||||
source=["work_id", "classification"],
|
||||
query={"terms": {"work_id": raw_work_ids}},
|
||||
size=10000,
|
||||
)
|
||||
logger.debug(f"Elasticsearch response for work classifications v2FOO: {response}")
|
||||
|
||||
purposes: List[SpecificWorkPurpose] = []
|
||||
|
||||
hits_block = response.get("hits", {})
|
||||
hits = hits_block.get("hits", [])
|
||||
total_hits = hits_block.get("total", {}).get("value", 0)
|
||||
hitted_work_ids = []
|
||||
for hit in hits:
|
||||
source = hit.get("_source", {})
|
||||
work_id = source.get("work_id")
|
||||
classification = source.get("classification")
|
||||
if work_id:
|
||||
work_purpose = _primary_classification_category_to_work_purpose(
|
||||
classification.get("primary_category", "")
|
||||
)
|
||||
purposes.append(
|
||||
SpecificWorkPurpose(
|
||||
raw_oa_work_id=work_id,
|
||||
publication_year=relevant_work_information.get(
|
||||
f"https://openalex.org/{work_id}"
|
||||
),
|
||||
purpose=work_purpose,
|
||||
reasoning=classification.get("classification_reason"),
|
||||
)
|
||||
)
|
||||
hitted_work_ids.append(f"https://openalex.org/{work_id}")
|
||||
else:
|
||||
logger.warning(f"Work hit without id for author {raw_oa_author_id}: {hit}")
|
||||
|
||||
for work_id in filter(lambda wid: wid not in hitted_work_ids, work_ids):
|
||||
purposes.append(
|
||||
SpecificWorkPurpose(
|
||||
raw_oa_work_id=_extract_raw_work_id(work_id),
|
||||
publication_year=relevant_work_information.get(work_id),
|
||||
purpose=WorkPurpose.NOT_CLASSIFIED,
|
||||
reasoning="No classification found for this work.",
|
||||
)
|
||||
)
|
||||
|
||||
return AuthorWorkPurposes(
|
||||
raw_oa_author_id=raw_oa_author_id, total=total_hits, purposes=purposes
|
||||
)
|
||||
|
||||
|
||||
async def get_relevant_work_information(raw_oa_author_id: str) -> Dict[str, int]:
|
||||
raw_oa_author_id = raw_oa_author_id.strip().upper()
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.OPENALEX_WORKS_WILDCARD,
|
||||
source=["id", "publication_year"],
|
||||
query={
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {
|
||||
"bool": {
|
||||
"filter": [
|
||||
{
|
||||
"term": {
|
||||
"authorships.author.id": f"https://openalex.org/{raw_oa_author_id}"
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
size=10000,
|
||||
)
|
||||
|
||||
logger.debug(f"Elasticsearch response for author id {raw_oa_author_id}: {response}")
|
||||
|
||||
hits_block = response.get("hits", {})
|
||||
hits = hits_block.get("hits", [])
|
||||
d: Dict[str, int] = {}
|
||||
for hit in hits:
|
||||
source = hit.get("_source", {})
|
||||
work_id = source.get("id")
|
||||
publication_year = source.get("publication_year")
|
||||
if work_id:
|
||||
d[work_id] = int(publication_year) if publication_year is not None else 0
|
||||
else:
|
||||
logger.warning(f"Work hit without id for author {raw_oa_author_id}: {hit}")
|
||||
|
||||
return d
|
||||
|
||||
|
||||
def _extract_raw_work_id(work_id: str) -> str:
|
||||
"""
|
||||
Extracts the raw work ID from a full OpenAlex work ID.
|
||||
For example, given "https://openalex.org/W1234567890", it returns "W1234567890".
|
||||
"""
|
||||
if not work_id:
|
||||
return ""
|
||||
return work_id.split("/")[-1]
|
||||
|
||||
|
||||
def _primary_classification_category_to_work_purpose(
|
||||
primary_category: str,
|
||||
) -> WorkPurpose:
|
||||
mapping = {
|
||||
"basic_research": WorkPurpose.BASIC_RESEARCH,
|
||||
"applied_research": WorkPurpose.APPLIED_RESEARCH,
|
||||
"non_research": WorkPurpose.NON_RESEARCH,
|
||||
"experimental_development": WorkPurpose.EXPERIMENTAL_DEVELOPMENT,
|
||||
}
|
||||
return mapping.get(
|
||||
primary_category, WorkPurpose.NON_RESEARCH
|
||||
) # Default to NON_RESEARCH if not found
|
||||
@@ -1,4 +1,9 @@
|
||||
from datetime import datetime
|
||||
from enum import StrEnum
|
||||
from typing import Optional, List
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
from inse.model import Page
|
||||
from inse.models.openalex.work import Work
|
||||
@@ -14,3 +19,161 @@ class WorkSortBy(StrEnum):
|
||||
|
||||
class WorkPage(Page[Work]):
|
||||
pass
|
||||
|
||||
|
||||
class WorkPrimaryCategory(StrEnum):
|
||||
"""Represents the primary category of a work."""
|
||||
|
||||
BASIC_RESEARCH = "basic_research"
|
||||
APPLIED_RESEARCH = "applied_research"
|
||||
NON_RESEARCH = "non_research"
|
||||
EXPERIMENTAL_DEVELOPMENT = "experimental_development"
|
||||
NOT_CLASSIFIED = "not_classified"
|
||||
|
||||
|
||||
class WorkClassificationAuthor(BaseModel):
|
||||
"""An author entry within a work classification document."""
|
||||
|
||||
id: Optional[str] = Field(default=None, description="The OpenAlex author id.")
|
||||
display_name: Optional[str] = Field(
|
||||
default=None, description="The author's display name."
|
||||
)
|
||||
orcid: Optional[str] = Field(default=None, description="The author's ORCID id.")
|
||||
|
||||
|
||||
class WorkClassificationInstitution(BaseModel):
|
||||
"""An institution entry within a work classification document."""
|
||||
|
||||
id: Optional[str] = Field(default=None, description="The OpenAlex institution id.")
|
||||
display_name: Optional[str] = Field(
|
||||
default=None, description="The institution's display name."
|
||||
)
|
||||
ror: Optional[str] = Field(default=None, description="The institution's ROR id.")
|
||||
|
||||
|
||||
class WorkClassificationTopicGroup(BaseModel):
|
||||
"""A domain/field/subfield group referenced within a classification topic."""
|
||||
|
||||
id: Optional[str] = Field(default=None, description="The id of the group.")
|
||||
display_name: Optional[str] = Field(
|
||||
default=None, description="The display name of the group."
|
||||
)
|
||||
|
||||
|
||||
class WorkClassificationTopic(BaseModel):
|
||||
"""A topic entry within a work classification document."""
|
||||
|
||||
id: Optional[str] = Field(default=None, description="The OpenAlex topic id.")
|
||||
display_name: Optional[str] = Field(
|
||||
default=None, description="The topic's display name."
|
||||
)
|
||||
score: Optional[float] = Field(
|
||||
default=None, description="The relevance score of the topic."
|
||||
)
|
||||
domain: Optional[WorkClassificationTopicGroup] = Field(
|
||||
default=None, description="The topic's domain."
|
||||
)
|
||||
field: Optional[WorkClassificationTopicGroup] = Field(
|
||||
default=None, description="The topic's field."
|
||||
)
|
||||
subfield: Optional[WorkClassificationTopicGroup] = Field(
|
||||
default=None, description="The topic's subfield."
|
||||
)
|
||||
|
||||
|
||||
class WorkClassificationDetails(BaseModel):
|
||||
"""The core classification result for a work."""
|
||||
|
||||
primary_category: Optional[WorkPrimaryCategory] = Field(
|
||||
default=None,
|
||||
description="The primary classification category assigned to the work.",
|
||||
)
|
||||
confidence: Optional[str] = Field(
|
||||
default=None, description="The confidence level of the classification."
|
||||
)
|
||||
pasteur_quadrant: Optional[str] = Field(
|
||||
default=None, description="The Pasteur quadrant classification, if applicable."
|
||||
)
|
||||
applied_orientation_score: Optional[int] = Field(
|
||||
default=None,
|
||||
description="The applied orientation score for the classification.",
|
||||
)
|
||||
insufficient_context: Optional[bool] = Field(
|
||||
default=None,
|
||||
description="Whether there was insufficient context to classify confidently.",
|
||||
)
|
||||
signals_used: Optional[List[str]] = Field(
|
||||
default=None, description="The signals used to arrive at the classification."
|
||||
)
|
||||
classification_reason: Optional[str] = Field(
|
||||
default=None, description="The reasoning behind the classification."
|
||||
)
|
||||
|
||||
|
||||
class WorkClassificationMeta(BaseModel):
|
||||
"""Metadata about how and when a classification was produced."""
|
||||
|
||||
model: Optional[str] = Field(
|
||||
default=None, description="The model used to produce the classification."
|
||||
)
|
||||
prompt_version: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The version of the prompt used to produce the classification.",
|
||||
)
|
||||
classified_at: Optional[datetime] = Field(
|
||||
default=None,
|
||||
description="The timestamp at which the classification was produced.",
|
||||
)
|
||||
|
||||
|
||||
class WorkClassificationValidation(BaseModel):
|
||||
"""Validation results for a classification."""
|
||||
|
||||
valid: Optional[bool] = Field(
|
||||
default=None, description="Whether the classification passed validation."
|
||||
)
|
||||
errors: Optional[List[str]] = Field(
|
||||
default=None, description="Validation errors, if any."
|
||||
)
|
||||
corrections: Optional[List[str]] = Field(
|
||||
default=None, description="Corrections applied, if any."
|
||||
)
|
||||
|
||||
|
||||
class WorkClassification(BaseModel):
|
||||
"""Represents a full work-classification document."""
|
||||
|
||||
work_id: str = Field(description="The full OpenAlex work id/URL.")
|
||||
doi: Optional[str] = Field(default=None, description="The DOI of the work.")
|
||||
title: Optional[str] = Field(default=None, description="The title of the work.")
|
||||
publication_year: Optional[int] = Field(
|
||||
default=None, description="The publication year of the work."
|
||||
)
|
||||
authors: List[WorkClassificationAuthor] = Field(
|
||||
default_factory=list, description="The authors of the work."
|
||||
)
|
||||
institutions: List[WorkClassificationInstitution] = Field(
|
||||
default_factory=list, description="The institutions associated with the work."
|
||||
)
|
||||
topics: List[WorkClassificationTopic] = Field(
|
||||
default_factory=list, description="The topics associated with the work."
|
||||
)
|
||||
classification: Optional[WorkClassificationDetails] = Field(
|
||||
default=None, description="The classification result for the work."
|
||||
)
|
||||
classification_meta: Optional[WorkClassificationMeta] = Field(
|
||||
default=None, description="Metadata about the classification."
|
||||
)
|
||||
validation: Optional[WorkClassificationValidation] = Field(
|
||||
default=None, description="Validation results for the classification."
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, source: dict) -> Optional["WorkClassification"]:
|
||||
if not source or "work_id" not in source:
|
||||
return None
|
||||
return cls.model_validate(source)
|
||||
|
||||
|
||||
class WorkClassificationPage(Page[WorkClassification]):
|
||||
pass
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
from typing import Annotated, List
|
||||
import logging
|
||||
from typing import Annotated, List, Optional
|
||||
|
||||
from fastapi import APIRouter, Path, Query
|
||||
|
||||
from inse.tags import Tags
|
||||
from inse.model import SortDirection
|
||||
from inse.works.v2.model import WorkPage, WorkSortBy
|
||||
from inse.works.v2.model import (
|
||||
WorkClassification,
|
||||
WorkClassificationPage,
|
||||
WorkPage,
|
||||
WorkSortBy,
|
||||
)
|
||||
from inse.models.openalex.work_topic import WorkTopic
|
||||
from inse.models.openalex.institution import Institution
|
||||
from inse.works.v2.service import get_works_by_keywords
|
||||
from inse.models.openalex.author import Author
|
||||
from inse.models.openalex.topic import Topic
|
||||
|
||||
WORKS_v2_PREFIX = "/api/v2/works"
|
||||
|
||||
router = APIRouter(prefix="/api/v2/works", tags=[Tags.WORKS_V2])
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
router = APIRouter(prefix=WORKS_v2_PREFIX, tags=[Tags.WORKS_V2])
|
||||
|
||||
|
||||
@router.get(
|
||||
@@ -282,3 +292,68 @@ async def get_author_autocomplete(
|
||||
from inse.works.v2.service import search_authors
|
||||
|
||||
return await search_authors(query=query)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/classification/author/{raw_oa_author_id}",
|
||||
operation_id="getAuthorWorkClassifications",
|
||||
summary="Returns the classifications of an author's works based on their ID.",
|
||||
)
|
||||
async def get_author_work_classifications(
|
||||
raw_oa_author_id: Annotated[str, Path(description="The raw OpenAlex author id.")],
|
||||
) -> WorkClassificationPage:
|
||||
from inse.works.v2.service import get_work_classifications_by_author_id
|
||||
|
||||
return await get_work_classifications_by_author_id(
|
||||
raw_oa_author_id=raw_oa_author_id
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/classification/work/{work_id}",
|
||||
operation_id="getWorkClassificationByWorkId",
|
||||
summary="Returns the classifications of a work based on its ID.",
|
||||
)
|
||||
async def get_work_classification_by_work_id(
|
||||
work_id: Annotated[str, Path(description="The OpenAlex work id.")],
|
||||
) -> Optional[WorkClassification]:
|
||||
from inse.works.v2.service import get_work_classification_by_work_id
|
||||
|
||||
return await get_work_classification_by_work_id(work_id=work_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/classification/works/search",
|
||||
operation_id="getWorkClassificationsByWorkIds",
|
||||
summary="Returns the classifications of works based on their IDs.",
|
||||
)
|
||||
async def get_work_classifications_by_work_ids(
|
||||
work_ids: Annotated[
|
||||
list[str],
|
||||
Query(
|
||||
description="A list of OpenAlex work IDs to retrieve classifications for."
|
||||
),
|
||||
] = [],
|
||||
page: Annotated[
|
||||
int, Query(description="The page number to retrieve. (0-based)", ge=0)
|
||||
] = 0,
|
||||
size: Annotated[
|
||||
int,
|
||||
Query(
|
||||
description="The number of classifications to retrieve per page.",
|
||||
ge=1,
|
||||
le=100,
|
||||
),
|
||||
] = 10,
|
||||
) -> WorkClassificationPage:
|
||||
from inse.works.v2.service import get_work_classifications_by_work_ids
|
||||
|
||||
logger.debug(
|
||||
f"Fetching work classifications for work IDs: {work_ids}, page: {page}, size: {size}"
|
||||
)
|
||||
|
||||
return await get_work_classifications_by_work_ids(
|
||||
work_ids=work_ids or [],
|
||||
page=page,
|
||||
size=size,
|
||||
)
|
||||
|
||||
@@ -5,6 +5,8 @@ from fastapi import Query
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex, SortDirection, ESCluster
|
||||
from inse.works.v2.model import (
|
||||
WorkClassification,
|
||||
WorkClassificationPage,
|
||||
WorkPage,
|
||||
WorkSortBy,
|
||||
)
|
||||
@@ -15,7 +17,7 @@ from inse.models.openalex.author import Author
|
||||
from inse.models.openalex.topic import Topic
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
def _authors_nested_query(author_ids: List[str]) -> dict:
|
||||
@@ -549,6 +551,123 @@ async def search_authors(
|
||||
return elements
|
||||
|
||||
|
||||
async def get_work_classifications_by_author_id(
|
||||
raw_oa_author_id: str,
|
||||
page: int = 0,
|
||||
size: int = 10000,
|
||||
) -> WorkClassificationPage:
|
||||
must = [
|
||||
{
|
||||
"nested": {
|
||||
"path": "authors",
|
||||
"query": {"term": {"authors.id": f"{_prefix_id(raw_oa_author_id)}"}},
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
response = await elasticsearch.search(
|
||||
ESIndex.WORK_CLASSIFICATIONS,
|
||||
source=[
|
||||
"work_id",
|
||||
"doi",
|
||||
"title",
|
||||
"publication_year",
|
||||
"authors",
|
||||
"institutions",
|
||||
"topics",
|
||||
"classification",
|
||||
],
|
||||
query={"bool": {"must": must}},
|
||||
size=size,
|
||||
offset=page * size,
|
||||
)
|
||||
|
||||
hits_block = response.get("hits", {})
|
||||
total = hits_block.get("total", {}).get("value", 0)
|
||||
elements = []
|
||||
for hit in hits_block.get("hits", []):
|
||||
classification = WorkClassification.from_dict(hit.get("_source", {})) # type: ignore
|
||||
if classification is not None:
|
||||
elements.append(classification)
|
||||
|
||||
return WorkClassificationPage(
|
||||
elements=elements,
|
||||
total=total,
|
||||
page=page,
|
||||
size=size,
|
||||
)
|
||||
|
||||
|
||||
async def get_work_classification_by_work_id(
|
||||
work_id: str,
|
||||
) -> Optional[WorkClassification]:
|
||||
response = await elasticsearch.search(
|
||||
ESIndex.WORK_CLASSIFICATIONS,
|
||||
source=[
|
||||
"work_id",
|
||||
"doi",
|
||||
"title",
|
||||
"publication_year",
|
||||
"authors",
|
||||
"institutions",
|
||||
"topics",
|
||||
"classification",
|
||||
"classification_meta",
|
||||
"validation",
|
||||
],
|
||||
query={"term": {"work_id": f"{_prefix_id(work_id)}"}},
|
||||
size=1,
|
||||
)
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
if not hits:
|
||||
return None
|
||||
|
||||
return WorkClassification.from_dict(hits[0].get("_source", {}))
|
||||
|
||||
|
||||
async def get_work_classifications_by_work_ids(
|
||||
work_ids: List[str],
|
||||
page: int = 0,
|
||||
size: int = 10000,
|
||||
) -> WorkClassificationPage:
|
||||
prefixed = [_prefix_id(wid) for wid in work_ids]
|
||||
|
||||
logger.debug(f"Fetching work classifications for work IDs: {prefixed}")
|
||||
|
||||
response = await elasticsearch.search(
|
||||
ESIndex.WORK_CLASSIFICATIONS,
|
||||
source=[
|
||||
"work_id",
|
||||
"doi",
|
||||
"title",
|
||||
"publication_year",
|
||||
"authors",
|
||||
"institutions",
|
||||
"topics",
|
||||
"classification",
|
||||
"classification_meta",
|
||||
"validation",
|
||||
],
|
||||
query={"terms": {"work_id": prefixed}},
|
||||
size=size,
|
||||
offset=page * size,
|
||||
)
|
||||
|
||||
hits_block = response.get("hits", {})
|
||||
total = hits_block.get("total", {}).get("value", 0)
|
||||
elements: List[WorkClassification] = []
|
||||
for hit in hits_block.get("hits", []):
|
||||
classification = WorkClassification.from_dict(hit.get("_source", {}))
|
||||
if classification is not None:
|
||||
elements.append(classification)
|
||||
|
||||
p = WorkClassificationPage(elements=elements, total=total, page=page, size=size)
|
||||
logger.debug(f"Returning WorkClassificationPage: {p}")
|
||||
|
||||
return p
|
||||
|
||||
|
||||
def _prefix_id(raw_id: str) -> str:
|
||||
if not raw_id.startswith("https://openalex.org/"):
|
||||
return f"https://openalex.org/{raw_id}"
|
||||
|
||||
@@ -1141,6 +1141,12 @@ Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
GET https://project.nes.uni-due.de/elastic/work-classifications/_mapping
|
||||
Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ==
|
||||
Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
GET https://project.nes.uni-due.de/elastic/work-classifications/_search
|
||||
Authorization: ApiKey am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ==
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -39,7 +39,6 @@ model/authorNetworkNode.ts
|
||||
model/authorParsedLongestName.ts
|
||||
model/authorPositionCount.ts
|
||||
model/authorSummaryStats.ts
|
||||
model/authorWorkPurposes.ts
|
||||
model/authorsFilterProperties.ts
|
||||
model/authorsListResponse.ts
|
||||
model/authorship.ts
|
||||
@@ -185,7 +184,6 @@ model/rankingResponse.ts
|
||||
model/rebuildResponse.ts
|
||||
model/score.ts
|
||||
model/sortDirection.ts
|
||||
model/specificWorkPurpose.ts
|
||||
model/tokenType.ts
|
||||
model/topAuthor.ts
|
||||
model/topAuthorStatistics.ts
|
||||
@@ -221,13 +219,22 @@ model/work.ts
|
||||
model/workBiblio.ts
|
||||
model/workCitationNormalizedPercentile.ts
|
||||
model/workCitedByPercentileYear.ts
|
||||
model/workClassification.ts
|
||||
model/workClassificationAuthor.ts
|
||||
model/workClassificationDetails.ts
|
||||
model/workClassificationInstitution.ts
|
||||
model/workClassificationMeta.ts
|
||||
model/workClassificationPage.ts
|
||||
model/workClassificationTopic.ts
|
||||
model/workClassificationTopicGroup.ts
|
||||
model/workClassificationValidation.ts
|
||||
model/workCountsByYearInner.ts
|
||||
model/workHasContent.ts
|
||||
model/workIds.ts
|
||||
model/workKeyword.ts
|
||||
model/workMeshInner.ts
|
||||
model/workNetworkNode.ts
|
||||
model/workPurpose.ts
|
||||
model/workPrimaryCategory.ts
|
||||
model/workSortBy.ts
|
||||
model/workSustainableDevelopmentGoalsInner.ts
|
||||
model/workTopic.ts
|
||||
|
||||
@@ -16,15 +16,11 @@ import { HttpClient, HttpHeaders, HttpParams,
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// @ts-ignore
|
||||
import { AuthorWorkPurposes } from '../model/authorWorkPurposes';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
// @ts-ignore
|
||||
import { InseModelsOpenalexWorkPageWorkPage } from '../model/inseModelsOpenalexWorkPageWorkPage';
|
||||
// @ts-ignore
|
||||
import { SpecificWorkPurpose } from '../model/specificWorkPurpose';
|
||||
// @ts-ignore
|
||||
import { TopicCount } from '../model/topicCount';
|
||||
// @ts-ignore
|
||||
import { TopicsByTime } from '../model/topicsByTime';
|
||||
@@ -104,61 +100,6 @@ export class WorksService extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the purposes of an author based on their ID.
|
||||
* @endpoint get /api/purpose/{raw_oa_author_id}/purposes
|
||||
* @param rawOaAuthorId The raw OpenAlex author id.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getAuthorWorkPurposes(rawOaAuthorId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<AuthorWorkPurposes>;
|
||||
public getAuthorWorkPurposes(rawOaAuthorId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<AuthorWorkPurposes>>;
|
||||
public getAuthorWorkPurposes(rawOaAuthorId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<AuthorWorkPurposes>>;
|
||||
public getAuthorWorkPurposes(rawOaAuthorId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (rawOaAuthorId === null || rawOaAuthorId === undefined) {
|
||||
throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getAuthorWorkPurposes.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/purpose/${this.configuration.encodeParam({name: "rawOaAuthorId", value: rawOaAuthorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/purposes`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<AuthorWorkPurposes>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a page of works for an author.
|
||||
* @endpoint get /api/works/{author_id}
|
||||
@@ -444,59 +385,4 @@ export class WorksService extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the purpose of a work based on its ID.
|
||||
* @endpoint get /api/purpose/{raw_oa_work_id}/purpose
|
||||
* @param rawOaWorkId The raw OpenAlex work id.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getWorkPurpose(rawOaWorkId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<SpecificWorkPurpose>;
|
||||
public getWorkPurpose(rawOaWorkId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<SpecificWorkPurpose>>;
|
||||
public getWorkPurpose(rawOaWorkId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<SpecificWorkPurpose>>;
|
||||
public getWorkPurpose(rawOaWorkId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (rawOaWorkId === null || rawOaWorkId === undefined) {
|
||||
throw new Error('Required parameter rawOaWorkId was null or undefined when calling getWorkPurpose.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/purpose/${this.configuration.encodeParam({name: "rawOaWorkId", value: rawOaWorkId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/purpose`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<SpecificWorkPurpose>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ import { SortDirection } from '../model/sortDirection';
|
||||
// @ts-ignore
|
||||
import { Topic } from '../model/topic';
|
||||
// @ts-ignore
|
||||
import { WorkClassification } from '../model/workClassification';
|
||||
// @ts-ignore
|
||||
import { WorkClassificationPage } from '../model/workClassificationPage';
|
||||
// @ts-ignore
|
||||
import { WorkSortBy } from '../model/workSortBy';
|
||||
// @ts-ignore
|
||||
import { WorkTopic } from '../model/workTopic';
|
||||
@@ -106,6 +110,61 @@ export class WorksV2Service extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the classifications of an author\'s works based on their ID.
|
||||
* @endpoint get /api/v2/works/classification/author/{raw_oa_author_id}
|
||||
* @param rawOaAuthorId The raw OpenAlex author id.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getAuthorWorkClassifications(rawOaAuthorId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkClassificationPage>;
|
||||
public getAuthorWorkClassifications(rawOaAuthorId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkClassificationPage>>;
|
||||
public getAuthorWorkClassifications(rawOaAuthorId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkClassificationPage>>;
|
||||
public getAuthorWorkClassifications(rawOaAuthorId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (rawOaAuthorId === null || rawOaAuthorId === undefined) {
|
||||
throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getAuthorWorkClassifications.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/v2/works/classification/author/${this.configuration.encodeParam({name: "rawOaAuthorId", value: rawOaAuthorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<WorkClassificationPage>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a paginated list of works for a given author based on their ID.
|
||||
* @endpoint get /api/v2/works/author/{raw_oa_author_id}
|
||||
@@ -558,6 +617,128 @@ export class WorksV2Service extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the classifications of a work based on its ID.
|
||||
* @endpoint get /api/v2/works/classification/work/{work_id}
|
||||
* @param workId The OpenAlex work id.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getWorkClassificationByWorkId(workId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkClassification>;
|
||||
public getWorkClassificationByWorkId(workId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkClassification>>;
|
||||
public getWorkClassificationByWorkId(workId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkClassification>>;
|
||||
public getWorkClassificationByWorkId(workId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (workId === null || workId === undefined) {
|
||||
throw new Error('Required parameter workId was null or undefined when calling getWorkClassificationByWorkId.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/v2/works/classification/work/${this.configuration.encodeParam({name: "workId", value: workId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<WorkClassification>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the classifications of works based on their IDs.
|
||||
* @endpoint get /api/v2/works/classification/works/search
|
||||
* @param workIds A list of OpenAlex work IDs to retrieve classifications for.
|
||||
* @param page The page number to retrieve. (0-based)
|
||||
* @param size The number of classifications to retrieve per page.
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getWorkClassificationsByWorkIds(workIds?: Array<string>, page?: number, size?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkClassificationPage>;
|
||||
public getWorkClassificationsByWorkIds(workIds?: Array<string>, page?: number, size?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkClassificationPage>>;
|
||||
public getWorkClassificationsByWorkIds(workIds?: Array<string>, page?: number, size?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkClassificationPage>>;
|
||||
public getWorkClassificationsByWorkIds(workIds?: Array<string>, page?: number, size?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
if (workIds) {
|
||||
workIds.forEach((element) => {
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>element, 'work_ids');
|
||||
})
|
||||
}
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>page, 'page');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>size, 'size');
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||
'application/json'
|
||||
]);
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||
|
||||
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/v2/works/classification/works/search`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<WorkClassificationPage>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of work topics based on their IDs.
|
||||
* @endpoint get /api/v2/works/topics/search
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { SpecificWorkPurpose } from './specificWorkPurpose';
|
||||
|
||||
|
||||
/**
|
||||
* Represents the purposes of an author, including their ID and a list of specific work purposes.
|
||||
*/
|
||||
export interface AuthorWorkPurposes {
|
||||
/**
|
||||
* The raw OpenAlex author id.
|
||||
*/
|
||||
raw_oa_author_id: string;
|
||||
/**
|
||||
* The total number of works for the author.
|
||||
*/
|
||||
total?: number;
|
||||
/**
|
||||
* The list of specific work purposes.
|
||||
*/
|
||||
purposes?: Array<SpecificWorkPurpose>;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -9,15 +9,26 @@
|
||||
*/
|
||||
import { PatentEntry } from './patentEntry';
|
||||
|
||||
export interface KeywordPatentMatch {
|
||||
patent: PatentEntry;
|
||||
/**
|
||||
* Combined match quality score.
|
||||
*/
|
||||
match_score: number;
|
||||
ipc_score: number;
|
||||
topic_score: number;
|
||||
text_score: number;
|
||||
matched_keywords?: Array<string>;
|
||||
matched_ipc_symbols?: Array<string>;
|
||||
|
||||
export interface KeywordPatentMatch {
|
||||
patent: PatentEntry;
|
||||
/**
|
||||
* Combined match quality score.
|
||||
*/
|
||||
match_score: number;
|
||||
/**
|
||||
* IPC/CPC classification match score.
|
||||
*/
|
||||
ipc_score: number;
|
||||
/**
|
||||
* OpenAlex topic overlap score (0 or 1).
|
||||
*/
|
||||
topic_score: number;
|
||||
/**
|
||||
* Title/abstract keyword overlap score.
|
||||
*/
|
||||
text_score: number;
|
||||
matched_keywords?: Array<string>;
|
||||
matched_ipc_symbols?: Array<string>;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ export * from './authorNetworkNode';
|
||||
export * from './authorParsedLongestName';
|
||||
export * from './authorPositionCount';
|
||||
export * from './authorSummaryStats';
|
||||
export * from './authorWorkPurposes';
|
||||
export * from './authorsFilterProperties';
|
||||
export * from './authorsListResponse';
|
||||
export * from './authorship';
|
||||
@@ -156,7 +155,6 @@ export * from './rankingResponse';
|
||||
export * from './rebuildResponse';
|
||||
export * from './score';
|
||||
export * from './sortDirection';
|
||||
export * from './specificWorkPurpose';
|
||||
export * from './tokenType';
|
||||
export * from './topAuthor';
|
||||
export * from './topAuthorStatistics';
|
||||
@@ -192,13 +190,22 @@ export * from './work';
|
||||
export * from './workBiblio';
|
||||
export * from './workCitationNormalizedPercentile';
|
||||
export * from './workCitedByPercentileYear';
|
||||
export * from './workClassification';
|
||||
export * from './workClassificationAuthor';
|
||||
export * from './workClassificationDetails';
|
||||
export * from './workClassificationInstitution';
|
||||
export * from './workClassificationMeta';
|
||||
export * from './workClassificationPage';
|
||||
export * from './workClassificationTopic';
|
||||
export * from './workClassificationTopicGroup';
|
||||
export * from './workClassificationValidation';
|
||||
export * from './workCountsByYearInner';
|
||||
export * from './workHasContent';
|
||||
export * from './workIds';
|
||||
export * from './workKeyword';
|
||||
export * from './workMeshInner';
|
||||
export * from './workNetworkNode';
|
||||
export * from './workPurpose';
|
||||
export * from './workPrimaryCategory';
|
||||
export * from './workSortBy';
|
||||
export * from './workSustainableDevelopmentGoalsInner';
|
||||
export * from './workTopic';
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { WorkPurpose } from './workPurpose';
|
||||
|
||||
|
||||
/**
|
||||
* Represents the purpose of a specific work, including its ID, purpose, and optional reasoning.
|
||||
*/
|
||||
export interface SpecificWorkPurpose {
|
||||
/**
|
||||
* The raw OpenAlex work id.
|
||||
*/
|
||||
raw_oa_work_id: string;
|
||||
publication_year?: number | null;
|
||||
/**
|
||||
* The purpose of the work.
|
||||
*/
|
||||
purpose: WorkPurpose;
|
||||
reasoning?: string | null;
|
||||
}
|
||||
export namespace SpecificWorkPurpose {
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { WorkClassificationTopic } from './workClassificationTopic';
|
||||
import { WorkClassificationDetails } from './workClassificationDetails';
|
||||
import { WorkClassificationInstitution } from './workClassificationInstitution';
|
||||
import { WorkClassificationMeta } from './workClassificationMeta';
|
||||
import { WorkClassificationValidation } from './workClassificationValidation';
|
||||
import { WorkClassificationAuthor } from './workClassificationAuthor';
|
||||
|
||||
|
||||
/**
|
||||
* Represents a full work-classification document.
|
||||
*/
|
||||
export interface WorkClassification {
|
||||
/**
|
||||
* The full OpenAlex work id/URL.
|
||||
*/
|
||||
work_id: string;
|
||||
doi?: string | null;
|
||||
title?: string | null;
|
||||
publication_year?: number | null;
|
||||
/**
|
||||
* The authors of the work.
|
||||
*/
|
||||
authors?: Array<WorkClassificationAuthor>;
|
||||
/**
|
||||
* The institutions associated with the work.
|
||||
*/
|
||||
institutions?: Array<WorkClassificationInstitution>;
|
||||
/**
|
||||
* The topics associated with the work.
|
||||
*/
|
||||
topics?: Array<WorkClassificationTopic>;
|
||||
classification?: WorkClassificationDetails | null;
|
||||
classification_meta?: WorkClassificationMeta | null;
|
||||
validation?: WorkClassificationValidation | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* An author entry within a work classification document.
|
||||
*/
|
||||
export interface WorkClassificationAuthor {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
orcid?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { WorkPrimaryCategory } from './workPrimaryCategory';
|
||||
|
||||
|
||||
/**
|
||||
* The core classification result for a work.
|
||||
*/
|
||||
export interface WorkClassificationDetails {
|
||||
primary_category?: WorkPrimaryCategory | null;
|
||||
confidence?: string | null;
|
||||
pasteur_quadrant?: string | null;
|
||||
applied_orientation_score?: number | null;
|
||||
insufficient_context?: boolean | null;
|
||||
signals_used?: Array<string> | null;
|
||||
classification_reason?: string | null;
|
||||
}
|
||||
export namespace WorkClassificationDetails {
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* An institution entry within a work classification document.
|
||||
*/
|
||||
export interface WorkClassificationInstitution {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
ror?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Metadata about how and when a classification was produced.
|
||||
*/
|
||||
export interface WorkClassificationMeta {
|
||||
model?: string | null;
|
||||
prompt_version?: string | null;
|
||||
classified_at?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { WorkClassification } from './workClassification';
|
||||
|
||||
|
||||
export interface WorkClassificationPage {
|
||||
/**
|
||||
* The elements of the page.
|
||||
*/
|
||||
elements?: Array<WorkClassification>;
|
||||
/**
|
||||
* The page number. (0-based)
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* The page size in elements.
|
||||
*/
|
||||
size?: number;
|
||||
/**
|
||||
* The total number of elements.
|
||||
*/
|
||||
total?: number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { WorkClassificationTopicGroup } from './workClassificationTopicGroup';
|
||||
|
||||
|
||||
/**
|
||||
* A topic entry within a work classification document.
|
||||
*/
|
||||
export interface WorkClassificationTopic {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
score?: number | null;
|
||||
domain?: WorkClassificationTopicGroup | null;
|
||||
field?: WorkClassificationTopicGroup | null;
|
||||
subfield?: WorkClassificationTopicGroup | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* A domain/field/subfield group referenced within a classification topic.
|
||||
*/
|
||||
export interface WorkClassificationTopicGroup {
|
||||
id?: string | null;
|
||||
display_name?: string | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Validation results for a classification.
|
||||
*/
|
||||
export interface WorkClassificationValidation {
|
||||
valid?: boolean | null;
|
||||
errors?: Array<string> | null;
|
||||
corrections?: Array<string> | null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Represents the primary category of a work.
|
||||
*/
|
||||
export const WorkPrimaryCategory = {
|
||||
BasicResearch: 'basic_research',
|
||||
AppliedResearch: 'applied_research',
|
||||
NonResearch: 'non_research',
|
||||
ExperimentalDevelopment: 'experimental_development',
|
||||
NotClassified: 'not_classified'
|
||||
} as const;
|
||||
export type WorkPrimaryCategory = typeof WorkPrimaryCategory[keyof typeof WorkPrimaryCategory];
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Represents the purpose of a work.
|
||||
*/
|
||||
export const WorkPurpose = {
|
||||
BasicResearch: 'Basic Research',
|
||||
AppliedResearch: 'Applied Research',
|
||||
NonResearch: 'Non-Research',
|
||||
ExperimentalDevelopment: 'Experimental Development',
|
||||
NotClassified: 'Not Classified'
|
||||
} as const;
|
||||
export type WorkPurpose = typeof WorkPurpose[keyof typeof WorkPurpose];
|
||||
|
||||
@@ -28,7 +28,6 @@ import { KeywordsToPatentsResultsComponent } from './modules/keywords-search/sea
|
||||
import { KeywordsToNewsResultsComponent } from './modules/keywords-search/search-results/news-results/news-results.component';
|
||||
import { KeywordsToWorksResultsComponent } from './modules/keywords-search/search-results/works-results/works-results.component';
|
||||
import { UniTrendParentComponent } from './modules/university-ranking/uni-trend-parent/uni-trend-parent.component';
|
||||
import { authorWorkPurposesResolver } from './resolvers/author-work-purposes.resolver';
|
||||
import {
|
||||
RESOLVING_WORK_PAGE_FOR,
|
||||
workPageResolver,
|
||||
@@ -40,6 +39,7 @@ import { roleGuard } from './shared/guards/role.guard';
|
||||
import { UserRole } from './api';
|
||||
import { personCordisEuProjectPageResolver } from './resolvers/person-cordis-eu-project-page.resolver';
|
||||
import { selectedAuthorsResolver } from './resolvers/selected-authors.resolver';
|
||||
import { authorWorkClassificationPageResolver } from './resolvers/author-work-classification-page.resolver';
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
@@ -388,7 +388,7 @@ export const routes: Routes = [
|
||||
selectedTopics: selectedTopicsResolver,
|
||||
selectedInstitutions: selectedInstitutionsResolver,
|
||||
authorWorkPage: workPageResolver,
|
||||
authorWorkPurposes: authorWorkPurposesResolver,
|
||||
authorWorkClassificationPage: authorWorkClassificationPageResolver,
|
||||
},
|
||||
data: {
|
||||
resolvingFor: RESOLVING_WORK_PAGE_FOR.PERSON,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Forschungszwecke</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
@if (this.authorWorkPurposes().purposes?.length === 0) {
|
||||
@if (this.authorWorkClassifications().length === 0) {
|
||||
<div class="no-results">
|
||||
Keine klassifizierten Publikationen gefunden.
|
||||
</div>
|
||||
@@ -21,19 +21,32 @@
|
||||
<div class="purpose-info-cards">
|
||||
<app-info-card
|
||||
[value]="this.basicResearchAmount() + ''"
|
||||
description="Grundlagenforschung" />
|
||||
[description]="this.basicResearchLabel" />
|
||||
<app-info-card
|
||||
[value]="this.appliedResearchAmount() + ''"
|
||||
description="Anwendungsbasierte Forschung" />
|
||||
[description]="this.appliedResearchLabel" />
|
||||
<app-info-card
|
||||
[value]="this.nonResearchAmount() + ''"
|
||||
description="Nicht-forschende Tätigkeit" />
|
||||
[description]="this.nonResearchLabel" />
|
||||
<app-info-card
|
||||
[value]="this.experimentalDevelopmentAmount() + ''"
|
||||
description="Experimentelle Entwicklung" />
|
||||
[description]="this.experimentalDevelopmentLabel" />
|
||||
<app-info-card
|
||||
[value]="this.notClassifiedAmmount() + ''"
|
||||
description="Nicht klassifiziert" />
|
||||
[description]="this.notClassifiedLabel" />
|
||||
<div>
|
||||
<div class="classification-disclaimer">
|
||||
<button
|
||||
mat-icon-button
|
||||
matTooltip="Die Klassifizierung der Publikationen erfolgt nur für eine ausgewählte Anzahl von Institutionen. Wenn eine Publikation nicht zu einer dieser Institutionen gehört, wird sie nicht klassifiziert.">
|
||||
<mat-icon>info_outline</mat-icon>
|
||||
</button>
|
||||
<span
|
||||
>Im Diagramm sind ausschließlich klassifizierte Publikationen
|
||||
enthalten.</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel class="mat-elevation-z1" [expanded]="true">
|
||||
|
||||
@@ -37,3 +37,23 @@ mat-panel-description {
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.classification-disclaimer {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.classification-disclaimer button {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.classification-disclaimer mat-icon {
|
||||
font-size: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
line-height: 18px;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Component, computed, effect, input } from '@angular/core';
|
||||
|
||||
import {
|
||||
AuthorWorkPurposes,
|
||||
InseWorksV2ModelWorkPage,
|
||||
Author,
|
||||
SpecificWorkPurpose,
|
||||
WorkPurpose,
|
||||
WorkTopic,
|
||||
WorkClassificationPage,
|
||||
WorkClassification,
|
||||
WorkPrimaryCategory,
|
||||
} from '../../api';
|
||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||
import * as echarts from 'echarts/core';
|
||||
@@ -22,6 +22,10 @@ import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-pagina
|
||||
import { AppInfoCardComponent } from '../../shared/ui/app-info-card/app-info-card.component';
|
||||
import { PublicationTableComponent } from '../../shared/ui/publication-table/publication-table.component';
|
||||
import { PublicationFilterComponent } from '../../shared/ui/publication-filters/publication-filters.component';
|
||||
import { transformWorkPrimaryCategory } from '../../shared/pipes/work-primary-category.pipe';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
echarts.use([
|
||||
GridComponent,
|
||||
CanvasRenderer,
|
||||
@@ -39,24 +43,13 @@ interface YearlyPurposeCounts {
|
||||
notClassified: number;
|
||||
}
|
||||
|
||||
const PURPOSE_LABELS: Record<
|
||||
| 'BASIC_RESEARCH'
|
||||
| 'APPLIED_RESEARCH'
|
||||
| 'NON_RESEARCH'
|
||||
| 'EXPERIMENTAL_DEVELOPMENT'
|
||||
| 'NOT_CLASSIFIED',
|
||||
string
|
||||
> = {
|
||||
BASIC_RESEARCH: 'Grundlagenforschung',
|
||||
APPLIED_RESEARCH: 'anwendungsbasierte Forschung',
|
||||
NON_RESEARCH: 'nicht-forschende Tätigkeit',
|
||||
EXPERIMENTAL_DEVELOPMENT: 'experimentelle Entwicklung',
|
||||
NOT_CLASSIFIED: 'nicht klassifiziert',
|
||||
};
|
||||
@Component({
|
||||
selector: 'app-person-publications',
|
||||
imports: [
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
MatExpansionModule,
|
||||
MatTooltipModule,
|
||||
NgxEchartsDirective,
|
||||
AppInfoCardComponent,
|
||||
PublicationTableComponent,
|
||||
@@ -74,49 +67,74 @@ export class PersonPublicationsComponent {
|
||||
selectedInstitutions = input.required<Array<Author>>();
|
||||
selectedTopics = input.required<Array<WorkTopic>>();
|
||||
|
||||
authorWorkPurposes = input.required<AuthorWorkPurposes>();
|
||||
authorWorkClassificationPage = input.required<WorkClassificationPage>();
|
||||
authorWorkClassifications = computed(
|
||||
() => this.authorWorkClassificationPage().elements ?? [],
|
||||
);
|
||||
|
||||
specificWorkPurposesByYear = computed(() => {
|
||||
const authorWorkPurposes = this.authorWorkPurposes();
|
||||
return this.getAuthorSpecificWorkPurposesByYear(authorWorkPurposes);
|
||||
const authorWorkClassifications = this.authorWorkClassifications();
|
||||
return this.getAuthorWorkClassificationByYear(authorWorkClassifications);
|
||||
});
|
||||
basicResearchAmount = computed(() => {
|
||||
return this.countPurpose(
|
||||
this.authorWorkPurposes().purposes || [],
|
||||
WorkPurpose.BasicResearch,
|
||||
this.authorWorkClassifications(),
|
||||
WorkPrimaryCategory.BasicResearch,
|
||||
);
|
||||
});
|
||||
basicResearchLabel = transformWorkPrimaryCategory(
|
||||
WorkPrimaryCategory.BasicResearch,
|
||||
);
|
||||
|
||||
appliedResearchAmount = computed(() => {
|
||||
return this.countPurpose(
|
||||
this.authorWorkPurposes().purposes || [],
|
||||
WorkPurpose.AppliedResearch,
|
||||
this.authorWorkClassifications(),
|
||||
WorkPrimaryCategory.AppliedResearch,
|
||||
);
|
||||
});
|
||||
appliedResearchLabel = transformWorkPrimaryCategory(
|
||||
WorkPrimaryCategory.AppliedResearch,
|
||||
);
|
||||
|
||||
nonResearchAmount = computed(() => {
|
||||
return this.countPurpose(
|
||||
this.authorWorkPurposes().purposes || [],
|
||||
WorkPurpose.NonResearch,
|
||||
this.authorWorkClassifications(),
|
||||
WorkPrimaryCategory.NonResearch,
|
||||
);
|
||||
});
|
||||
nonResearchLabel = transformWorkPrimaryCategory(
|
||||
WorkPrimaryCategory.NonResearch,
|
||||
);
|
||||
|
||||
experimentalDevelopmentAmount = computed(() => {
|
||||
return this.countPurpose(
|
||||
this.authorWorkPurposes().purposes || [],
|
||||
WorkPurpose.ExperimentalDevelopment,
|
||||
this.authorWorkClassifications(),
|
||||
WorkPrimaryCategory.ExperimentalDevelopment,
|
||||
);
|
||||
});
|
||||
experimentalDevelopmentLabel = transformWorkPrimaryCategory(
|
||||
WorkPrimaryCategory.ExperimentalDevelopment,
|
||||
);
|
||||
|
||||
notClassifiedAmmount = computed(() => {
|
||||
return this.countPurpose(
|
||||
this.authorWorkPurposes().purposes || [],
|
||||
WorkPurpose.NotClassified,
|
||||
this.authorWorkClassifications(),
|
||||
WorkPrimaryCategory.NotClassified,
|
||||
);
|
||||
});
|
||||
notClassifiedLabel = transformWorkPrimaryCategory(
|
||||
WorkPrimaryCategory.NotClassified,
|
||||
);
|
||||
|
||||
countPurpose = (
|
||||
specificWorkPurposes: SpecificWorkPurpose[],
|
||||
purpose: WorkPurpose,
|
||||
workClassifications: WorkClassification[],
|
||||
primaryCategory: WorkPrimaryCategory,
|
||||
) => {
|
||||
let count = 0;
|
||||
for (const specificWorkPurpose of specificWorkPurposes) {
|
||||
if (specificWorkPurpose.purpose == purpose) {
|
||||
for (const workClassification of workClassifications) {
|
||||
if (
|
||||
workClassification.classification?.primary_category == primaryCategory
|
||||
) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -134,28 +152,31 @@ export class PersonPublicationsComponent {
|
||||
});
|
||||
}
|
||||
|
||||
getAuthorSpecificWorkPurposesByYear(
|
||||
authorWorkPurposes: AuthorWorkPurposes,
|
||||
): Record<number, Array<SpecificWorkPurpose>> {
|
||||
const purposesByYear: Record<number, Array<SpecificWorkPurpose>> = {};
|
||||
for (const purpose of authorWorkPurposes.purposes ?? []) {
|
||||
const year = purpose.publication_year;
|
||||
getAuthorWorkClassificationByYear(
|
||||
authorWorkClassifications: WorkClassification[],
|
||||
): Record<number, Array<WorkClassification>> {
|
||||
const workClassificationsByYear: Record<
|
||||
number,
|
||||
Array<WorkClassification>
|
||||
> = {};
|
||||
for (const classification of authorWorkClassifications) {
|
||||
const year = classification.publication_year;
|
||||
if (!year) continue;
|
||||
|
||||
if (!purposesByYear[year]) {
|
||||
purposesByYear[year] = [];
|
||||
if (!workClassificationsByYear[year]) {
|
||||
workClassificationsByYear[year] = [];
|
||||
}
|
||||
|
||||
purposesByYear[year].push(purpose);
|
||||
workClassificationsByYear[year].push(classification);
|
||||
}
|
||||
return purposesByYear;
|
||||
return workClassificationsByYear;
|
||||
}
|
||||
|
||||
buildYearlyCounts(
|
||||
purposesByYear: Record<number, Array<SpecificWorkPurpose>>,
|
||||
workClassificationsByYear: Record<number, Array<WorkClassification>>,
|
||||
): YearlyPurposeCounts[] {
|
||||
return Object.entries(purposesByYear)
|
||||
.map(([year, purposes]) => {
|
||||
return Object.entries(workClassificationsByYear)
|
||||
.map(([year, classificiations]) => {
|
||||
const counts: YearlyPurposeCounts = {
|
||||
year: Number(year),
|
||||
basicResearch: 0,
|
||||
@@ -164,16 +185,22 @@ export class PersonPublicationsComponent {
|
||||
experimentalDevelopment: 0,
|
||||
notClassified: 0,
|
||||
};
|
||||
for (const purpose of purposes) {
|
||||
if (purpose.purpose == WorkPurpose.BasicResearch) {
|
||||
for (const classification of classificiations) {
|
||||
const primaryCategory =
|
||||
classification.classification?.primary_category;
|
||||
if (!primaryCategory) continue;
|
||||
|
||||
if (primaryCategory == WorkPrimaryCategory.BasicResearch) {
|
||||
counts.basicResearch++;
|
||||
} else if (purpose.purpose == WorkPurpose.AppliedResearch) {
|
||||
} else if (primaryCategory == WorkPrimaryCategory.AppliedResearch) {
|
||||
counts.appliedResearch++;
|
||||
} else if (purpose.purpose == WorkPurpose.NonResearch) {
|
||||
} else if (primaryCategory == WorkPrimaryCategory.NonResearch) {
|
||||
counts.nonResearch++;
|
||||
} else if (purpose.purpose == WorkPurpose.ExperimentalDevelopment) {
|
||||
} else if (
|
||||
primaryCategory == WorkPrimaryCategory.ExperimentalDevelopment
|
||||
) {
|
||||
counts.experimentalDevelopment++;
|
||||
} else if (purpose.purpose == WorkPurpose.NotClassified) {
|
||||
} else if (primaryCategory == WorkPrimaryCategory.NotClassified) {
|
||||
counts.notClassified++;
|
||||
}
|
||||
}
|
||||
@@ -187,11 +214,11 @@ export class PersonPublicationsComponent {
|
||||
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
|
||||
legend: {
|
||||
data: [
|
||||
PURPOSE_LABELS.BASIC_RESEARCH,
|
||||
PURPOSE_LABELS.APPLIED_RESEARCH,
|
||||
PURPOSE_LABELS.NON_RESEARCH,
|
||||
PURPOSE_LABELS.EXPERIMENTAL_DEVELOPMENT,
|
||||
PURPOSE_LABELS.NOT_CLASSIFIED,
|
||||
this.basicResearchLabel,
|
||||
this.appliedResearchLabel,
|
||||
this.nonResearchLabel,
|
||||
this.experimentalDevelopmentLabel,
|
||||
this.notClassifiedLabel,
|
||||
],
|
||||
bottom: 0,
|
||||
itemGap: 40,
|
||||
@@ -210,35 +237,35 @@ export class PersonPublicationsComponent {
|
||||
yAxis: { type: 'value' },
|
||||
series: [
|
||||
{
|
||||
name: PURPOSE_LABELS.BASIC_RESEARCH,
|
||||
name: this.basicResearchLabel,
|
||||
type: 'bar',
|
||||
stack: 'total',
|
||||
emphasis: { focus: 'series' },
|
||||
data: data.map((d) => d.basicResearch),
|
||||
},
|
||||
{
|
||||
name: PURPOSE_LABELS.APPLIED_RESEARCH,
|
||||
name: this.appliedResearchLabel,
|
||||
type: 'bar',
|
||||
stack: 'total',
|
||||
emphasis: { focus: 'series' },
|
||||
data: data.map((d) => d.appliedResearch),
|
||||
},
|
||||
{
|
||||
name: PURPOSE_LABELS.NON_RESEARCH,
|
||||
name: this.nonResearchLabel,
|
||||
type: 'bar',
|
||||
stack: 'total',
|
||||
emphasis: { focus: 'series' },
|
||||
data: data.map((d) => d.nonResearch),
|
||||
},
|
||||
{
|
||||
name: PURPOSE_LABELS.EXPERIMENTAL_DEVELOPMENT,
|
||||
name: this.experimentalDevelopmentLabel,
|
||||
type: 'bar',
|
||||
stack: 'total',
|
||||
emphasis: { focus: 'series' },
|
||||
data: data.map((d) => d.experimentalDevelopment),
|
||||
},
|
||||
{
|
||||
name: PURPOSE_LABELS.NOT_CLASSIFIED,
|
||||
name: this.notClassifiedLabel,
|
||||
type: 'bar',
|
||||
stack: 'total',
|
||||
emphasis: { focus: 'series' },
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { WorkClassificationPage, WorksV2Service } from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const authorWorkClassificationPageResolver: ResolveFn<
|
||||
WorkClassificationPage
|
||||
> = (route, state) => {
|
||||
const id = route.parent?.paramMap.get('id') || route.paramMap.get('id');
|
||||
if (!id) {
|
||||
throw new Error(
|
||||
'Author ID is required to resolve author work classification page.',
|
||||
);
|
||||
}
|
||||
|
||||
return inject(WorksV2Service).getAuthorWorkClassifications(id);
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { AuthorWorkPurposes, WorksService } from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const authorWorkPurposesResolver: ResolveFn<AuthorWorkPurposes> = (
|
||||
route,
|
||||
state,
|
||||
) => {
|
||||
const id = route.parent?.paramMap.get('id') || route.paramMap.get('id');
|
||||
if (!id) {
|
||||
throw new Error('Author ID is required to resolve author work purposes.');
|
||||
}
|
||||
|
||||
return inject(WorksService).getAuthorWorkPurposes(id);
|
||||
};
|
||||
@@ -68,7 +68,7 @@ export const workPageResolver: ResolveFn<InseWorksV2ModelWorkPage> = (
|
||||
const rawOaAuthorId =
|
||||
route.parent?.paramMap.get('id') || route.paramMap.get('id');
|
||||
if (!rawOaAuthorId) {
|
||||
throw new Error('Author ID is required to resolve author work purposes.');
|
||||
throw new Error('Author ID is required to resolve author works.');
|
||||
}
|
||||
return inject(WorksV2Service).getAuthorWorkPage(
|
||||
rawOaAuthorId,
|
||||
@@ -90,7 +90,7 @@ export const workPageResolver: ResolveFn<InseWorksV2ModelWorkPage> = (
|
||||
route.paramMap.get('institutionId');
|
||||
if (!rawOaInstitutionId) {
|
||||
throw new Error(
|
||||
'Institution ID is required to resolve institution work purposes.',
|
||||
'Institution ID is required to resolve institution works.',
|
||||
);
|
||||
}
|
||||
return inject(WorksV2Service).getInstitutionWorkPage(
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { WorkPrimaryCategory } from '../../api';
|
||||
|
||||
export const workPrimaryCategoryLabels: Record<WorkPrimaryCategory, string> = {
|
||||
[WorkPrimaryCategory.AppliedResearch]: 'Anwendungsbasierte Forschung',
|
||||
[WorkPrimaryCategory.BasicResearch]: 'Grundlagenforschung',
|
||||
[WorkPrimaryCategory.ExperimentalDevelopment]: 'Experimentelle Entwicklung',
|
||||
[WorkPrimaryCategory.NonResearch]: 'Nicht-forschende Tätigkeit',
|
||||
[WorkPrimaryCategory.NotClassified]: 'Nicht klassifiziert',
|
||||
};
|
||||
|
||||
export const transformWorkPrimaryCategory = (
|
||||
value: WorkPrimaryCategory | null | undefined,
|
||||
): string => {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
return workPrimaryCategoryLabels[value] || value;
|
||||
};
|
||||
|
||||
@Pipe({
|
||||
name: 'workPrimaryCategory',
|
||||
})
|
||||
export class WorkPrimaryCategoryPipe implements PipeTransform {
|
||||
transform(
|
||||
value: WorkPrimaryCategory | null | undefined,
|
||||
...args: unknown[]
|
||||
): unknown {
|
||||
return transformWorkPrimaryCategory(value);
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,19 @@
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #classificationTmp let-work>
|
||||
@let classification = getWorkClassification(work.id);
|
||||
@if (classification) {
|
||||
<button type="button" class="cell-filter-pill" matTooltipPosition="above">
|
||||
{{
|
||||
classification.classification?.primary_category | workPrimaryCategory
|
||||
}}
|
||||
</button>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #authorsTmp let-work>
|
||||
@let workAuthors = getWorkAuthors(work);
|
||||
@let workAuthorsExpanded = isWorkAuthorsExpanded(work);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
OnInit,
|
||||
signal,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
@@ -16,6 +18,8 @@ import {
|
||||
InseWorksV2ModelWorkPage,
|
||||
Institution,
|
||||
Work,
|
||||
WorkClassification,
|
||||
WorksV2Service,
|
||||
WorkTopic,
|
||||
} from '../../../api';
|
||||
import { TopicChipComponent } from '../topic-chip/topic-chip.component';
|
||||
@@ -29,6 +33,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
|
||||
import { WorkPrimaryCategoryPipe } from '../../pipes/work-primary-category.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publication-table',
|
||||
@@ -42,6 +47,7 @@ import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
|
||||
ChipComponent,
|
||||
WorkTypePipe,
|
||||
LanguageCodePipe,
|
||||
WorkPrimaryCategoryPipe,
|
||||
],
|
||||
templateUrl: './publication-table.component.html',
|
||||
styleUrl: './publication-table.component.scss',
|
||||
@@ -59,6 +65,7 @@ export class PublicationTableComponent implements OnInit {
|
||||
typeTmp = viewChild.required<TemplateRef<any>>('typeTmp');
|
||||
yearTmp = viewChild.required<TemplateRef<any>>('yearTmp');
|
||||
languageTmp = viewChild.required<TemplateRef<any>>('languageTmp');
|
||||
classificationTmp = viewChild.required<TemplateRef<any>>('classificationTmp');
|
||||
authorsTmp = viewChild.required<TemplateRef<any>>('authorsTmp');
|
||||
institutionsTmp = viewChild.required<TemplateRef<any>>('institutionsTmp');
|
||||
topicsTmp = viewChild.required<TemplateRef<any>>('topicsTmp');
|
||||
@@ -126,12 +133,19 @@ export class PublicationTableComponent implements OnInit {
|
||||
accessorKey: 'language',
|
||||
cellTemplate: this.languageTmp(),
|
||||
},
|
||||
{
|
||||
id: 'classification',
|
||||
header: 'Klassifikation',
|
||||
type: 'display',
|
||||
cellTemplate: this.classificationTmp(),
|
||||
},
|
||||
{
|
||||
id: 'authors',
|
||||
header: 'Autoren',
|
||||
type: 'display',
|
||||
cellTemplate: this.authorsTmp(),
|
||||
},
|
||||
|
||||
{
|
||||
id: 'institutions',
|
||||
header: 'Institutionen',
|
||||
@@ -161,6 +175,36 @@ export class PublicationTableComponent implements OnInit {
|
||||
];
|
||||
}
|
||||
|
||||
workIds = computed(
|
||||
() =>
|
||||
this.elements()
|
||||
.map((work) => work.id)
|
||||
.filter(Boolean) as string[],
|
||||
);
|
||||
|
||||
workClassifications = signal<WorkClassification[]>([]);
|
||||
|
||||
getWorkClassification(workId: string): WorkClassification | undefined {
|
||||
return this.workClassifications().find(
|
||||
(classification) => classification.work_id === workId,
|
||||
);
|
||||
}
|
||||
|
||||
constructor(private readonly worksV2Service: WorksV2Service) {
|
||||
effect(() => {
|
||||
const ids = this.workIds();
|
||||
if (ids.length > 0) {
|
||||
this.worksV2Service
|
||||
.getWorkClassificationsByWorkIds(ids)
|
||||
.subscribe((classificationPage) => {
|
||||
this.workClassifications.set(classificationPage.elements ?? []);
|
||||
});
|
||||
} else {
|
||||
this.workClassifications.set([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isTypeActive(type: string): boolean {
|
||||
return this.selectedTypesQueryParams().includes(type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user