feat/ranking #279

Merged
tischer merged 6 commits from feat/ranking into dev 2026-08-15 12:48:05 +02:00
17 changed files with 581 additions and 43 deletions
+79
View File
@@ -24,6 +24,7 @@ from .model import (
FilterType,
KeywordOperator,
PublicationType,
PublicationTypeCount,
RankedAuthor,
RankingWeights,
SubfieldShare,
@@ -788,6 +789,84 @@ def _build_query(
}
def _build_publication_type_counts_query(
keywords: list[str],
operator: KeywordOperator,
author_ids: list[str],
timespan: Timespan | None,
config: MatchConfig = _KEYWORD_MATCH,
) -> dict:
"""Builds the query that counts matching works per publication type.
Mirrors _build_query's work filters but leaves out the publication_types
filter itself, since it aggregates over all types instead of one score.
"""
work_filters = [
_build_keyword_query(keywords, operator, config),
_author_filter(author_ids),
]
if timespan is not None:
work_filters.append(_timespan_filter(timespan))
return {
"size": 0,
"query": {
"bool": {
"filter": work_filters,
},
},
"aggs": {
"by_type": {
"terms": {
"field": "type",
"size": len(PublicationType),
},
},
},
}
async def publication_type_counts_for_keywords(
keywords: list[str],
operator: KeywordOperator,
institution_id: str,
career_stages: list[CareerStage],
timespan: Timespan | None,
filter_type: FilterType = FilterType.KEYWORD,
) -> list[PublicationTypeCount]:
"""Counts the university's matching works per publication type, largest first."""
author_ids = await _get_author_ids_from_institution(institution_id)
if not author_ids:
return []
if career_stages:
author_ids = await _filter_author_ids_by_career_stage(author_ids, career_stages)
query_body = _build_publication_type_counts_query(
keywords, operator, author_ids, timespan, _match_config(filter_type),
)
response: dict[str, Any] = await elasticsearch.search(
index=config.settings.openalex_works_search_index,
body=query_body,
cluster=ESCluster.NES,
)
type_buckets = response.get("aggregations", {}).get("by_type", {}).get("buckets", [])
counts = []
for bucket in type_buckets:
try:
publication_type = PublicationType(bucket["key"])
except ValueError:
continue
counts.append(PublicationTypeCount(type=publication_type, count=bucket["doc_count"]))
counts.sort(key=lambda c: c.count, reverse=True)
return counts
def _display_name_from_bucket(author_bucket: dict) -> str:
"""Reads the authors display name out of the name sub-aggregation."""
name_buckets = author_bucket.get("author_name", {}).get("buckets", [])
+36
View File
@@ -195,6 +195,42 @@ class AuthorMetricsRequest(BaseModel):
)
class PublicationTypeCountsRequest(BaseModel):
keywords: list[str] = Field(
min_length=1,
description="One or more keywords to match works against.",
)
operator: KeywordOperator = Field(
default=KeywordOperator.AND,
description="How to combine the keywords: 'and' or 'or'. Defaults to 'and'.",
)
filter_type: FilterType = Field(
default=FilterType.KEYWORD,
description="What the 'keywords' values match against: 'keyword' (OpenAlex "
"keyword display names) or 'topic' (OpenAlex topic display names). Defaults to 'keyword'.",
)
career_stages: list[CareerStage] = Field(
default_factory=list,
description="Optional filter: only count works of authors in one of these career stages. Empty = no filter.",
)
timespan: Timespan | None = Field(
default=None,
description="Optional filter: only count works whose publication_year is within [from, to].",
)
@field_validator("operator", "filter_type", mode="before")
@classmethod
def operator_case_insensitive(cls, value):
if isinstance(value, str):
return value.lower()
return value
class PublicationTypeCount(BaseModel):
type: PublicationType = Field(description="The OpenAlex work type.")
count: int = Field(description="Number of matching works of this type.")
class AuthorTopicStats(BaseModel):
"""Section 1: combined stats over an author's works that match the topic filter."""
+36
View File
@@ -14,6 +14,8 @@ from .model import (
AuthorTopicProfile,
AuthorTopicStats,
KeywordToAuthorRequest,
PublicationTypeCount,
PublicationTypeCountsRequest,
RankedAuthor,
SelectedAuthorsRequest,
)
@@ -68,6 +70,40 @@ async def rank_author(
filter_type=request.filter_type,
)
# Publication-type facet counts for the "Art der Work" filter
@router.post("/publication-type-counts", response_model=list[PublicationTypeCount])
async def publication_type_counts(
request: PublicationTypeCountsRequest,
access_token_metadata: Annotated[
AccessTokenMetadata, CurrentUserAccessTokenPayloadDep
],
):
institution_id = access_token_metadata.effective_institution_id
if not institution_id:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="No OpenAlex institution is assigned to the current organization.",
)
logger.info(
"publication-type-counts keywords=%s operator=%s filter_type=%s institution_id=%s "
"career_stages=%s timespan=%s",
request.keywords,
request.operator,
request.filter_type,
institution_id,
request.career_stages,
request.timespan,
)
return await logic.publication_type_counts_for_keywords(
keywords=request.keywords,
operator=request.operator,
institution_id=institution_id,
career_stages=request.career_stages,
timespan=request.timespan,
filter_type=request.filter_type,
)
# Compare authors table 1 (topic stats)
@router.post("/topic-stats", response_model=list[AuthorTopicStats])
async def topic_stats(request: SelectedAuthorsRequest):
+134
View File
@@ -39,6 +39,10 @@ import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { KeywordToAuthorRequest } from '../model/keywordToAuthorRequest';
// @ts-ignore
import { PublicationTypeCount } from '../model/publicationTypeCount';
// @ts-ignore
import { PublicationTypeCountsRequest } from '../model/publicationTypeCountsRequest';
// @ts-ignore
import { RankedAuthor } from '../model/rankedAuthor';
// @ts-ignore
import { SelectedAuthorsRequest } from '../model/selectedAuthorsRequest';
@@ -191,6 +195,136 @@ export class RankingService extends BaseService {
);
}
/**
* Publication Type Counts
* @endpoint post /api/rank/publication-type-counts
* @param publicationTypeCountsRequest
* @param secureFgpAcc
* @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 publicationTypeCountsApiRankPublicationTypeCountsPost(
publicationTypeCountsRequest: PublicationTypeCountsRequest,
secureFgpAcc?: string,
observe?: 'body',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<Array<PublicationTypeCount>>;
public publicationTypeCountsApiRankPublicationTypeCountsPost(
publicationTypeCountsRequest: PublicationTypeCountsRequest,
secureFgpAcc?: string,
observe?: 'response',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<HttpResponse<Array<PublicationTypeCount>>>;
public publicationTypeCountsApiRankPublicationTypeCountsPost(
publicationTypeCountsRequest: PublicationTypeCountsRequest,
secureFgpAcc?: string,
observe?: 'events',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<HttpEvent<Array<PublicationTypeCount>>>;
public publicationTypeCountsApiRankPublicationTypeCountsPost(
publicationTypeCountsRequest: PublicationTypeCountsRequest,
secureFgpAcc?: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<any> {
if (
publicationTypeCountsRequest === null ||
publicationTypeCountsRequest === undefined
) {
throw new Error(
'Required parameter publicationTypeCountsRequest was null or undefined when calling publicationTypeCountsApiRankPublicationTypeCountsPost.',
);
}
let localVarHeaders = this.defaultHeaders;
// authentication (HTTPBearer) required
localVarHeaders = this.configuration.addCredentialToHeaders(
'HTTPBearer',
'Authorization',
localVarHeaders,
'Bearer ',
);
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;
// to determine the Content-Type header
const consumes: string[] = ['application/json'];
const httpContentTypeSelected: string | undefined =
this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set(
'Content-Type',
httpContentTypeSelected,
);
}
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/rank/publication-type-counts`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<PublicationTypeCount>>(
'post',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
body: publicationTypeCountsRequest,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined
? { transferCache: localVarTransferCache }
: {}),
reportProgress: reportProgress,
},
);
}
/**
* Rank Author
* @endpoint post /api/rank/rank-author
+2
View File
@@ -202,6 +202,8 @@ export * from './projectsSortBy';
export * from './publicationDetailByFunder';
export * from './publicationIdsByAuthorPosition';
export * from './publicationType';
export * from './publicationTypeCount';
export * from './publicationTypeCountsRequest';
export * from './publicationsByAuthorResponse';
export * from './rankedAuthor';
export * from './rankingResponse';
@@ -0,0 +1,22 @@
/**
* 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 { PublicationType } from './publicationType';
export interface PublicationTypeCount {
/**
* The OpenAlex work type.
*/
type: PublicationType;
/**
* Number of matching works of this type.
*/
count: number;
}
export namespace PublicationTypeCount {}
@@ -0,0 +1,34 @@
/**
* 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 { Timespan } from './timespan';
import { FilterType } from './filterType';
import { CareerStage } from './careerStage';
import { KeywordOperator } from './keywordOperator';
export interface PublicationTypeCountsRequest {
/**
* One or more keywords to match works against.
*/
keywords: Array<string>;
/**
* How to combine the keywords: \'and\' or \'or\'. Defaults to \'and\'.
*/
operator?: KeywordOperator;
/**
* What the \'keywords\' values match against: \'keyword\' (OpenAlex keyword display names) or \'topic\' (OpenAlex topic display names). Defaults to \'keyword\'.
*/
filter_type?: FilterType;
/**
* Optional filter: only count works of authors in one of these career stages. Empty = no filter.
*/
career_stages?: Array<CareerStage>;
timespan?: Timespan | null;
}
export namespace PublicationTypeCountsRequest {}
@@ -32,7 +32,19 @@
<span class="meta-label">Betrachtete Personen:</span>
<div class="meta-chip-group">
@for (author of summary(); track author.authorId) {
<app-chip [color]="author.color">{{ author.name }}</app-chip>
<app-chip [color]="author.color">
<a
class="chip-link"
[routerLink]="[
'/person',
authorProfileId(author.authorId),
'overview',
]"
title="Zur Autor:innen-Seite">
{{ author.name }}
<mat-icon>open_in_new</mat-icon>
</a>
</app-chip>
}
</div>
</div>
@@ -159,7 +171,19 @@
<th class="metric-col">Kennzahl</th>
@for (author of summary(); track author.authorId) {
<th class="author-col">
<app-chip [color]="author.color">{{ author.name }}</app-chip>
<app-chip [color]="author.color">
<a
class="chip-link"
[routerLink]="[
'/person',
authorProfileId(author.authorId),
'overview',
]"
title="Zur Autor:innen-Seite">
{{ author.name }}
<mat-icon>open_in_new</mat-icon>
</a>
</app-chip>
</th>
}
</tr>
@@ -168,7 +192,16 @@
@for (row of rows; track row.label) {
<tr>
<th scope="row" class="metric-col">
<span class="metric-label">{{ row.label }}</span>
<span class="metric-label">
{{ row.label }}
@if (row.nameMatched) {
<mat-icon
class="icon-small name-match-star"
aria-hidden="true">
star
</mat-icon>
}
</span>
<span class="metric-hint">{{ row.hint }}</span>
@if (row.kind === 'group') {
<span class="position-legend">
@@ -222,4 +255,12 @@
</tbody>
</table>
</div>
@if (hasNameMatchedRow(rows)) {
<p class="name-match-note">
<mat-icon class="icon-small">star</mat-icon>
Diese Kennzahlen basieren auf einem automatischen Namensabgleich mit
externen Quellen, wodurch es in Einzelfällen zu Fehlzuordnungen kommen
kann.
</p>
}
</ng-template>
@@ -60,6 +60,28 @@ app-chip mat-icon {
vertical-align: text-bottom;
}
.chip-link {
display: inline-flex;
align-items: center;
gap: 4px;
margin: -4px -12px;
padding: 4px 12px;
color: inherit;
text-decoration: none;
cursor: pointer;
mat-icon {
font-size: 14px;
width: 14px;
height: 14px;
opacity: 0.7;
}
&:hover mat-icon {
opacity: 1;
}
}
/* ---- cards ---- */
.card {
background: var(--sg-card-bg);
@@ -122,7 +144,10 @@ app-chip mat-icon {
}
.metric-label {
display: block;
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
font-weight: 600;
color: var(--sg-text);
}
@@ -135,6 +160,31 @@ app-chip mat-icon {
color: var(--sg-text-soft);
}
.icon-small {
font-size: 14px;
width: 14px;
height: 14px;
vertical-align: text-bottom;
}
.name-match-star {
color: var(--sg-warning, #b8860b);
}
.name-match-note {
display: flex;
align-items: center;
gap: 6px;
margin: 10px 0 0;
font-size: 12px;
color: var(--sg-text-muted);
mat-icon {
flex: 0 0 auto;
color: var(--sg-warning, #b8860b);
}
}
.value-cell {
text-align: center;
font-variant-numeric: tabular-nums;
@@ -1,6 +1,6 @@
import { Component, OnInit, computed, inject, signal } from '@angular/core';
import { DecimalPipe, NgTemplateOutlet } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { MatIconModule } from '@angular/material/icon';
import { EChartsOption } from 'echarts';
import { NgxEchartsDirective } from 'ngx-echarts';
@@ -98,6 +98,7 @@ interface MetricRow {
cells: MetricCell[];
segments: GroupSegment[];
groupCells: GroupCell[];
nameMatched: boolean;
}
interface RowDef {
@@ -105,6 +106,7 @@ interface RowDef {
hint: string;
select: (a: AuthorSummary) => number | null;
decimals?: boolean;
nameMatched?: boolean;
}
interface SegmentDef {
@@ -121,6 +123,7 @@ interface SegmentDef {
imports: [
DecimalPipe,
NgTemplateOutlet,
RouterLink,
MatIconModule,
NgxEchartsDirective,
AuthorResearchProfileComponent,
@@ -385,15 +388,18 @@ export class CompareAuthorsComponent implements OnInit {
label: 'Unternehmensgründungen',
hint: 'Handelsregister-Verbindungen über den Namen',
select: (a) => a.companies,
nameMatched: true,
},
{
label: 'News-Artikel',
hint: 'Nachrichtenartikel, die die Person namentlich nennen',
select: (a) => a.news,
nameMatched: true,
},
{
label: 'Patente',
hint: 'Der Person zugeordnete Patente',
nameMatched: true,
select: (a) => a.patents,
},
]),
@@ -469,6 +475,11 @@ export class CompareAuthorsComponent implements OnInit {
);
}
authorProfileId(authorId: string): string {
const parts = authorId.split('/');
return parts[parts.length - 1];
}
// colours the author names on the chart axes like the legend chips
private authorAxisLabel(profiles: AuthorTopicProfile[]) {
const rich: Record<string, { color: string; fontWeight: number }> = {};
@@ -707,6 +718,7 @@ export class CompareAuthorsComponent implements OnInit {
})),
segments: [],
groupCells: [],
nameMatched: def.nameMatched ?? false,
};
});
}
@@ -731,9 +743,14 @@ export class CompareAuthorsComponent implements OnInit {
groupCells: this.summary().map((a) => ({
values: segs.map((s) => s.select(a)),
})),
nameMatched: false,
};
}
hasNameMatchedRow(rows: MetricRow[]): boolean {
return rows.some((row) => row.nameMatched);
}
ngOnInit(): void {
// everything is read from the URL so a shared link lands on the same view
const rawAuthors = this.route.snapshot.queryParamMap.get('authors') ?? '';
@@ -104,8 +104,10 @@
}
</div>
@for (pt of filteredPubTypes(); track pt) {
<mat-option [value]="pt">{{ pt }}</mat-option>
@for (pt of filteredPubTypes(); track pt.type) {
<mat-option [value]="pt.type"
>{{ pt.type }} ({{ pt.count }})</mat-option
>
}
</mat-select>
</mat-form-field>
@@ -25,6 +25,8 @@ import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slide
import {
CareerStage,
KeywordToAuthorRequest,
PublicationTypeCount,
PublicationTypeCountsRequest,
RankedAuthor,
RankingService,
} from '../../../../api';
@@ -116,6 +118,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
icon: 'business',
description:
'Gewichtet die Anzahl der Unternehmensgründungen (Handelsregister-Verbindungen).',
nameMatched: true,
defaultValue: 0.5,
queryParamName: 'wCompanies',
},
@@ -125,6 +128,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
icon: 'visibility',
description:
'Gewichtet die öffentliche Sichtbarkeit über Nennungen in Nachrichtenartikeln.',
nameMatched: true,
defaultValue: 0.5,
queryParamName: 'wNews',
},
@@ -133,6 +137,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
label: 'Patente',
icon: 'workspace_premium',
description: 'Gewichtet Innovations- und Transferleistung über Patente.',
nameMatched: true,
defaultValue: 0.5,
queryParamName: 'wPatents',
},
@@ -174,33 +179,8 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
];
readonly companyStatus = signal<'all' | 'active' | 'deleted'>('all');
// publication types
readonly ALL_PUBLICATION_TYPES = [
'article',
'other',
'dataset',
'book-chapter',
'book',
'dissertation',
'preprint',
'paratext',
'libguides',
'review',
'letter',
'reference-entry',
'editorial',
'peer-review',
'report',
'standard',
'erratum',
'retraction',
'supplementary-materials',
'book-section',
'database',
'software',
'report-component',
'grant',
];
// publication types: counted from the index (count-by), largest first
readonly publicationTypeCounts = signal<PublicationTypeCount[]>([]);
readonly pubTypeSearchTerm = signal('');
@@ -213,10 +193,9 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
readonly filteredPubTypes = computed(() => {
const term = this.pubTypeSearchTerm().toLowerCase();
if (!term) return this.ALL_PUBLICATION_TYPES;
return this.ALL_PUBLICATION_TYPES.filter((pt) =>
pt.toLowerCase().includes(term),
);
const counts = this.publicationTypeCounts();
if (!term) return counts;
return counts.filter((pt) => pt.type.toLowerCase().includes(term));
});
onPubTypesChange(selected: string[]) {
@@ -253,6 +232,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
replaceUrl: true,
});
this.loadAuthors();
this.loadPublicationTypeCounts();
}
readonly CAREER_STAGE_OPTIONS = [
@@ -314,6 +294,8 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
if (operator === 'and' || operator === 'or') {
this.keywordOperator.set(operator);
}
this.loadPublicationTypeCounts();
}
// reads a year query param, clamped to the valid range; falls back on invalid input
@@ -400,6 +382,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
}
this.writeTimespanToUrl();
this.loadAuthors();
this.loadPublicationTypeCounts();
}
// the backend returns the full OpenAlex url; the profile route needs only the id
@@ -494,4 +477,30 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
},
});
}
// counts, by publication type, of the works matching the current keyword/
// career-stage/timespan filters — drives the "Art der Work" filter options
private loadPublicationTypeCounts(): void {
const request: PublicationTypeCountsRequest = {
keywords: this.state.topicsList(),
operator: this.keywordOperator(),
filter_type: 'topic',
career_stages:
this.careerStages().length > 0 ? this.careerStages() : undefined,
timespan: {
from: this.timespanFrom(),
to: this.timespanTo(),
},
};
this.rankingService
.publicationTypeCountsApiRankPublicationTypeCountsPost(request)
.subscribe({
next: (counts) => this.publicationTypeCounts.set(counts),
error: (error) => {
console.error(error);
this.publicationTypeCounts.set([]);
},
});
}
}
@@ -22,9 +22,14 @@
<span class="mode-badge">
<mat-slide-toggle
labelPosition="before"
matTooltip="Wenn aktiviert, werden die extrahierten Keywords auf bekannte Themenbereiche abgebildet, man kann dann nach Themen filtern. Wenn deaktiviert, werden die Keywords direkt für die Suche verwendet."
[matTooltip]="
isPersonsTab()
? 'Auf dem Personen-Tab wird immer nach Themen gerankt, daher ist Fuzzy Search hier fest aktiviert.'
: 'Wenn aktiviert, werden die extrahierten Keywords auf bekannte Themenbereiche abgebildet, man kann dann nach Themen filtern. Wenn deaktiviert, werden die Keywords direkt für die Suche verwendet.'
"
(change)="onToggleFuzzySearch($event)"
[checked]="state.fuzzySearch()">
[checked]="state.fuzzySearch()"
[disabled]="isPersonsTab()">
Fuzzy Search
</mat-slide-toggle>
</span>
@@ -72,8 +77,8 @@
[active]="rla.isActive"
[queryParams]="{
keywords: state.payload()?.keywords?.join(','),
fuzzy: state.payload()?.options?.fuzzy,
topics: state.payload()?.options?.fuzzy ? state.topicIds() : null,
fuzzy: tabFuzzyValue(route),
topics: tabFuzzyValue(route) ? state.topicIds() : null,
topicId: null,
}"
queryParamsHandling="replace">
@@ -63,6 +63,8 @@ export class KeywordsSearchResultsComponent {
{ path: 'trends', label: 'Visualisierung', icon: 'bar_chart' },
];
private readonly lastUserFuzzy = signal(false);
readonly selectedKeywordCount = computed(() => this.state.keywords().length);
readonly allKeywordEntries = computed(() => {
const seen = new Set<string>();
@@ -85,7 +87,12 @@ export class KeywordsSearchResultsComponent {
// previous search never gets silently applied to a new one.
this.route.queryParamMap.pipe(takeUntilDestroyed()).subscribe((params) => {
const keywords = this.parseKeywordList(params.get('keywords'));
const fuzzySearch = params.get('fuzzy') === 'true';
const onPersonsTab = this.isPersonsTab();
const fuzzySearch = onPersonsTab || params.get('fuzzy') === 'true';
if (!onPersonsTab) {
this.lastUserFuzzy.set(params.get('fuzzy') === 'true');
}
const cached = this.readHandoffCache();
const cacheMatches =
@@ -100,8 +107,22 @@ export class KeywordsSearchResultsComponent {
? cached!.patentKeywordEntries
: undefined,
});
if (onPersonsTab && params.get('fuzzy') !== 'true') {
this.updateQueryParams(true);
}
});
}
// the Fuzzy Search toggle is locked on while the Personen tab is active
isPersonsTab(): boolean {
return this.route.snapshot.firstChild?.routeConfig?.path === 'persons';
}
tabFuzzyValue(route: { path: string }): boolean {
if (route.path === 'persons') return true;
return this.lastUserFuzzy();
}
goBackToSearch(): void {
void this.router.navigate(['/keywords'], {
queryParamsHandling: 'merge',
@@ -25,6 +25,11 @@
<mat-icon class="icon-small">{{ option.icon }}</mat-icon>
}
<span>{{ option.label }}</span>
@if (option.nameMatched) {
<mat-icon class="icon-small name-match-star" aria-hidden="true">
star
</mat-icon>
}
</div>
<div class="slider-container">
@@ -51,6 +56,16 @@
}
</div>
<!-- Name-Match Note -->
@if (hasNameMatchedOption) {
<p class="name-match-note">
<mat-icon class="icon-small">star</mat-icon>
Diese Kennzahlen basieren auf einem automatischen Namensabgleich mit
externen Quellen, wodurch es in Einzelfällen zu Fehlzuordnungen kommen
kann.
</p>
}
<!-- Validation Warning -->
@if (!weightsState().valid) {
<div class="weight-warning">
@@ -77,6 +77,7 @@ $touch-target: 44px;
width: 14px;
height: 14px;
color: var(--sg-text-muted);
flex-shrink: 0;
}
span {
@@ -84,6 +85,8 @@ $touch-target: 44px;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: 500;
flex: 1;
min-width: 0;
}
}
@@ -108,6 +111,28 @@ $touch-target: 44px;
padding: 0 6px;
}
::ng-deep .weight-label .icon-small.name-match-star {
color: var(--sg-warning, #b8860b);
}
/* ============================================================
NAME MATCH NOTE
============================================================ */
.name-match-note {
display: flex;
align-items: center;
gap: 0.3rem;
margin: 0.3rem 0 0;
padding: 0.2rem 0.3rem;
font-size: 0.7rem;
color: var(--sg-text-muted);
mat-icon {
flex: 0 0 auto;
color: var(--sg-warning, #b8860b);
}
}
/* ============================================================
WARNING
============================================================ */
@@ -28,6 +28,12 @@ export interface WeightSliderOption {
icon?: string;
description?: string;
/**
* Marks this metric with a star, indicating it relies on name matching
* (see weight-name-match-note in the template).
*/
nameMatched?: boolean;
/**
* Optional default raw weight.
* Must be between 0 and 1.
@@ -212,6 +218,10 @@ export class WeightsSlidersComponent implements OnInit, OnChanges {
}
}
get hasNameMatchedOption(): boolean {
return this.options.some((option) => option.nameMatched);
}
weightControl(key: string): FormControl<number> {
const control = this.form.controls[key];