From 377e75f89ded5184f5f1335cd3337707251da93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mats=20Paul=20Ton=C4=8Dik?= Date: Fri, 17 Jul 2026 14:20:25 +0200 Subject: [PATCH] fix(work-classifications): adapted to new elasticsearch index schema --- service/src/main/inse/main.py | 2 - service/src/main/inse/works/model.py | 36 ---- service/src/main/inse/works/purpose_router.py | 36 ---- .../src/main/inse/works/purpose_service.py | 166 ---------------- service/src/main/inse/works/v2/model.py | 163 ++++++++++++++++ service/src/main/inse/works/v2/router.py | 74 ++++++- service/src/main/inse/works/v2/service.py | 114 +++++++++++ ude_person.http | 6 + webapp/src/app/api/.openapi-generator/FILES | 13 +- webapp/src/app/api/api/works.service.ts | 114 ----------- webapp/src/app/api/api/worksV2.service.ts | 181 ++++++++++++++++++ .../src/app/api/model/authorWorkPurposes.ts | 30 --- .../src/app/api/model/keywordPatentMatch.ts | 35 ++-- webapp/src/app/api/model/models.ts | 13 +- .../src/app/api/model/specificWorkPurpose.ts | 31 --- .../src/app/api/model/workClassification.ts | 45 +++++ .../app/api/model/workClassificationAuthor.ts | 20 ++ .../api/model/workClassificationDetails.ts | 28 +++ .../model/workClassificationInstitution.ts | 20 ++ .../app/api/model/workClassificationMeta.ts | 20 ++ .../app/api/model/workClassificationPage.ts | 31 +++ .../app/api/model/workClassificationTopic.ts | 24 +++ .../api/model/workClassificationTopicGroup.ts | 19 ++ .../api/model/workClassificationValidation.ts | 20 ++ .../src/app/api/model/workPrimaryCategory.ts | 23 +++ webapp/src/app/api/model/workPurpose.ts | 23 --- webapp/src/app/app.routes.ts | 4 +- .../person-publications.component.html | 2 +- .../person-publications.component.ts | 93 +++++---- ...uthor-work-classification-page.resolver.ts | 16 ++ .../author-work-purposes.resolver.ts | 15 -- .../src/app/resolvers/work-page.resolver.ts | 4 +- 32 files changed, 903 insertions(+), 518 deletions(-) delete mode 100644 service/src/main/inse/works/purpose_router.py delete mode 100644 service/src/main/inse/works/purpose_service.py delete mode 100644 webapp/src/app/api/model/authorWorkPurposes.ts delete mode 100644 webapp/src/app/api/model/specificWorkPurpose.ts create mode 100644 webapp/src/app/api/model/workClassification.ts create mode 100644 webapp/src/app/api/model/workClassificationAuthor.ts create mode 100644 webapp/src/app/api/model/workClassificationDetails.ts create mode 100644 webapp/src/app/api/model/workClassificationInstitution.ts create mode 100644 webapp/src/app/api/model/workClassificationMeta.ts create mode 100644 webapp/src/app/api/model/workClassificationPage.ts create mode 100644 webapp/src/app/api/model/workClassificationTopic.ts create mode 100644 webapp/src/app/api/model/workClassificationTopicGroup.ts create mode 100644 webapp/src/app/api/model/workClassificationValidation.ts create mode 100644 webapp/src/app/api/model/workPrimaryCategory.ts delete mode 100644 webapp/src/app/api/model/workPurpose.ts create mode 100644 webapp/src/app/resolvers/author-work-classification-page.resolver.ts delete mode 100644 webapp/src/app/resolvers/author-work-purposes.resolver.ts diff --git a/service/src/main/inse/main.py b/service/src/main/inse/main.py index b8fa3d17..1e9c0a78 100644 --- a/service/src/main/inse/main.py +++ b/service/src/main/inse/main.py @@ -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) diff --git a/service/src/main/inse/works/model.py b/service/src/main/inse/works/model.py index 38f29433..e16d723a 100644 --- a/service/src/main/inse/works/model.py +++ b/service/src/main/inse/works/model.py @@ -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." - ) diff --git a/service/src/main/inse/works/purpose_router.py b/service/src/main/inse/works/purpose_router.py deleted file mode 100644 index 2d2beeaf..00000000 --- a/service/src/main/inse/works/purpose_router.py +++ /dev/null @@ -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 - ) diff --git a/service/src/main/inse/works/purpose_service.py b/service/src/main/inse/works/purpose_service.py deleted file mode 100644 index f397076a..00000000 --- a/service/src/main/inse/works/purpose_service.py +++ /dev/null @@ -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 diff --git a/service/src/main/inse/works/v2/model.py b/service/src/main/inse/works/v2/model.py index 25efaef5..c5bbb1b1 100644 --- a/service/src/main/inse/works/v2/model.py +++ b/service/src/main/inse/works/v2/model.py @@ -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 diff --git a/service/src/main/inse/works/v2/router.py b/service/src/main/inse/works/v2/router.py index 8301b308..10f53e22 100644 --- a/service/src/main/inse/works/v2/router.py +++ b/service/src/main/inse/works/v2/router.py @@ -1,17 +1,24 @@ -from typing import Annotated, List +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.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]) + +router = APIRouter(prefix=WORKS_v2_PREFIX, tags=[Tags.WORKS_V2]) @router.get( @@ -238,3 +245,64 @@ 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/work/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 + + return await get_work_classifications_by_work_ids( + work_ids=work_ids or [], + page=page, + size=size, + ) diff --git a/service/src/main/inse/works/v2/service.py b/service/src/main/inse/works/v2/service.py index dce8e393..de03c28b 100644 --- a/service/src/main/inse/works/v2/service.py +++ b/service/src/main/inse/works/v2/service.py @@ -4,6 +4,8 @@ from typing import List, Optional from inse.integrations import elasticsearch from inse.model import ESIndex, SortDirection from inse.works.v2.model import ( + WorkClassification, + WorkClassificationPage, WorkPage, WorkSortBy, ) @@ -394,6 +396,118 @@ 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] + + 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) + + return WorkClassificationPage(elements=elements, total=total, page=page, size=size) + + def _prefix_id(raw_id: str) -> str: if not raw_id.startswith("https://openalex.org/"): return f"https://openalex.org/{raw_id}" diff --git a/ude_person.http b/ude_person.http index e797f39a..46eeccc8 100644 --- a/ude_person.http +++ b/ude_person.http @@ -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 diff --git a/webapp/src/app/api/.openapi-generator/FILES b/webapp/src/app/api/.openapi-generator/FILES index 3b7a05ad..766ae2dd 100644 --- a/webapp/src/app/api/.openapi-generator/FILES +++ b/webapp/src/app/api/.openapi-generator/FILES @@ -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 diff --git a/webapp/src/app/api/api/works.service.ts b/webapp/src/app/api/api/works.service.ts index 935ceba4..80b60de6 100644 --- a/webapp/src/app/api/api/works.service.ts +++ b/webapp/src/app/api/api/works.service.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; - public getAuthorWorkPurposes(rawOaAuthorId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getAuthorWorkPurposes(rawOaAuthorId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getAuthorWorkPurposes(rawOaAuthorId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - 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('get', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: 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; - public getWorkPurpose(rawOaWorkId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getWorkPurpose(rawOaWorkId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; - public getWorkPurpose(rawOaWorkId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { - 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('get', `${basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - ...(withCredentials ? { withCredentials } : {}), - headers: localVarHeaders, - observe: observe, - ...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}), - reportProgress: reportProgress - } - ); - } - } diff --git a/webapp/src/app/api/api/worksV2.service.ts b/webapp/src/app/api/api/worksV2.service.ts index a2ad4aeb..a875e62f 100644 --- a/webapp/src/app/api/api/worksV2.service.ts +++ b/webapp/src/app/api/api/worksV2.service.ts @@ -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; + public getAuthorWorkClassifications(rawOaAuthorId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAuthorWorkClassifications(rawOaAuthorId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getAuthorWorkClassifications(rawOaAuthorId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + 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('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: 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; + public getWorkClassificationByWorkId(workId: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getWorkClassificationByWorkId(workId: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getWorkClassificationByWorkId(workId: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + 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('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: 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/work/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, page?: number, size?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable; + public getWorkClassificationsByWorkIds(workIds?: Array, page?: number, size?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getWorkClassificationsByWorkIds(workIds?: Array, page?: number, size?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable>; + public getWorkClassificationsByWorkIds(workIds?: Array, page?: number, size?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable { + + let localVarQueryParameters = new HttpParams({encoder: this.encoder}); + if (workIds) { + workIds.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'work_ids'); + }) + } + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + page, 'page'); + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + 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/work/search`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + params: localVarQueryParameters, + responseType: 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 diff --git a/webapp/src/app/api/model/authorWorkPurposes.ts b/webapp/src/app/api/model/authorWorkPurposes.ts deleted file mode 100644 index bbe4289a..00000000 --- a/webapp/src/app/api/model/authorWorkPurposes.ts +++ /dev/null @@ -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; -} - diff --git a/webapp/src/app/api/model/keywordPatentMatch.ts b/webapp/src/app/api/model/keywordPatentMatch.ts index 3884b93d..9e351d55 100644 --- a/webapp/src/app/api/model/keywordPatentMatch.ts +++ b/webapp/src/app/api/model/keywordPatentMatch.ts @@ -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; - matched_ipc_symbols?: Array; + +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; + matched_ipc_symbols?: Array; } + diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index 3ed9f10e..cabeb96f 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -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'; diff --git a/webapp/src/app/api/model/specificWorkPurpose.ts b/webapp/src/app/api/model/specificWorkPurpose.ts deleted file mode 100644 index 0deaf6cb..00000000 --- a/webapp/src/app/api/model/specificWorkPurpose.ts +++ /dev/null @@ -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 { -} - - diff --git a/webapp/src/app/api/model/workClassification.ts b/webapp/src/app/api/model/workClassification.ts new file mode 100644 index 00000000..12885922 --- /dev/null +++ b/webapp/src/app/api/model/workClassification.ts @@ -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; + /** + * The institutions associated with the work. + */ + institutions?: Array; + /** + * The topics associated with the work. + */ + topics?: Array; + classification?: WorkClassificationDetails | null; + classification_meta?: WorkClassificationMeta | null; + validation?: WorkClassificationValidation | null; +} + diff --git a/webapp/src/app/api/model/workClassificationAuthor.ts b/webapp/src/app/api/model/workClassificationAuthor.ts new file mode 100644 index 00000000..a28e37de --- /dev/null +++ b/webapp/src/app/api/model/workClassificationAuthor.ts @@ -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; +} + diff --git a/webapp/src/app/api/model/workClassificationDetails.ts b/webapp/src/app/api/model/workClassificationDetails.ts new file mode 100644 index 00000000..e096423b --- /dev/null +++ b/webapp/src/app/api/model/workClassificationDetails.ts @@ -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 | null; + classification_reason?: string | null; +} +export namespace WorkClassificationDetails { +} + + diff --git a/webapp/src/app/api/model/workClassificationInstitution.ts b/webapp/src/app/api/model/workClassificationInstitution.ts new file mode 100644 index 00000000..db2eae24 --- /dev/null +++ b/webapp/src/app/api/model/workClassificationInstitution.ts @@ -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; +} + diff --git a/webapp/src/app/api/model/workClassificationMeta.ts b/webapp/src/app/api/model/workClassificationMeta.ts new file mode 100644 index 00000000..eb67e185 --- /dev/null +++ b/webapp/src/app/api/model/workClassificationMeta.ts @@ -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; +} + diff --git a/webapp/src/app/api/model/workClassificationPage.ts b/webapp/src/app/api/model/workClassificationPage.ts new file mode 100644 index 00000000..22b71991 --- /dev/null +++ b/webapp/src/app/api/model/workClassificationPage.ts @@ -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; + /** + * The page number. (0-based) + */ + page?: number; + /** + * The page size in elements. + */ + size?: number; + /** + * The total number of elements. + */ + total?: number; +} + diff --git a/webapp/src/app/api/model/workClassificationTopic.ts b/webapp/src/app/api/model/workClassificationTopic.ts new file mode 100644 index 00000000..5ea5b9f9 --- /dev/null +++ b/webapp/src/app/api/model/workClassificationTopic.ts @@ -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; +} + diff --git a/webapp/src/app/api/model/workClassificationTopicGroup.ts b/webapp/src/app/api/model/workClassificationTopicGroup.ts new file mode 100644 index 00000000..58ce3fe6 --- /dev/null +++ b/webapp/src/app/api/model/workClassificationTopicGroup.ts @@ -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; +} + diff --git a/webapp/src/app/api/model/workClassificationValidation.ts b/webapp/src/app/api/model/workClassificationValidation.ts new file mode 100644 index 00000000..da1db647 --- /dev/null +++ b/webapp/src/app/api/model/workClassificationValidation.ts @@ -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 | null; + corrections?: Array | null; +} + diff --git a/webapp/src/app/api/model/workPrimaryCategory.ts b/webapp/src/app/api/model/workPrimaryCategory.ts new file mode 100644 index 00000000..f802dc3c --- /dev/null +++ b/webapp/src/app/api/model/workPrimaryCategory.ts @@ -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 purpose 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]; + diff --git a/webapp/src/app/api/model/workPurpose.ts b/webapp/src/app/api/model/workPurpose.ts deleted file mode 100644 index df980e6a..00000000 --- a/webapp/src/app/api/model/workPurpose.ts +++ /dev/null @@ -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]; - diff --git a/webapp/src/app/app.routes.ts b/webapp/src/app/app.routes.ts index e983a48c..1c170e81 100644 --- a/webapp/src/app/app.routes.ts +++ b/webapp/src/app/app.routes.ts @@ -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, @@ -39,6 +38,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: '', @@ -386,7 +386,7 @@ export const routes: Routes = [ selectedTopics: selectedTopicsResolver, selectedInstitutions: selectedInstitutionsResolver, authorWorkPage: workPageResolver, - authorWorkPurposes: authorWorkPurposesResolver, + authorWorkClassificationPage: authorWorkClassificationPageResolver, }, data: { resolvingFor: RESOLVING_WORK_PAGE_FOR.PERSON, diff --git a/webapp/src/app/modules/person-publications/person-publications.component.html b/webapp/src/app/modules/person-publications/person-publications.component.html index 8530504d..aeaea15d 100644 --- a/webapp/src/app/modules/person-publications/person-publications.component.html +++ b/webapp/src/app/modules/person-publications/person-publications.component.html @@ -8,7 +8,7 @@ Forschungszwecke - @if (this.authorWorkPurposes().purposes?.length === 0) { + @if (this.authorWorkClassifications().length === 0) {
Keine klassifizierten Publikationen gefunden.
diff --git a/webapp/src/app/modules/person-publications/person-publications.component.ts b/webapp/src/app/modules/person-publications/person-publications.component.ts index 651aefe9..3857fbac 100644 --- a/webapp/src/app/modules/person-publications/person-publications.component.ts +++ b/webapp/src/app/modules/person-publications/person-publications.component.ts @@ -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'; @@ -74,49 +74,55 @@ export class PersonPublicationsComponent { selectedInstitutions = input.required>(); selectedTopics = input.required>(); - authorWorkPurposes = input.required(); + authorWorkClassificationPage = input.required(); + 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, ); }); appliedResearchAmount = computed(() => { return this.countPurpose( - this.authorWorkPurposes().purposes || [], - WorkPurpose.AppliedResearch, + this.authorWorkClassifications(), + WorkPrimaryCategory.AppliedResearch, ); }); nonResearchAmount = computed(() => { return this.countPurpose( - this.authorWorkPurposes().purposes || [], - WorkPurpose.NonResearch, + this.authorWorkClassifications(), + WorkPrimaryCategory.NonResearch, ); }); experimentalDevelopmentAmount = computed(() => { return this.countPurpose( - this.authorWorkPurposes().purposes || [], - WorkPurpose.ExperimentalDevelopment, + this.authorWorkClassifications(), + WorkPrimaryCategory.ExperimentalDevelopment, ); }); notClassifiedAmmount = computed(() => { return this.countPurpose( - this.authorWorkPurposes().purposes || [], - WorkPurpose.NotClassified, + this.authorWorkClassifications(), + 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 +140,31 @@ export class PersonPublicationsComponent { }); } - getAuthorSpecificWorkPurposesByYear( - authorWorkPurposes: AuthorWorkPurposes, - ): Record> { - const purposesByYear: Record> = {}; - for (const purpose of authorWorkPurposes.purposes ?? []) { - const year = purpose.publication_year; + getAuthorWorkClassificationByYear( + authorWorkClassifications: WorkClassification[], + ): Record> { + const workClassificationsByYear: Record< + number, + Array + > = {}; + 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>, + workClassificationsByYear: Record>, ): 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 +173,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++; } } diff --git a/webapp/src/app/resolvers/author-work-classification-page.resolver.ts b/webapp/src/app/resolvers/author-work-classification-page.resolver.ts new file mode 100644 index 00000000..9e20749b --- /dev/null +++ b/webapp/src/app/resolvers/author-work-classification-page.resolver.ts @@ -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); +}; diff --git a/webapp/src/app/resolvers/author-work-purposes.resolver.ts b/webapp/src/app/resolvers/author-work-purposes.resolver.ts deleted file mode 100644 index 15285adb..00000000 --- a/webapp/src/app/resolvers/author-work-purposes.resolver.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ResolveFn } from '@angular/router'; -import { AuthorWorkPurposes, WorksService } from '../api'; -import { inject } from '@angular/core'; - -export const authorWorkPurposesResolver: ResolveFn = ( - 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); -}; diff --git a/webapp/src/app/resolvers/work-page.resolver.ts b/webapp/src/app/resolvers/work-page.resolver.ts index 27800296..8776efa0 100644 --- a/webapp/src/app/resolvers/work-page.resolver.ts +++ b/webapp/src/app/resolvers/work-page.resolver.ts @@ -68,7 +68,7 @@ export const workPageResolver: ResolveFn = ( 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 = ( 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(