feat: improve patent matching with disambiguation pipeline and caching
LocationBasedServices/smartguide/pipeline/head There was a failure building this commit

This commit is contained in:
2026-06-15 20:27:21 +02:00
parent bc7b7784ea
commit 0dd03e0ae0
15 changed files with 1642 additions and 314 deletions
+47
View File
@@ -32,7 +32,22 @@ export interface PatentEntry {
assignees: string[];
ipc: string[];
country: string | null;
orcid?: string | null;
confidence_score: number;
match_signals?: string[];
}
export interface PatentSearchMeta {
epo_total_hits: number;
uspto_total_hits: number;
epo_returned_hits: number;
uspto_returned_hits: number;
matched_count: number;
epo_truncated: boolean;
uspto_truncated: boolean;
coauthor_signals: number;
publication_keywords: number;
rebuild_failed?: boolean;
}
export interface PatentsByAuthorResponse {
@@ -40,6 +55,9 @@ export interface PatentsByAuthorResponse {
author_name: string | null;
patent_count: number;
patents: PatentEntry[];
from_cache?: boolean;
last_built_at?: string | null;
search_meta?: PatentSearchMeta | null;
}
@Injectable({
@@ -99,6 +117,7 @@ export class PatentsService extends BaseService {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
refresh?: boolean;
},
): Observable<any> {
if (authorId === null || authorId === undefined) {
@@ -147,12 +166,18 @@ export class PatentsService extends BaseService {
dataFormat: undefined,
})}/patents`;
let localVarQueryParameters = new HttpParams({ encoder: new CustomHttpParameterCodec() });
if (options?.refresh) {
localVarQueryParameters = localVarQueryParameters.set('refresh', 'true');
}
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<PatentsByAuthorResponse>(
'get',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
@@ -164,4 +189,26 @@ export class PatentsService extends BaseService {
},
);
}
public rebuildPatentsByAuthor(authorId: string): Observable<PatentsByAuthorResponse> {
const localVarPath = `/api/inse-service/authors/${this.configuration.encodeParam({
name: 'authorId',
value: authorId,
in: 'path',
style: 'simple',
explode: false,
dataType: 'string',
dataFormat: undefined,
})}/patents/rebuild`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.post<PatentsByAuthorResponse>(
`${basePath}${localVarPath}`,
null,
{
...(withCredentials ? { withCredentials } : {}),
headers: this.defaultHeaders,
},
);
}
}
@@ -20,6 +20,21 @@
<span class="summary-value">{{ getUsptoCount() }}</span>
<span class="summary-label"> USPTO</span>
</p>
@if (fromCache) {
<p class="summary-line summary-line--meta">
<span class="summary-label">Aus Cache</span>
@if (lastBuiltAt) {
<span class="summary-label"> · {{ formatDate(lastBuiltAt) }}</span>
}
</p>
}
<button
class="rebuild-button"
type="button"
[disabled]="rebuilding"
(click)="rebuildPatents()">
{{ rebuilding ? 'Aktualisiere...' : 'Neu zuordnen' }}
</button>
</div>
<div class="patents-content">
@@ -101,6 +116,17 @@
</div>
</div>
@if (selectedPatent.match_signals?.length) {
<div class="detail-section">
<h4>Zuordnungs-Signale</h4>
<ul class="tag-list tag-list--compact">
@for (signal of selectedPatent.match_signals; track signal) {
<li class="tag tag--signal">{{ formatSignal(signal) }}</li>
}
</ul>
</div>
}
@if (selectedPatent.abstract) {
<div class="detail-section">
<h4>Abstract</h4>
@@ -14,6 +14,8 @@
margin-bottom: 8px;
display: flex;
gap: 24px;
align-items: center;
flex-wrap: wrap;
.summary-line {
margin: 0;
@@ -21,6 +23,27 @@
color: #333;
}
.summary-line--meta {
color: #666;
font-size: 13px;
}
.rebuild-button {
margin-left: auto;
padding: 8px 14px;
border: 1px solid #bdd4ff;
border-radius: 20px;
background: #f0f6ff;
color: #0b63ce;
cursor: pointer;
font-size: 14px;
&:disabled {
opacity: 0.6;
cursor: default;
}
}
.summary-label {
color: #333;
}
@@ -263,6 +286,12 @@
color: #1e40af;
font-size: 0.8rem;
line-height: 1.3;
&--signal {
background: #eef7ee;
border-color: #cfe6cf;
color: #2f6b2f;
}
}
.pagination {
@@ -1,11 +1,27 @@
import { Component, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { PatentsService, PatentEntry } from '../../api/api/patents.service';
import {
PatentsService,
PatentEntry,
PatentSearchMeta,
} from '../../api/api/patents.service';
type SortMode = 'score' | 'date' | 'title';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
const SIGNAL_LABELS: Record<string, string> = {
full_name_match: 'Vollständiger Name',
last_name_match: 'Nachname',
first_name_match: 'Vorname',
institution_match: 'Institution',
orcid_match: 'ORCID',
topic_match: 'Forschungsthema',
coauthor_match: 'Ko-Autor',
publication_topic_match: 'Publikations-Thema',
manual_include: 'Manuell hinzugefügt',
};
@Component({
selector: 'app-person-patents',
imports: [CommonModule],
@@ -21,9 +37,14 @@ export class PersonPatentsComponent implements OnInit {
filteredPatents: PatentEntry[] = [];
authorName: string | null = null;
selectedPatent: PatentEntry | null = null;
searchMeta: PatentSearchMeta | null = null;
fromCache = false;
lastBuiltAt: string | null = null;
loading = true;
rebuilding = false;
error = false;
authorId = '';
activeFilter: SourceFilter = 'all';
sortMode: SortMode = 'score';
@@ -33,7 +54,7 @@ export class PersonPatentsComponent implements OnInit {
ngOnInit(): void {
this.route.parent?.paramMap.subscribe((params) => {
const authorId = params.get('id') ?? '';
this.authorId = params.get('id') ?? '';
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
const sortFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
@@ -45,23 +66,51 @@ export class PersonPatentsComponent implements OnInit {
this.sortMode = sortFromUrl;
}
if (authorId) {
this.patentsApi.getPatentsByAuthor(authorId, 'body').subscribe({
next: (result) => {
this.patents = result.patents ?? [];
this.authorName = result.author_name ?? null;
this.applyFilter();
this.loading = false;
},
error: () => {
this.error = true;
this.loading = false;
},
});
if (this.authorId) {
this.loadPatents();
}
});
}
loadPatents(refresh = false): void {
this.loading = true;
this.error = false;
this.patentsApi
.getPatentsByAuthor(this.authorId, 'body', false, {
refresh,
transferCache: false,
})
.subscribe({
next: (result) => this.applyResult(result),
error: () => {
this.error = true;
this.loading = false;
},
});
}
rebuildPatents(): void {
if (!this.authorId || this.rebuilding) {
return;
}
this.rebuilding = true;
this.error = false;
this.patentsApi.rebuildPatentsByAuthor(this.authorId).subscribe({
next: (result) => {
this.applyResult(result);
this.rebuilding = false;
},
error: () => {
this.error = true;
this.rebuilding = false;
this.loading = false;
},
});
}
setFilter(filter: SourceFilter): void {
this.activeFilter = filter;
this.selectedPage = 1;
@@ -81,6 +130,26 @@ export class PersonPatentsComponent implements OnInit {
this.updateQueryParams();
}
formatSignal(signal: string): string {
return SIGNAL_LABELS[signal] ?? signal;
}
private applyResult(result: {
patents?: PatentEntry[];
author_name?: string | null;
from_cache?: boolean;
last_built_at?: string | null;
search_meta?: PatentSearchMeta | null;
}): void {
this.patents = result.patents ?? [];
this.authorName = result.author_name ?? null;
this.fromCache = result.from_cache ?? false;
this.lastBuiltAt = result.last_built_at ?? null;
this.searchMeta = result.search_meta ?? null;
this.applyFilter();
this.loading = false;
}
private applyFilter(): void {
let patents = this.patents;