Added fakordb tests
LocationBasedServices/smartguide/pipeline/head There was a failure building this commit

This commit is contained in:
2026-11-03 13:50:10 +01:00
parent 0b19f6c6af
commit 552fa2daaf
24 changed files with 3872 additions and 3 deletions
+282
View File
@@ -0,0 +1,282 @@
# Query cookbook for the `ude` graph
Cypher examples for the whole-university graph built by `bulk_load.py` (FalkorDB Browser at
http://localhost:3000, graph `ude`, or `FalkorDB(host="localhost").select_graph("ude").ro_query(...)`).
Every example was run against the graph on 2026-09-15; timings are from that run.
Conventions:
- `Author` nodes of the university's own researchers carry the extra label `Cohort` (indexed).
Start queries there whenever you can.
- `CO_AUTHOR` edges are undirected in meaning (stored from the smaller to the larger author id);
match them without an arrow: `(a)-[c:CO_AUTHOR]-(b)`.
- Aggregations render as tables. To see a graph, return nodes and relationships (or paths).
- Queries that touch the whole graph take 2 to 20 s; raise the browser's timeout first
(`docker exec pensive_tu redis-cli GRAPH.CONFIG SET TIMEOUT 60000`).
- Results are capped at 10,000 rows by the server (`RESULTSET_SIZE`).
## Overview
```cypher
MATCH (n) RETURN labels(n), count(n) ORDER BY count(n) DESC
```
```cypher
MATCH ()-[r]->() RETURN type(r), count(r) ORDER BY count(r) DESC
```
Everything around one researcher, for the canvas:
```cypher
MATCH (a:Cohort {name: 'Nikolai Axmacher'})-[r]-(n) RETURN a, r, n LIMIT 300
```
Source coverage of the cohort (works, projects, patents, news, companies):
```cypher
MATCH (a:Cohort)
OPTIONAL MATCH (a)-[:AUTHORED]->(w:Work) WITH a, count(DISTINCT w) AS works
OPTIONAL MATCH (a)-[:CONTRIBUTED_TO|DFG_ROLE]->(p:Project) WITH a, works, count(DISTINCT p) AS projects
OPTIONAL MATCH (a)-[:INVENTOR_OF]->(pt:Patent) WITH a, works, projects, count(DISTINCT pt) AS patents
OPTIONAL MATCH (a)-[:MENTIONED_IN]->(n:NewsArticle) WITH a, works, projects, patents, count(DISTINCT n) AS news
OPTIONAL MATCH (a)-[:OFFICER_OF]->(c:Company) WITH a, works, projects, patents, news, count(DISTINCT c) AS companies
RETURN count(a) AS cohort,
sum(CASE WHEN works > 0 THEN 1 ELSE 0 END) AS with_works,
sum(CASE WHEN projects > 0 THEN 1 ELSE 0 END) AS with_projects,
sum(CASE WHEN patents > 0 THEN 1 ELSE 0 END) AS with_patents,
sum(CASE WHEN news > 0 THEN 1 ELSE 0 END) AS with_news,
sum(CASE WHEN companies > 0 THEN 1 ELSE 0 END) AS with_companies
```
## Topics, subfields, fields and domains of the institution
The path from the institution: `Institution <-[:REPRESENTS]- Organization <-[:MEMBER_OF]- Cohort`.
Domains with counts (2.1 s):
```cypher
MATCH (:Institution {id: 'I62318514'})<-[:REPRESENTS]-(:Organization)<-[:MEMBER_OF]-(:Cohort)-[:AUTHORED]->(w:Work)
-[:HAS_TOPIC]->(t:Topic)-[:IN_SUBFIELD]->(s:Subfield)-[:IN_FIELD]->(f:Field)-[:IN_DOMAIN]->(d:Domain)
RETURN d.name AS domain, count(DISTINCT f) AS fields, count(DISTINCT s) AS subfields,
count(DISTINCT t) AS topics, count(DISTINCT w) AS works
ORDER BY works DESC
```
Full hierarchy table, strongest topics first (2.4 s; drop `LIMIT` for all 4,336 topics):
```cypher
MATCH (:Institution {id: 'I62318514'})<-[:REPRESENTS]-(:Organization)<-[:MEMBER_OF]-(:Cohort)-[:AUTHORED]->(w:Work)
-[:HAS_TOPIC]->(t:Topic)-[:IN_SUBFIELD]->(s:Subfield)-[:IN_FIELD]->(f:Field)-[:IN_DOMAIN]->(d:Domain)
RETURN d.name AS domain, f.name AS field, s.name AS subfield, t.name AS topic, count(DISTINCT w) AS works
ORDER BY works DESC LIMIT 100
```
Fields by number of researchers, using OpenAlex's author-level topics (0.1 s):
```cypher
MATCH (:Institution {id: 'I62318514'})<-[:REPRESENTS]-(:Organization)<-[:MEMBER_OF]-(a:Cohort)-[:WORKS_ON]->(t:Topic)
-[:IN_SUBFIELD]->(s:Subfield)-[:IN_FIELD]->(f:Field)-[:IN_DOMAIN]->(d:Domain)
RETURN d.name AS domain, f.name AS field, count(DISTINCT a) AS researchers, count(DISTINCT t) AS topics
ORDER BY researchers DESC
```
### Graph versions via the research profile edges
The `profile` phase materialises `(Institution)-[:ACTIVE_IN {level, works, researchers}]->(Topic|Subfield|Field|Domain)`,
so the counts live on drawable edges. Set the node caption of Domain/Field/Subfield/Topic to `name`.
Domains as a star around the institution, and domains with their fields:
```cypher
MATCH (i:Institution {id: 'I62318514'})-[r:ACTIVE_IN]->(d:Domain) RETURN i, r, d
```
```cypher
MATCH (i:Institution {id: 'I62318514'})-[r:ACTIVE_IN]->(f:Field)-[c:IN_DOMAIN]->(d:Domain)
RETURN i, r, f, c, d
```
Tree of the strongest topics attached to the institution (lower `800` to widen; add
`AND d.name = 'Physical Sciences'` for one domain):
```cypher
MATCH (i:Institution {id: 'I62318514'})-[r:ACTIVE_IN {level: 'topic'}]->(t:Topic) WHERE r.works >= 800
MATCH (t)-[a:IN_SUBFIELD]->(s:Subfield)-[b:IN_FIELD]->(f:Field)-[c:IN_DOMAIN]->(d:Domain)
RETURN i, r, t, a, s, b, f, c, d
```
Fields by researchers:
```cypher
MATCH (i:Institution {id: 'I62318514'})-[r:ACTIVE_IN]->(f:Field) WHERE r.researchers >= 300
RETURN i, r, f
```
Without materialised edges: aggregate in a `WITH`, keep the top nodes, match the hierarchy again
and return nodes and relationships (the counts are not shown, the institution is not connected):
```cypher
MATCH (:Institution {id: 'I62318514'})<-[:REPRESENTS]-(:Organization)<-[:MEMBER_OF]-(:Cohort)-[:AUTHORED]->(w:Work)-[:HAS_TOPIC]->(t:Topic)
WITH t, count(DISTINCT w) AS works ORDER BY works DESC LIMIT 40
MATCH (t)-[a:IN_SUBFIELD]->(s:Subfield)-[b:IN_FIELD]->(f:Field)-[c:IN_DOMAIN]->(d:Domain)
RETURN t, a, s, b, f, c, d
```
## Collaboration
Strongest collaborations inside the university:
```cypher
MATCH (a:Cohort)-[c:CO_AUTHOR]->(b:Cohort)
RETURN a.name, b.name, c.weight, c.first_year, c.last_year ORDER BY c.weight DESC LIMIT 20
```
Top external partner institutions (4 s):
```cypher
MATCH (a:Cohort)-[:CO_AUTHOR]-(b:Author)-[:AFFILIATED_WITH]->(i:Institution)
WHERE NOT b:Cohort AND i.id <> 'I62318514'
RETURN i.name, i.country_code, count(DISTINCT b) AS partners ORDER BY partners DESC LIMIT 20
```
## Industry collaborations
OpenAlex types institutions as `education`, `healthcare`, `company`, `government`, `nonprofit`,
`facility`, `funder` or `other`; the value is stored as `Institution.type`. Industry means
`type = 'company'`. Two caveats: OpenAlex contains junk "companies" resolved from generic
affiliation strings (`Faculty (United Kingdom)`, `Signal Processing (United States)`,
`Engineering (Italy)`), and the author-level `AFFILIATED_WITH` edge is not tied to a paper, so a
co-author who was ever at a company counts on every shared work. The `affiliations` phase adds the
per-work view: `AUTHORED.institution_ids` and `(Work)-[:INVOLVES {authors}]->(Institution)`.
Prefer the per-work queries below; the author-level ones are kept as a quick approximation.
How much it matters (validated 2026-09-15): for Daniel Erni the per-work view gives 10 industry
co-publications with 4 companies (IBM, CETC, CSEM, ID Quantique), the author-level view claims 61
joint works with 8 companies. University-wide, 15,569 works involve 3,874 companies. A further
caveat is OpenAlex author disambiguation: a few cohort profiles are merged with namesakes
(`Róbert Langer` carries the MIT chemist's industry ties), so check `orcid` before trusting an outlier.
### Per work (precise)
Companies on the papers of one researcher, with the co-authors who were at the company on that paper:
```cypher
MATCH (a:Cohort {name: 'Daniel Erni'})-[:AUTHORED]->(w:Work)-[:INVOLVES]->(i:Institution {type: 'company'})
MATCH (w)<-[e:AUTHORED]-(b:Author) WHERE i.id IN e.institution_ids
RETURN i.name AS company, i.country_code AS country, count(DISTINCT w) AS works,
collect(DISTINCT b.name)[0..4] AS company_coauthors
ORDER BY works DESC
```
The same as a graph (researcher, shared works, companies):
```cypher
MATCH (a:Cohort {name: 'Daniel Erni'})-[x:AUTHORED]->(w:Work)-[v:INVOLVES]->(i:Institution {type: 'company'})
RETURN a, x, w, v, i
```
Industry partners of researchers from a field (author-level OpenAlex topics define the field):
```cypher
MATCH (a:Cohort)-[:WORKS_ON]->(:Topic)-[:IN_SUBFIELD]->()-[:IN_FIELD]->(:Field {name: 'Engineering'})
WITH DISTINCT a
MATCH (a)-[:AUTHORED]->(w:Work)-[:INVOLVES]->(i:Institution {type: 'company'})
RETURN i.name AS company, i.country_code AS country,
count(DISTINCT a) AS ude_researchers, count(DISTINCT w) AS joint_works
ORDER BY ude_researchers DESC LIMIT 25
```
Researchers of a field ranked by industry ties:
```cypher
MATCH (a:Cohort)-[:WORKS_ON]->(:Topic)-[:IN_SUBFIELD]->()-[:IN_FIELD]->(:Field {name: 'Engineering'})
WITH DISTINCT a
MATCH (a)-[:AUTHORED]->(w:Work)-[:INVOLVES]->(i:Institution {type: 'company'})
RETURN a.name, count(DISTINCT i) AS companies, count(DISTINCT w) AS works, collect(DISTINCT i.name)[0..3] AS sample
ORDER BY companies DESC LIMIT 20
```
Industry co-publications per year for one researcher:
```cypher
MATCH (a:Cohort {name: 'Daniel Erni'})-[:AUTHORED]->(w:Work)-[:INVOLVES]->(i:Institution {type: 'company'})
RETURN w.year, count(DISTINCT w) AS works, collect(DISTINCT i.name)[0..3] AS companies
ORDER BY w.year DESC
```
Graph view for a field: researchers, their industry co-authored works and the companies
(the `LIMIT` keeps the canvas readable):
```cypher
MATCH (a:Cohort)-[:WORKS_ON]->(:Topic)-[:IN_SUBFIELD]->()-[:IN_FIELD]->(:Field {name: 'Engineering'})
WITH DISTINCT a
MATCH (a)-[x:AUTHORED]->(w:Work)-[v:INVOLVES]->(i:Institution {type: 'company'})
WITH a, x, w, v, i ORDER BY w.year DESC LIMIT 200
RETURN a, x, w, v, i
```
### Author level (approximate, no `affiliations` phase needed)
```cypher
MATCH (a:Cohort {name: 'Daniel Erni'})-[c:CO_AUTHOR]-(b:Author)-[:AFFILIATED_WITH]->(i:Institution {type: 'company'})
RETURN i.name AS company, i.country_code AS country, collect(DISTINCT b.name)[0..3] AS coauthors, sum(c.weight) AS joint_works
ORDER BY joint_works DESC LIMIT 20
```
```cypher
MATCH (a:Cohort {name: 'Daniel Erni'})-[c:CO_AUTHOR]-(b:Author)-[f:AFFILIATED_WITH]->(i:Institution {type: 'company'})
RETURN a, c, b, f, i
```
### Handelsregister links (founders and officers, not co-authorship)
```cypher
MATCH (a:Cohort)-[r:OFFICER_OF]->(c:Company)
RETURN a.name, c.name, c.registered_office, r.positions ORDER BY a.name LIMIT 50
```
```cypher
MATCH (a:Cohort)-[r:OFFICER_OF]->(c:Company) RETURN a, r, c LIMIT 200
```
## Projects, funders, patents, news
Projects per source and link type:
```cypher
MATCH (x)-[r:OUTPUT_OF|CONTRIBUTED_TO|DFG_ROLE|PARTICIPATES_IN]->(p:Project)
RETURN p.source, type(r), count(r) ORDER BY p.source, count(r) DESC
```
EU consortium partners of the university:
```cypher
MATCH (:Institution {id: 'I62318514'})-[:PARTICIPATES_IN]->(p:Project)<-[:PARTICIPATES_IN]-(o:EuOrganization)
WHERE o.name <> 'UNIVERSITAET DUISBURG-ESSEN'
RETURN o.name, o.country, count(DISTINCT p) AS shared ORDER BY shared DESC LIMIT 20
```
Funders of the cohort (author level):
```cypher
MATCH (a:Cohort)-[r:FUNDED_BY]->(f:Funder)
RETURN f.name, count(a) AS researchers, sum(r.publications) AS publications ORDER BY researchers DESC LIMIT 20
```
Patents with their OpenAlex topics:
```cypher
MATCH (a:Author)-[:INVENTOR_OF]->(p:Patent)
OPTIONAL MATCH (p)-[:HAS_TOPIC]->(t:Topic)
RETURN a.name, p.source, p.year, left(p.title, 60), collect(t.name)[0..2] ORDER BY p.year DESC LIMIT 20
```
News mentions with topics:
```cypher
MATCH (a:Cohort)-[m:MENTIONED_IN]->(n:NewsArticle) OPTIONAL MATCH (n)-[:HAS_TOPIC]->(t:Topic)
RETURN a.name, n.title, n.date, m.ambiguous, collect(DISTINCT t.name)[0..3] ORDER BY n.date DESC LIMIT 20
```
Work classifications (LLM):
```cypher
MATCH (w:Work) WHERE w.primary_category IS NOT NULL
RETURN w.primary_category, count(w) ORDER BY count(w) DESC
```
+289
View File
@@ -0,0 +1,289 @@
# FalkorDB example: a researcher graph from the INSE sources
`load_graph.py` builds a small knowledge graph in [FalkorDB](https://www.falkordb.com/) around a
couple of researchers from the predefined ("default") organizations in
`src/data/predefined_accounts.json`, i.e. Universität Duisburg-Essen (`I62318514`),
Ruhr-Universität Bochum (`I904495901`) and TU Dortmund (`I200332995`).
It does not talk to OpenAlex, EPO or CORDIS directly. Every fact comes from the backend's existing
source logic in `src/main/inse`, which reads the INSE Elasticsearch mirrors, so the graph shows
exactly what the REST API can already see:
| Source | Backend function | Graph |
| --- | --- | --- |
| OpenAlex authors (profile, ORCID, metrics, affiliations, topics) | `authors.v2.service.search_authors` / `get_author_by_id_strict_or_raise` | `Author`, `Institution`, `Topic`, `AFFILIATED_WITH`, `WORKS_ON` |
| OpenAlex works incl. co-authors and their institutions | `works.v2.service.get_author_works` | `Work`, `AUTHORED`, `HAS_TOPIC`, co-author `Author`s |
| CORDIS (EU) and DFG projects, bridged through publication DOIs | `works.logic.get_publication_dois_of_author`, `projects.projects_search_client.get_cordis_eu_project_ids_by_dois` / `get_dfg_project_ids_by_dois`, `get_enriched_cordis_project_by_id`, `get_dfg_project_by_id` | `Project`, `CONTRIBUTED_TO` |
| EPO + USPTO patents (name matching with institution guard) | `patents.authors.logic.get_patents_by_author_id` | `Patent`, `INVENTOR_OF`, `HAS_TOPIC` |
| Funders of the author's funded publications | `funders.logic.get_funders_by_author_id` | `Funder`, `FUNDED_BY` (author and work level) |
| News mentions (UDE "aktuell", CC-News) | `news.logic.get_news_by_author` | `NewsArticle`, `MENTIONED_IN`, `HAS_TOPIC` |
| Handelsregister officer matches | `company_connections.logic.get_company_connections_by_author_id` | `Company`, `OFFICER_OF` |
| Predefined organizations | `src/data/predefined_accounts.json`, `institutions.v2.service.get_institution_by_id` | `Organization`, `REPRESENTS`, `MEMBER_OF` |
Co-authorship is not computed in Python. After loading, one Cypher query derives
`(:Author)-[:CO_AUTHOR {weight, first_year, last_year}]->(:Author)` from the `AUTHORED` edges,
which is the part the in-service collaboration-graph API currently leaves to the client.
## Prerequisites
1. A FalkorDB server. The quickest way is the official image, which also serves a browser UI on
port 3000:
```bash
docker run -d --name falkordb -p 6379:6379 -p 3000:3000 falkordb/falkordb:latest
```
2. The service image `inse-service:1.0.0` (built by `./gradlew :service:createImage`, and already
present if you ever ran `./gradlew :service:serve`). The script imports the `inse` package, whose
`util` module pulls in sentence-transformers/torch, so the image is the easiest runtime that has
every dependency. `src/main/inse/.env` must contain the Elasticsearch credentials as usual.
## Run
```bash
cd service
scripts/falkordb/run.sh # 2 researchers per default organization
scripts/falkordb/run.sh --reset --organization Duisburg --per-org 3
scripts/falkordb/run.sh --author-id A5040796987 --author-id A5122994949 # explicit researchers, added incrementally
scripts/falkordb/run.sh --no-write --dump /scripts/falkordb/graph.json # collect only, inspect the JSON
scripts/falkordb/run.sh --help
```
`run.sh` starts a throwaway container from the service image, mounts `src/main`, `src/data` and
`scripts`, installs `falkordb` from `requirements.txt` and reaches the server on the host through
`host.docker.internal`. Override the target with `FALKORDB_HOST`, `FALKORDB_PORT`,
`FALKORDB_PASSWORD` and `FALKORDB_GRAPH` (default graph name `inse`).
Loads are idempotent: every node and edge is `MERGE`d on its `id`, so re-running or adding
researchers with `--author-id` extends the same graph. `--reset` drops the graph right before
writing, after all sources were collected. One failing source is logged and skipped, it does not
abort the load.
A default run (six researchers, 40 works each) takes a few minutes and ends with roughly 2,300 nodes
and 9,000 relationships. The slow parts are the DOI-to-project lookups (one detail query per hit)
and the EPO/USPTO scans for common names.
### How the researchers are picked
For each organization the script reuses the backend's active-cohort membership query
(`authors.institution_membership_query.build_institution_membership_query`, last known institution
plus an affiliation since the current year minus two) and then narrows the candidates so the graph
stays small and well disambiguated:
- `works_count` within `--min-works`/`--max-works` (default 20 to 300) to skip hyper-authorship
profiles from large collaborations,
- an ORCID unless `--no-require-orcid` is given,
- every last known institution inside the organization's OpenAlex lineage, which drops merged
profiles that also "currently" belong to unrelated institutions,
- sorted by `works_count`, then `cited_by_count`.
Works with more than `--max-authors-per-work` authors (default 30) keep their `Work` node but only
the seed researcher's own `AUTHORED` edge, so a single CERN paper cannot add a thousand co-authors.
## Schema
Node labels, all keyed by `id` (OpenAlex ids are stored without the `https://openalex.org/` prefix,
patents as `<source>:<patent_id>`, projects as `cordis:<id>` / `dfg:<id>`):
| Label | Properties |
| --- | --- |
| `Organization` | `name`, `openalex_institution_id` |
| `Institution` | `name`, `ror`, `country_code`, `type` |
| `Author` | `name`, `orcid`, `works_count`, `cited_by_count`, `h_index`, `i10_index`, `seed` (true for the selected researchers, false for co-authors) |
| `Work` | `title`, `year`, `type`, `language`, `cited_by_count`, `authors_count`, `hyperauthorship` |
| `Topic` | `name`, `subfield`, `field`, `domain` |
| `Project` | `source` (`cordis`/`dfg`), `source_id`, `title`, `acronym`, `start`, `end`, `funding_scheme`, `status`, `ec_max_contribution`, `url` |
| `Patent` | `patent_id`, `source` (EPO/USPTO), `title`, `year`, `publication_date`, `kind`, `status`, `country`, `ipc[]`, `assignees[]`, `inventors[]` |
| `Funder` | `name` |
| `NewsArticle` | `title`, `date`, `url` |
| `Company` | `name`, `status`, `registered_office`, `register` |
Relationships:
| Relationship | Properties |
| --- | --- |
| `(Organization)-[:REPRESENTS]->(Institution)` | |
| `(Author)-[:MEMBER_OF]->(Organization)` | |
| `(Author)-[:AFFILIATED_WITH]->(Institution)` | `years[]`, `last_known` (seed profiles only) |
| `(Author)-[:WORKS_ON]->(Topic)` | `score` |
| `(Author)-[:AUTHORED]->(Work)` | `position`, `corresponding` |
| `(Author)-[:CO_AUTHOR]->(Author)` | `weight`, `first_year`, `last_year` (derived in FalkorDB, `a.id < b.id`) |
| `(Work)-[:HAS_TOPIC]->(Topic)`, `(Patent)-[:HAS_TOPIC]->(Topic)`, `(NewsArticle)-[:HAS_TOPIC]->(Topic)` | `score` (works) |
| `(Author)-[:CONTRIBUTED_TO]->(Project)` | `via` = `publication_doi` |
| `(Author)-[:INVENTOR_OF]->(Patent)` | |
| `(Author)-[:FUNDED_BY]->(Funder)` | `publications` |
| `(Work)-[:FUNDED_BY]->(Funder)` | only for works that are in the graph |
| `(Author)-[:MENTIONED_IN]->(NewsArticle)` | `matching` = `display_name` |
| `(Author)-[:OFFICER_OF]->(Company)` | `positions[]`, `matching_method`, `common_name_warning` |
## Example queries
The queries for the whole-university graph `ude` are collected in [QUERIES.md](QUERIES.md).
The ones below target the small `inse` example graph.
Paste these into the FalkorDB browser (http://localhost:3000, graph `inse`) or run them with the
Python client (`FalkorDB(host="localhost").select_graph("inse").ro_query(...)`).
Everything around one researcher, for the visual explorer:
```cypher
MATCH (a:Author {seed: true})-[r]-(n) WHERE a.name STARTS WITH 'Nikolai' RETURN a, r, n LIMIT 200
```
Seed researchers per organization with counts per source:
```cypher
MATCH (o:Organization)<-[:MEMBER_OF]-(a:Author)
OPTIONAL MATCH (a)-[:AUTHORED]->(w:Work)
OPTIONAL MATCH (a)-[:CONTRIBUTED_TO]->(p:Project)
OPTIONAL MATCH (a)-[:INVENTOR_OF]->(pt:Patent)
OPTIONAL MATCH (a)-[:OFFICER_OF]->(c:Company)
RETURN o.name, a.name, count(DISTINCT w) AS works, count(DISTINCT p) AS projects,
count(DISTINCT pt) AS patents, count(DISTINCT c) AS companies
ORDER BY o.name, a.name
```
Strongest co-authors and where they sit:
```cypher
MATCH (s:Author {seed: true})-[c:CO_AUTHOR]-(o:Author)-[:AFFILIATED_WITH]->(i:Institution)
WITH s, o, c, collect(DISTINCT i.name) AS insts ORDER BY c.weight DESC
RETURN s.name, collect(o.name + ' (' + toString(c.weight) + ') @ ' + insts[0])[0..5] AS top
```
Topics shared by two of the selected researchers:
```cypher
MATCH (a:Author {seed: true})-[:WORKS_ON]->(t:Topic)<-[:WORKS_ON]-(b:Author {seed: true})
WHERE a.id < b.id RETURN a.name, b.name, collect(t.name) AS topics
```
Funders that several selected researchers share:
```cypher
MATCH (a:Author {seed: true})-[:FUNDED_BY]->(f:Funder)<-[:FUNDED_BY]-(b:Author {seed: true})
WHERE a.id < b.id
RETURN f.name, collect(DISTINCT a.name + ' & ' + b.name) AS pairs ORDER BY size(pairs) DESC LIMIT 5
```
Projects per source and patents with their OpenAlex topics:
```cypher
MATCH (a:Author)-[:CONTRIBUTED_TO]->(p:Project) RETURN p.source, count(DISTINCT p), collect(DISTINCT a.name)
```
```cypher
MATCH (a:Author)-[:INVENTOR_OF]->(p:Patent)
OPTIONAL MATCH (p)-[:HAS_TOPIC]->(t:Topic)
RETURN a.name, p.source, p.year, left(p.title, 60), collect(t.name)[0..2] ORDER BY p.year DESC LIMIT 10
```
Company links, showing which ones rest on a common name:
```cypher
MATCH (a:Author)-[r:OFFICER_OF]->(c:Company)
RETURN a.name, r.common_name_warning, count(c) AS companies, collect(c.name)[0..3] AS sample
```
Cross-organization paths through up to two co-authorship hops:
```cypher
MATCH path = (o1:Organization)<-[:MEMBER_OF]-(:Author)-[:CO_AUTHOR*1..2]-(:Author)-[:MEMBER_OF]->(o2:Organization)
WHERE o1.name < o2.name RETURN o1.name, o2.name, count(path)
```
## Whole-university graph: `bulk_load.py`
`load_graph.py` is the per-researcher example. `bulk_load.py` builds the graph for a whole
organization by scanning each Elasticsearch source once and streaming into FalkorDB:
```bash
scripts/falkordb/run.sh bulk --graph ude --reset # full UDE cohort, all phases
scripts/falkordb/run.sh bulk --graph ude_test --reset --limit-authors 25 # smoke test, a few seconds
scripts/falkordb/run.sh bulk --graph ude --phases projects derive # re-run selected phases (idempotent)
```
Phases, in order (`--phases` selects a subset; later phases reload cohort and works from the graph):
| Phase | Source | Adds |
| --- | --- | --- |
| `cohort` | active researchers via `build_institution_membership_query` (last known institution + affiliation in the last two years) | `Author` with extra label `Cohort`, `MEMBER_OF`, `AFFILIATED_WITH {years, last_known}`, `WORKS_ON`, `Institution` lineage as `PART_OF` |
| `works` | one `scan` of the works index for every work of every cohort researcher | `Work` (incl. `doi`, `is_oa`, `fwci`), every authorship as `AUTHORED`, co-author `Author`s, `AFFILIATED_WITH`, `HAS_TOPIC`, `Venue` + `PUBLISHED_IN`, `Funder` + `FUNDED_BY {awards}` |
| `institutions` | `openalex-institutions` index | names, countries and types for institutions that only appeared as lineage ancestors |
| `affiliations` | second, lighter scan of the works index | `AUTHORED.institution_ids` (institutions on that authorship) and `Work-[:INVOLVES {authors}]->Institution`, the per-work view that author-level `AFFILIATED_WITH` cannot give |
| `classifications` | `work-classifications` index (LLM) | `Work.primary_category`, `pasteur_quadrant`, `applied_orientation_score`, `classification_confidence` |
| `projects` | CORDIS publications and DFG project publications by DOI; CORDIS organisations and DFG institutes of the organization; DFG persons by ORCID; project details | `Project {source: cordis/dfg}`, `Work-[:OUTPUT_OF]->Project`, `Institution-[:PARTICIPATES_IN {role, ec_contribution}]->Project`, `Author-[:DFG_ROLE {role}]->Project`, `EuOrganization-[:PARTICIPATES_IN]->Project` (consortium partners) |
| `patents` | `org_patents` index (pre-matched by `index_org_patents.py`) | `Patent`, `Author-[:INVENTOR_OF {match_type}]->Patent`, `HAS_TOPIC` |
| `news` | `aktuell_postproc` author names matched exactly to cohort display names (the rule the news API uses), articles from `aktuell`, topics from `aktuell_openalex_topics` | `NewsArticle`, `MENTIONED_IN {ambiguous}`, `HAS_TOPIC {keyword}` |
| `companies` | `get_company_connections_by_author_id` per researcher, 8 in parallel | `Company`, `OFFICER_OF`; common-name matches are only counted on the Author (`hr_company_matches`, `hr_common_name_warning`) unless `--include-ambiguous-companies` |
| `hierarchy` | `get_topic_hierarchy()` | `Domain`, `Field`, `Subfield`, `IN_DOMAIN`, `IN_FIELD`, `IN_SUBFIELD` |
| `derive` | Cypher inside FalkorDB | `CO_AUTHOR {weight, first_year, last_year}`, `Author-[:FUNDED_BY {publications}]->Funder`, `Author-[:CONTRIBUTED_TO {works}]->Project` for cohort members |
| `profile` | aggregation over the cohort's works | `Institution-[:ACTIVE_IN {level, works, researchers}]->Topic/Subfield/Field/Domain`, the drawable research profile |
Co-author policy: every authorship is an `AUTHORED` edge, including 5,000-author collaboration
papers. `CO_AUTHOR` pairs are derived for all author pairs on works with at most `--pair-cap`
authors (default 30) and, on larger works, only for pairs that involve a cohort member. All pairs
on the UDE cohort's works would be 2.9 billion edges; the anchored policy gives about 10 million.
Edges always point from the smaller to the larger author id, so treat them as undirected.
Writes go through `GraphWriter`: rows are buffered per label / relationship type and flushed with
`UNWIND ... MERGE` in batches of 2,000, node buffers before edge buffers. Cohort profiles use
`SET`, co-author stubs use `ON CREATE SET`, so a researcher who is both keeps the full profile.
One failing phase is logged and the next phase still runs. The script ends with `BGSAVE`.
### Result for Universität Duisburg-Essen (2026-09-15)
Cohort of 6,176 active researchers, every work of every cohort member, no author cap. The load
ran in about 12 minutes of pipeline time (works scan 6.5 min, derive 100 s, everything else under
a minute each); FalkorDB holds it in 1.04 GB and the RDB snapshot is 264 MB.
| Nodes | | Relationships | |
| --- | --- | --- | --- |
| Author | 693,487 (6,176 also `:Cohort`) | AUTHORED | 4,112,809 (2,376,034 with `institution_ids`) |
| Work | 204,110 | CO_AUTHOR | 3,782,011 |
| Institution | 26,246 | AFFILIATED_WITH / INVOLVES | 1,072,837 / 784,212 |
| Venue | 16,534 | HAS_TOPIC | 571,906 |
| Funder | 7,493 | FUNDED_BY (work + author level) | 229,219 |
| EuOrganization | 5,469 | PUBLISHED_IN | 173,495 |
| Topic | 4,516 | WORKS_ON | 27,255 |
| NewsArticle | 4,402 | PARTICIPATES_IN | 17,046 |
| Project | 3,664 | MENTIONED_IN | 11,251 |
| Company | 547 | PART_OF | 11,045 |
| Patent | 366 | OUTPUT_OF / CONTRIBUTED_TO | 8,292 / 6,723 |
| Subfield / Field / Domain | 252 / 26 / 4 | OFFICER_OF / DFG_ROLE / INVENTOR_OF | 700 / 548 / 367 |
| | | ACTIVE_IN (institution research profile) | 4,618 |
Source coverage of the cohort: all 6,176 have works, 1,741 are linked to projects, 1,925 are
mentioned in news, 406 have unambiguous company links, 163 hold indexed patents, 164 were matched to
DFG persons through their ORCID. 187,000 works carry an LLM classification.
Two server behaviours matter at this scale and are handled in the script: FalkorDB caps every
result set at `RESULTSET_SIZE` rows (10,000 in the default container), so whole-graph reads are
paged (`GraphWriter.ro_all`); and write queries ignore timeouts, which is why the co-author
derivation computes pairs in Python and bulk-creates edges instead of running
`MATCH ... MERGE` inside the graph (that took over a minute per 2,000 works).
## Caveats worth knowing
- In the whole-university graph, common-name company matches are not written as edges by default
(406 researchers have unambiguous links, the rest only carry `hr_company_matches`).
- News and Handelsregister links are name matches, exactly as in the REST API. The `OFFICER_OF`
edge carries `common_name_warning`; a researcher named Thomas Kaiser gets 92 companies with the
flag set, Ahmet Karkar gets one without it.
- Patents are matched by inventor name with the institution guard from `patents.authors.logic`;
the backend logs `search_completeness=truncated_inconclusive` for common names.
- The project bridge is DOI based: a researcher is linked to every CORDIS/DFG project that lists one
of their publications, regardless of author position.
- OpenAlex profiles can be merged across institutions. The lineage filter above avoids most of
them for the automatic selection, `--author-id` takes whatever you give it.
- `Author.topics` in the mirror carry a `score` where OpenAlex has a `count`; the value is stored
as-is on `WORKS_ON`.
## Running without Docker
Create a Python 3.12 environment with the service dependencies (`pip install -e` is not set up, so
install `fastapi httpx pydantic pydantic-settings sqlmodel python-dotenv pyyaml pyjwt openai pandas
pypdf sentence-transformers torch` matching `pyproject.toml`) plus `falkordb`, then run
`python scripts/falkordb/load_graph.py` from `service/`. The script locates `src/main/inse` and its
`.env` relative to its own path.
File diff suppressed because it is too large Load Diff
+636
View File
@@ -0,0 +1,636 @@
"""
load_graph.py — Minimal FalkorDB example for the INSE backend.
Builds a small knowledge graph around a couple of researchers from the predefined
("default") organizations in src/data/predefined_accounts.json, using only the
backend's existing data-source logic (everything reads the INSE Elasticsearch mirrors):
OpenAlex authors, works, topics, institutions -> inse.authors.v2 / inse.works.v2 / inse.institutions.v2
EPO + USPTO patents -> inse.patents.authors.logic
CORDIS (EU) + DFG projects, via publication DOIs -> inse.works.logic + inse.projects.*
Funders of the author's funded publications -> inse.funders.logic
News mentions (UDE "aktuell" + CC-News) -> inse.news.logic
Handelsregister company officer matches -> inse.company_connections.logic
The collected nodes/edges are written to FalkorDB with batched UNWIND ... MERGE
queries, and CO_AUTHOR edges are then derived inside the graph with one Cypher query.
Usage (see run.sh for running inside the service image):
python scripts/falkordb/load_graph.py # 2 researchers per default org
python scripts/falkordb/load_graph.py --organization "Duisburg" --per-org 3
python scripts/falkordb/load_graph.py --author-id A5040796987 --author-id A5119657791
python scripts/falkordb/load_graph.py --reset --dump /tmp/graph.json --skip news --skip companies
FalkorDB connection: --falkordb-host/--falkordb-port/--falkordb-password or the
FALKORDB_HOST / FALKORDB_PORT / FALKORDB_PASSWORD environment variables.
"""
from __future__ import annotations
import argparse
import asyncio
import json
import logging
import os
import re
import sys
import time
from collections import Counter, defaultdict
from dataclasses import dataclass, field
from datetime import date, datetime
from pathlib import Path
from typing import Any
# --- locate the backend package (works from the repo checkout and inside the service image) ---
_current_dir = Path(__file__).resolve().parent
_service_dir = _current_dir.parent.parent
_src_main = _service_dir / "src" / "main"
if not (_src_main / "inse").is_dir():
_src_main = Path(os.environ.get("INSE_SRC_DIR", "/home"))
sys.path.insert(0, str(_src_main))
from dotenv import load_dotenv # noqa: E402
_env_file = _src_main / "inse" / ".env"
if _env_file.exists():
load_dotenv(dotenv_path=_env_file)
# inse.config reads the .env at import time, so these imports must come after load_dotenv.
from inse.authors.institution_membership_query import ( # noqa: E402
build_institution_membership_query,
current_affiliation_year_cutoff,
)
from inse.authors.v2.service import get_author_by_id_strict_or_raise, search_authors # noqa: E402
from inse.company_connections.logic import get_company_connections_by_author_id # noqa: E402
from inse.funders.logic import get_funders_by_author_id # noqa: E402
from inse.institutions.v2.service import get_institution_by_id # noqa: E402
from inse.models.openalex.author import Author # noqa: E402
from inse.news.logic import get_news_by_author # noqa: E402
from inse.patents.authors.logic import get_patents_by_author_id # noqa: E402
from inse.projects.eu_cordis_projects_client import get_enriched_cordis_project_by_id # noqa: E402
from inse.projects.projects_search_client import ( # noqa: E402
get_cordis_eu_project_ids_by_dois,
get_dfg_project_by_id,
get_dfg_project_ids_by_dois,
)
from inse.works.logic import get_publication_dois_of_author # noqa: E402
from inse.works.v2.service import get_author_works # noqa: E402
logger = logging.getLogger("falkordb.load_graph")
OPENALEX_PREFIX = "https://openalex.org/"
PREDEFINED_ACCOUNTS = _src_main.parent / "data" / "predefined_accounts.json"
SOURCES = ("works", "projects", "patents", "funders", "news", "companies")
_IDENT = re.compile(r"^[A-Z][A-Za-z_]*$")
# --------------------------------------------------------------------------- helpers
def short_id(raw: str | None) -> str | None:
"""'https://openalex.org/A123' -> 'A123' (OpenAlex ids are stored as URLs in ES)."""
if not raw:
return None
return raw.strip().removeprefix(OPENALEX_PREFIX)
def raw_doi(doi: str) -> str:
for prefix in ("https://doi.org/", "http://doi.org/", "http://dx.doi.org/"):
if doi.startswith(prefix):
return doi[len(prefix):]
return doi
def _scalar(value: Any) -> Any:
if isinstance(value, (date, datetime)):
return value.isoformat()
if isinstance(value, str):
return value[:2000]
if isinstance(value, (bool, int, float)):
return value
return str(value)
def clean_props(props: dict[str, Any]) -> dict[str, Any]:
"""FalkorDB properties must be scalars or lists of scalars; drop None/dicts."""
cleaned: dict[str, Any] = {}
for key, value in props.items():
if value is None or isinstance(value, dict):
continue
if isinstance(value, (list, tuple, set)):
cleaned[key] = [_scalar(v) for v in value if v is not None and not isinstance(v, dict)]
else:
cleaned[key] = _scalar(value)
return cleaned
@dataclass
class GraphBatch:
"""In-memory node/edge accumulator. First writer of a property wins, so seed
authors (hydrated first) keep their full profile when they reappear as co-authors."""
nodes: dict[tuple[str, str], dict[str, Any]] = field(default_factory=dict)
edges: dict[tuple[str, str, str, str, str], dict[str, Any]] = field(default_factory=dict)
def node(self, label: str, node_id: str | None, **props: Any) -> None:
if not node_id:
return
props = clean_props(props)
existing = self.nodes.setdefault((label, node_id), {})
for key, value in props.items():
existing.setdefault(key, value)
def edge(self, src_label: str, src: str | None, rel: str, dst_label: str, dst: str | None, **props: Any) -> None:
if not src or not dst:
return
props = clean_props(props)
existing = self.edges.setdefault((src_label, src, rel, dst_label, dst), {})
for key, value in props.items():
existing.setdefault(key, value)
def has_node(self, label: str, node_id: str | None) -> bool:
return bool(node_id) and (label, node_id) in self.nodes
def summary(self) -> tuple[Counter, Counter]:
return (
Counter(label for label, _ in self.nodes),
Counter(rel for _, _, rel, _, _ in self.edges),
)
def to_json(self) -> dict[str, Any]:
return {
"nodes": [{"label": l, "id": i, "props": p} for (l, i), p in self.nodes.items()],
"edges": [
{"src_label": sl, "src": s, "rel": r, "dst_label": dl, "dst": d, "props": p}
for (sl, s, r, dl, d), p in self.edges.items()
],
}
def add_topic(batch: GraphBatch, topic: Any) -> str | None:
"""Topic node from an OpenAlex WorkTopic-like object (works, authors, patents, news)."""
tid = short_id(getattr(topic, "id", None))
if not tid:
return None
subfield = getattr(topic, "subfield", None)
field_ = getattr(topic, "var_field", None) or getattr(topic, "field", None)
domain = getattr(topic, "domain", None)
batch.node(
"Topic",
tid,
name=getattr(topic, "display_name", None),
subfield=getattr(subfield, "display_name", None),
field=getattr(field_, "display_name", None),
domain=getattr(domain, "display_name", None),
)
return tid
# --------------------------------------------------------------------------- organizations
def load_default_organizations() -> list[dict[str, str]]:
"""The predefined organizations seeded at startup (auth.service.create_predefined_accounts)."""
with open(PREDEFINED_ACCOUNTS, encoding="utf-8") as fh:
data = json.load(fh)
return [
{"name": org["name"], "institution_id": org["openalex_institution_id"]}
for org in data.get("organizations", [])
if org.get("openalex_institution_id")
]
def select_organizations(orgs: list[dict[str, str]], wanted: list[str]) -> list[dict[str, str]]:
if not wanted:
return orgs
selected = []
for term in wanted:
term_l = term.lower()
matches = [o for o in orgs if term_l in o["name"].lower() or term_l == o["institution_id"].lower()]
if not matches:
raise SystemExit(f"No default organization matches {term!r}. Known: {[o['name'] for o in orgs]}")
selected.extend(m for m in matches if m not in selected)
return selected
async def ensure_organization_nodes(batch: GraphBatch, org: dict[str, str]) -> None:
"""Organization (from predefined_accounts.json) + its OpenAlex institution."""
if batch.has_node("Organization", org["name"]):
return
institution = await get_institution_by_id(org["institution_id"])
batch.node("Organization", org["name"], name=org["name"], openalex_institution_id=org["institution_id"])
batch.node(
"Institution", org["institution_id"],
name=getattr(institution, "display_name", None) or org["name"],
ror=getattr(institution, "ror", None),
country_code=getattr(institution, "country_code", None),
type=str(institution.type) if getattr(institution, "type", None) else None,
)
batch.edge("Organization", org["name"], "REPRESENTS", "Institution", org["institution_id"])
def organization_of(author: Author, orgs: list[dict[str, str]]) -> dict[str, str] | None:
"""Default organization whose institution is among the author's last known institutions."""
last_known = {short_id(i.id) for i in (author.last_known_institutions or []) if i.id}
return next((org for org in orgs if org["institution_id"] in last_known), None)
async def pick_seed_authors(
institution_id: str, per_org: int, min_works: int, max_works: int, require_orcid: bool
) -> list[Author]:
"""Seed researchers of an institution.
Reuses the backend's active-cohort membership query (last known institution plus an
affiliation since the current year minus two, the same rule the app uses for
"currently belongs to institution"), then narrows the candidates so the example graph
stays small and well disambiguated:
* works_count within [min_works, max_works] -> skips hyper-authorship profiles
* an ORCID (optional) -> better-disambiguated OpenAlex profiles
* every last-known institution inside the institution's OpenAlex lineage
-> drops merged profiles that also "currently" belong to unrelated institutions
"""
institution_url = f"{OPENALEX_PREFIX}{institution_id}"
filters: list[dict[str, Any]] = [
build_institution_membership_query(institution_id, year_mode="from", year=current_affiliation_year_cutoff()),
{"range": {"works_count": {"gte": min_works, "lte": max_works}}},
]
if require_orcid:
filters.append({"exists": {"field": "orcid"}})
page = await search_authors(
page=0,
size=max(20, per_org * 20),
query={"bool": {"filter": filters}},
sort=[{"works_count": {"order": "desc"}}, {"cited_by_count": {"order": "desc"}}],
)
def within_lineage(author: Author) -> bool:
return all(
inst.id == institution_url or institution_url in (inst.lineage or [])
for inst in (author.last_known_institutions or [])
)
return [author for author in page.elements if within_lineage(author)][:per_org]
# --------------------------------------------------------------------------- collectors
def collect_author_profile(batch: GraphBatch, author: Author, org_name: str | None) -> str:
aid = short_id(author.id)
stats = author.summary_stats
batch.node(
"Author",
aid,
name=author.display_name,
orcid=author.orcid,
works_count=author.works_count,
cited_by_count=author.cited_by_count,
h_index=getattr(stats, "h_index", None),
i10_index=getattr(stats, "i10_index", None),
seed=True,
)
if org_name:
batch.edge("Author", aid, "MEMBER_OF", "Organization", org_name)
last_known = {short_id(i.id) for i in (author.last_known_institutions or []) if i.id}
for affiliation in author.affiliations or []:
inst = affiliation.institution
iid = short_id(inst.id) if inst else None
if not iid:
continue
batch.node("Institution", iid, name=inst.display_name, country_code=inst.country_code, type=inst.type, ror=inst.ror)
batch.edge(
"Author", aid, "AFFILIATED_WITH", "Institution", iid,
years=sorted(affiliation.years or []),
last_known=iid in last_known,
)
for topic in author.topics or []:
tid = add_topic(batch, topic)
if tid:
batch.edge("Author", aid, "WORKS_ON", "Topic", tid, score=getattr(topic, "score", None))
return aid
async def collect_works(batch: GraphBatch, aid: str, max_works: int, max_authors_per_work: int) -> int:
page = await get_author_works(aid, page=0, size=max_works)
for work in page.elements:
wid = short_id(work.id)
if not wid:
continue
authorships = work.authorships or []
hyper = len(authorships) > max_authors_per_work
batch.node(
"Work", wid,
title=work.title or work.display_name,
year=work.publication_year,
type=work.type,
language=work.language,
cited_by_count=work.cited_by_count,
authors_count=len(authorships),
hyperauthorship=hyper,
)
for topic in work.topics or []:
tid = add_topic(batch, topic)
if tid:
batch.edge("Work", wid, "HAS_TOPIC", "Topic", tid, score=topic.score)
for authorship in authorships:
author = authorship.author
cid = short_id(author.id) if author else None
if not cid or (hyper and cid != aid):
continue # for hyper-authorship works only keep the seed author's own edge
batch.node("Author", cid, name=author.display_name, orcid=author.orcid, seed=False)
batch.edge(
"Author", cid, "AUTHORED", "Work", wid,
position=authorship.author_position,
corresponding=authorship.is_corresponding,
)
for inst in authorship.institutions or []:
iid = short_id(inst.id)
if iid:
batch.node("Institution", iid, name=inst.display_name, country_code=inst.country_code, type=inst.type)
batch.edge("Author", cid, "AFFILIATED_WITH", "Institution", iid)
return len(page.elements)
async def collect_projects(batch: GraphBatch, aid: str) -> int:
"""Author -> project bridge used elsewhere in the backend: the author's publication DOIs
are looked up in the CORDIS publication index and in the DFG projects' publication lists."""
dois = await get_publication_dois_of_author(aid)
if not dois:
return 0
doi_variants = sorted({v for d in dois for v in (d, raw_doi(d), raw_doi(d).lower())})
cordis_ids = await get_cordis_eu_project_ids_by_dois(dois)
dfg_ids = await get_dfg_project_ids_by_dois(doi_variants)
for pid in cordis_ids:
node_id = f"cordis:{pid}"
details = await get_enriched_cordis_project_by_id(str(pid))
batch.node(
"Project", node_id,
source="cordis", source_id=str(pid),
title=getattr(details, "title", None),
acronym=getattr(details, "acronym", None),
start=getattr(details, "start_date", None),
end=getattr(details, "end_date", None),
funding_scheme=getattr(details, "funding_scheme", None),
status=getattr(details, "status", None),
ec_max_contribution=getattr(details, "ec_max_contribution", None),
)
batch.edge("Author", aid, "CONTRIBUTED_TO", "Project", node_id, via="publication_doi")
for pid in dfg_ids:
node_id = f"dfg:{pid}"
details = await get_dfg_project_by_id(str(pid))
batch.node(
"Project", node_id,
source="dfg", source_id=str(pid),
title=getattr(details, "title_en", None) or getattr(details, "title_de", None),
start=getattr(details, "funding_start", None),
end=getattr(details, "funding_end", None),
funding_scheme=getattr(details, "funding_type_en", None) or getattr(details, "funding_type_de", None),
url=getattr(details, "page_url", None) or getattr(details, "link", None),
)
batch.edge("Author", aid, "CONTRIBUTED_TO", "Project", node_id, via="publication_doi")
return len(cordis_ids) + len(dfg_ids)
async def collect_patents(batch: GraphBatch, aid: str) -> int:
response = await get_patents_by_author_id(aid)
for patent in response.patents:
pid = f"{patent.source}:{patent.patent_id}"
year = int(patent.publication_year) if patent.publication_year and patent.publication_year.isdigit() else None
batch.node(
"Patent", pid,
patent_id=patent.patent_id, source=patent.source,
title=patent.title or patent.title_en or patent.title_de,
year=year, publication_date=patent.publication_date,
kind=patent.kind, status=patent.status, country=patent.country,
ipc=patent.ipc, assignees=patent.assignees, inventors=patent.inventors,
)
batch.edge("Author", aid, "INVENTOR_OF", "Patent", pid)
for tag in patent.openalex_topics:
tid = short_id(tag.topic_id)
if tid:
batch.node("Topic", tid, name=tag.topic_display_name, field=tag.field_name, domain=tag.domain_name)
batch.edge("Patent", pid, "HAS_TOPIC", "Topic", tid)
return response.patent_count
async def collect_funders(batch: GraphBatch, aid: str) -> int:
response = await get_funders_by_author_id(aid)
for funder in response.funders:
fid = short_id(funder.funder_id) or f"name:{funder.funder_name}"
batch.node("Funder", fid, name=funder.funder_name)
batch.edge("Author", aid, "FUNDED_BY", "Funder", fid, publications=funder.publication_count)
ids = funder.publication_ids
for wid_raw in ids.first + ids.middle + ids.last + ids.unknown:
wid = short_id(wid_raw)
if batch.has_node("Work", wid): # only link works we already loaded
batch.edge("Work", wid, "FUNDED_BY", "Funder", fid)
return response.funder_count
async def collect_news(batch: GraphBatch, aid: str, max_news: int) -> int:
page = await get_news_by_author(aid, page=1, page_size=max_news)
for article in page.results:
batch.node("NewsArticle", article.id, title=article.maintitle, date=article.date, url=article.url)
batch.edge("Author", aid, "MENTIONED_IN", "NewsArticle", article.id, matching="display_name")
for topic in article.topics or []:
tid = short_id(topic.id)
if tid:
batch.node("Topic", tid, name=topic.display_name, subfield=topic.subfield_name, field=topic.field_name, domain=topic.domain_name)
batch.edge("NewsArticle", article.id, "HAS_TOPIC", "Topic", tid)
return page.total
async def collect_companies(batch: GraphBatch, aid: str) -> int:
response = await get_company_connections_by_author_id(aid)
for company in response.connections:
cid = company.company_number or company.native_company_number or f"name:{company.company_name}"
batch.node(
"Company", cid,
name=company.company_name, status=company.company_status,
registered_office=company.registered_office,
register=" ".join(p for p in (company.register_art, company.register_nummer) if p) or None,
)
batch.edge(
"Author", aid, "OFFICER_OF", "Company", cid,
positions=[o.position for o in company.matched_officers if o.position],
matching_method=response.matching_method,
common_name_warning=response.common_name_warning,
)
return response.company_count
# --------------------------------------------------------------------------- FalkorDB sink
def _chunks(rows: list[dict[str, Any]], size: int):
for start in range(0, len(rows), size):
yield rows[start:start + size]
def write_to_falkordb(batch: GraphBatch, args: argparse.Namespace) -> None:
from falkordb import FalkorDB
from redis.exceptions import ResponseError
db = FalkorDB(host=args.falkordb_host, port=args.falkordb_port, password=args.falkordb_password)
if args.reset and args.graph in db.list_graphs():
db.select_graph(args.graph).delete()
logger.info("Deleted existing graph %r", args.graph)
graph = db.select_graph(args.graph)
labels = sorted({label for label, _ in batch.nodes})
for label in labels:
try:
graph.create_node_range_index(label, "id")
except ResponseError as exc:
if "already indexed" not in str(exc):
raise
nodes_by_label: dict[str, list[dict[str, Any]]] = defaultdict(list)
for (label, node_id), props in batch.nodes.items():
nodes_by_label[label].append({"id": node_id, "props": props})
for label, rows in nodes_by_label.items():
assert _IDENT.match(label), label
for chunk in _chunks(rows, args.batch_size):
graph.query(f"UNWIND $rows AS r MERGE (n:{label} {{id: r.id}}) SET n += r.props", {"rows": chunk})
edges_by_type: dict[tuple[str, str, str], list[dict[str, Any]]] = defaultdict(list)
for (src_label, src, rel, dst_label, dst), props in batch.edges.items():
edges_by_type[(src_label, rel, dst_label)].append({"src": src, "dst": dst, "props": props})
for (src_label, rel, dst_label), rows in edges_by_type.items():
assert _IDENT.match(src_label) and _IDENT.match(rel) and _IDENT.match(dst_label)
for chunk in _chunks(rows, args.batch_size):
graph.query(
f"UNWIND $rows AS r "
f"MATCH (a:{src_label} {{id: r.src}}), (b:{dst_label} {{id: r.dst}}) "
f"MERGE (a)-[e:{rel}]->(b) SET e += r.props",
{"rows": chunk},
)
if not args.no_coauthor_edges:
# Derive co-authorship inside the graph instead of in Python (this is the part the
# in-service CollaborationGraph API currently leaves to the client).
result = graph.query(
"MATCH (a:Author)-[:AUTHORED]->(w:Work)<-[:AUTHORED]-(b:Author) "
"WHERE a.id < b.id "
"WITH a, b, count(DISTINCT w) AS n, min(w.year) AS first_year, max(w.year) AS last_year "
"MERGE (a)-[c:CO_AUTHOR]->(b) "
"SET c.weight = n, c.first_year = first_year, c.last_year = last_year"
)
logger.info("CO_AUTHOR edges created: %d", int(result.relationships_created or 0))
stats = graph.ro_query(
"MATCH (n) WITH count(n) AS nodes MATCH ()-[r]->() RETURN nodes, count(r)"
).result_set
logger.info("Graph %r now holds %s nodes and %s relationships", args.graph, *stats[0])
seeds = graph.ro_query(
"MATCH (s:Author {seed: true}) "
"OPTIONAL MATCH (s)-[c:CO_AUTHOR]-(o:Author) "
"WITH s, o, c ORDER BY c.weight DESC "
"WITH s, collect(o.name + ' (' + toString(c.weight) + ')')[0..3] AS top "
"RETURN s.id, s.name, top ORDER BY s.name"
).result_set
for row in seeds:
logger.info(" %s %-32s strongest co-authors: %s", row[0], row[1], ", ".join(row[2]) or "-")
# --------------------------------------------------------------------------- main
async def run_source(name: str, coro, status: dict[str, str]) -> None:
started = time.perf_counter()
try:
count = await coro
status[name] = f"{count} ({(time.perf_counter() - started) * 1000:.0f}ms)"
except Exception as exc: # one failing source must not abort the whole load
logger.warning("source %-9s failed: %s: %s", name, type(exc).__name__, exc)
status[name] = "error"
async def main(args: argparse.Namespace) -> None:
batch = GraphBatch()
skipped = set(args.skip)
seeds: list[tuple[Author, str | None]] = []
default_orgs = load_default_organizations()
if args.author_id:
for raw in args.author_id:
author = await get_author_by_id_strict_or_raise(short_id(raw))
org = organization_of(author, default_orgs)
if org:
await ensure_organization_nodes(batch, org)
seeds.append((author, org["name"] if org else None))
else:
for org in select_organizations(default_orgs, args.organization):
await ensure_organization_nodes(batch, org)
authors = await pick_seed_authors(
org["institution_id"], args.per_org, args.min_works, args.max_works, args.require_orcid
)
logger.info("%s (%s): %s", org["name"], org["institution_id"], ", ".join(f"{a.display_name} [{short_id(a.id)}]" for a in authors) or "no authors found")
seeds.extend((author, org["name"]) for author in authors)
if not seeds:
raise SystemExit("No seed researchers selected.")
seed_ids = [collect_author_profile(batch, author, org_name) for author, org_name in seeds]
for (author, _), aid in zip(seeds, seed_ids):
logger.info("Collecting sources for %s [%s] ...", author.display_name, aid)
status: dict[str, str] = {}
if "works" not in skipped:
await run_source("works", collect_works(batch, aid, args.works, args.max_authors_per_work), status)
if "projects" not in skipped:
await run_source("projects", collect_projects(batch, aid), status)
if "patents" not in skipped:
await run_source("patents", collect_patents(batch, aid), status)
if "funders" not in skipped:
await run_source("funders", collect_funders(batch, aid), status)
if "news" not in skipped:
await run_source("news", collect_news(batch, aid, args.news), status)
if "companies" not in skipped:
await run_source("companies", collect_companies(batch, aid), status)
logger.info(" %s", " ".join(f"{k}={v}" for k, v in status.items()))
node_counts, edge_counts = batch.summary()
logger.info("Collected nodes: %s", dict(node_counts))
logger.info("Collected edges: %s", dict(edge_counts))
if args.dump:
Path(args.dump).write_text(json.dumps(batch.to_json(), ensure_ascii=False, indent=1), encoding="utf-8")
logger.info("Wrote %s", args.dump)
if args.no_write:
return
write_to_falkordb(batch, args)
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
sel = parser.add_argument_group("researcher selection")
sel.add_argument("--organization", action="append", default=[], metavar="NAME_OR_ID",
help="restrict to default organization(s) by name substring or OpenAlex institution id (repeatable)")
sel.add_argument("--per-org", type=int, default=2, help="seed researchers per organization (default 2)")
sel.add_argument("--min-works", type=int, default=20, help="minimum works_count for seed selection")
sel.add_argument("--max-works", type=int, default=300, help="maximum works_count for seed selection (skips hyper-authorship profiles)")
sel.add_argument("--require-orcid", action=argparse.BooleanOptionalAction, default=True,
help="only seed researchers with an ORCID (default on)")
sel.add_argument("--author-id", action="append", default=[], metavar="OPENALEX_ID",
help="explicit seed researcher(s), e.g. A5040796987 (repeatable; overrides organization selection)")
src = parser.add_argument_group("sources")
src.add_argument("--works", type=int, default=40, help="max works per researcher (default 40)")
src.add_argument("--max-authors-per-work", type=int, default=30, help="skip co-author edges for works with more authors")
src.add_argument("--news", type=int, default=20, help="max news articles per researcher")
src.add_argument("--skip", action="append", default=[], choices=SOURCES, help="skip a source (repeatable)")
out = parser.add_argument_group("output")
out.add_argument("--falkordb-host", default=os.environ.get("FALKORDB_HOST", "localhost"))
out.add_argument("--falkordb-port", type=int, default=int(os.environ.get("FALKORDB_PORT", "6379")))
out.add_argument("--falkordb-password", default=os.environ.get("FALKORDB_PASSWORD") or None)
out.add_argument("--graph", default=os.environ.get("FALKORDB_GRAPH", "inse"), help="graph name (default inse)")
out.add_argument("--reset", action="store_true", help="delete the graph before loading")
out.add_argument("--no-coauthor-edges", action="store_true", help="do not derive CO_AUTHOR edges")
out.add_argument("--batch-size", type=int, default=500)
out.add_argument("--dump", metavar="PATH", help="also write the collected nodes/edges as JSON")
out.add_argument("--no-write", action="store_true", help="collect only (useful with --dump), do not touch FalkorDB")
parser.add_argument("-v", "--verbose", action="store_true", help="show backend/httpx logs")
return parser.parse_args()
if __name__ == "__main__":
cli_args = parse_args()
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")
if not cli_args.verbose:
# Some backend modules pin their own logger level, so filter at the handler instead.
for handler in logging.getLogger().handlers:
handler.addFilter(lambda record: record.levelno >= logging.WARNING or record.name.startswith("falkordb"))
asyncio.run(main(cli_args))
@@ -0,0 +1,2 @@
# Extra dependency for scripts/falkordb on top of the service image / pyproject.
falkordb~=1.7
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Run load_graph.py inside the inse-service image, which already has every backend
# dependency (torch/sentence-transformers included), and talk to FalkorDB on the host.
#
# scripts/falkordb/run.sh # 2 researchers per default organization
# scripts/falkordb/run.sh --reset --organization Duisburg --per-org 3
# scripts/falkordb/run.sh --author-id A5040796987 --author-id A5119657791
# scripts/falkordb/run.sh bulk --graph ude --reset # whole-university graph (bulk_load.py)
#
# Env: INSE_IMAGE (default inse-service:1.0.0, built by ./gradlew :service:createImage),
# FALKORDB_HOST (default host.docker.internal), FALKORDB_PORT, FALKORDB_PASSWORD, FALKORDB_GRAPH.
set -euo pipefail
SERVICE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
# First argument "bulk" selects the whole-university loader (bulk_load.py); otherwise load_graph.py runs.
SCRIPT="load_graph.py"
if [ "${1:-}" = "bulk" ]; then SCRIPT="bulk_load.py"; shift; fi
IMAGE="${INSE_IMAGE:-inse-service:1.0.0}"
TTY_FLAGS=""
if [ -t 0 ] && [ -t 1 ]; then TTY_FLAGS="-it"; fi
# Match the image's platform (the Gradle build targets amd64), avoiding Docker's mismatch warning on arm64 hosts.
PLATFORM="$(docker image inspect --format '{{.Os}}/{{.Architecture}}' "$IMAGE" 2>/dev/null || true)"
PLATFORM_FLAGS=""
if [ -n "$PLATFORM" ]; then PLATFORM_FLAGS="--platform $PLATFORM"; fi
exec docker run --rm $TTY_FLAGS $PLATFORM_FLAGS \
-v "$SERVICE_DIR/src/main:/home" \
-v "$SERVICE_DIR/src/data:/data" \
-v "$SERVICE_DIR/scripts:/scripts" \
-w /home \
--add-host host.docker.internal:host-gateway \
-e FALKORDB_HOST="${FALKORDB_HOST:-host.docker.internal}" \
-e FALKORDB_PORT="${FALKORDB_PORT:-6379}" \
-e FALKORDB_PASSWORD="${FALKORDB_PASSWORD:-}" \
-e FALKORDB_GRAPH="${FALKORDB_GRAPH:-inse}" \
-e PRINT_ES_QUERIES=false -e PRINT_ES_TIMINGS=false \
-e HF_HUB_DISABLE_PROGRESS_BARS=1 -e TQDM_DISABLE=1 \
--entrypoint sh "$IMAGE" -c \
'pip install -q --root-user-action=ignore --disable-pip-version-check -r /scripts/falkordb/requirements.txt && exec python "/scripts/falkordb/$0" "$@"' \
"$SCRIPT" "$@"
@@ -0,0 +1,406 @@
{
"institution": "I62318514",
"cohort": [
"I62318514",
"I4210119759",
"I4210161917",
"I127668822",
"I4210090139",
"I4210092428",
"I4210110714",
"I4210146441",
"I4210154243"
],
"config_hash": "e56aa52d51c2",
"counts": {
"focal_authors_scored": 9474,
"nodes": 864646,
"edges": 5822006,
"works_used": 228103,
"works_capped": 9238,
"tags": {
"mentor": 161,
"bridger": 133,
"amplifier": 10
},
"suspicious_profiles": 400,
"es_docs_written": 9474,
"es_network_docs_written": 9474,
"founding": {
"in_population": 5712,
"timing_applicable": 6118,
"percentile_ge_90": 270,
"with_patents": 152
}
},
"timings": {
"extract_s": 0.4,
"load_cache_s": 33.3,
"founding_features_s": 2.6,
"build_graph_s": 74.6,
"metrics_s": 363.1,
"signals_s": 369.1,
"founding_s": 4.5,
"scoring_s": 0.1,
"index_s": 11.2,
"network_s": 93.6
},
"top_bridgers": [
{
"author_id": "A5113304257",
"name": "Jan Egger",
"score": 0.9533,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5051904885",
"name": "Feyza Cansiz",
"score": 0.9436,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5015256836",
"name": "Giebel Bernd",
"score": 0.9403,
"bucket": "Early",
"active_years": 3,
"suspicious": false
},
{
"author_id": "A5029568311",
"name": "S. Ugurel-Becker",
"score": 0.9395,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5039473892",
"name": "D. Schadendorf",
"score": 0.9329,
"bucket": "Early",
"active_years": 3,
"suspicious": false
},
{
"author_id": "A5098748894",
"name": "Bahadır Eryılmaz",
"score": 0.927,
"bucket": "Early",
"active_years": 3,
"suspicious": false
},
{
"author_id": "A5120610796",
"name": "Ulrich Sure",
"score": 0.9263,
"bucket": "Early",
"active_years": 2,
"suspicious": false
},
{
"author_id": "A5007940140",
"name": "Amin Dada",
"score": 0.9262,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5101839832",
"name": "Mohammed-Ali Sheikh",
"score": 0.9243,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5074268016",
"name": "Anika Grüneboom",
"score": 0.922,
"bucket": "Emerging",
"active_years": 9,
"suspicious": false
}
],
"top_mentors": [
{
"author_id": "A5043495754",
"name": "Cornelius Deuschl",
"score": 0.9613,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5030635588",
"name": "Birte Möhlendick",
"score": 0.9582,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5029722705",
"name": "Freya Droege",
"score": 0.95,
"bucket": "Established",
"active_years": 14,
"suspicious": true
},
{
"author_id": "A5062907808",
"name": "Wolfgang P. Fendler",
"score": 0.9437,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5048453026",
"name": "Alpaslan Tasdogan",
"score": 0.9436,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5063064952",
"name": "Nora Bruns",
"score": 0.9408,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5036496827",
"name": "Ramazan Jabbarli",
"score": 0.9336,
"bucket": "Established",
"active_years": 13,
"suspicious": false
},
{
"author_id": "A5041276010",
"name": "Heiko Wende",
"score": 0.9291,
"bucket": "Senior",
"active_years": 31,
"suspicious": false
},
{
"author_id": "A5110823011",
"name": "Dagmar Führer",
"score": 0.9285,
"bucket": "Senior",
"active_years": 32,
"suspicious": false
},
{
"author_id": "A5047137012",
"name": "David Kersting",
"score": 0.9284,
"bucket": "Established",
"active_years": 12,
"suspicious": false
}
],
"top_amplifiers": [
{
"author_id": "A5007801159",
"name": "Jens Wiltfang",
"score": 0.9282,
"bucket": "Senior",
"active_years": 35,
"suspicious": false
},
{
"author_id": "A5049577078",
"name": "Stefan Kleine",
"score": 0.9121,
"bucket": "Emerging",
"active_years": 6,
"suspicious": false
},
{
"author_id": "A5055188384",
"name": "Benjamin Zingsem",
"score": 0.8991,
"bucket": "Established",
"active_years": 10,
"suspicious": false
},
{
"author_id": "A5036507802",
"name": "Martin Schüler",
"score": 0.8934,
"bucket": "Senior",
"active_years": 47,
"suspicious": true
},
{
"author_id": "A5123934012",
"name": "Karl Sebastian Lang",
"score": 0.8883,
"bucket": "Early",
"active_years": 1,
"suspicious": false
},
{
"author_id": "A5016532166",
"name": "Adalbert Krawczyk",
"score": 0.8779,
"bucket": "Senior",
"active_years": 16,
"suspicious": false
},
{
"author_id": "A5052587248",
"name": "Gabi Schierning",
"score": 0.8751,
"bucket": "Senior",
"active_years": 23,
"suspicious": false
},
{
"author_id": "A5024191146",
"name": "Markus Kaiser",
"score": 0.868,
"bucket": "Senior",
"active_years": 30,
"suspicious": false
},
{
"author_id": "A5044921528",
"name": "Annette Paschen",
"score": 0.862,
"bucket": "Senior",
"active_years": 29,
"suspicious": false
},
{
"author_id": "A5107541231",
"name": "Raimund Erbel",
"score": 0.8519,
"bucket": "Senior",
"active_years": 52,
"suspicious": false
}
],
"top_founder_potential": [
{
"author_id": "A5039812973",
"name": "Hamza Kalisch",
"percentile": 99.9,
"probability_raw": 0.9974,
"p_within_3y_percentile": 99.6,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5084716913",
"name": "N Blase",
"percentile": 99.9,
"probability_raw": 0.9975,
"p_within_3y_percentile": 99.7,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5102237308",
"name": "Kelsey Hermann",
"percentile": 99.9,
"probability_raw": 0.9985,
"p_within_3y_percentile": 100.0,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5031388574",
"name": "HH-J Schmidt",
"percentile": 99.9,
"probability_raw": 0.9982,
"p_within_3y_percentile": 99.9,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5063433003",
"name": "H. H. Schmidt",
"percentile": 99.9,
"probability_raw": 0.9978,
"p_within_3y_percentile": 99.8,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5082880950",
"name": "Fabian Haut",
"percentile": 99.9,
"probability_raw": 0.9975,
"p_within_3y_percentile": 99.3,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5000155431",
"name": "K Herrmann",
"percentile": 99.9,
"probability_raw": 0.9978,
"p_within_3y_percentile": 99.9,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5069143867",
"name": "Michael Dominic Harr",
"percentile": 99.8,
"probability_raw": 0.9969,
"p_within_3y_percentile": 99.8,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5090109295",
"name": "Johannes Neuhaus",
"percentile": 99.8,
"probability_raw": 0.9965,
"p_within_3y_percentile": 99.9,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
},
{
"author_id": "A5087082783",
"name": "Christopher J. Rastin",
"percentile": 99.8,
"probability_raw": 0.9965,
"p_within_3y_percentile": 99.5,
"publications": 4,
"patents": 0,
"bucket": "Early",
"tags": []
}
]
}
@@ -0,0 +1,269 @@
{
"institution": "I62318514",
"config_hash": "a49ddd388990",
"counts": {
"focal_authors_scored": 4921,
"nodes": 639544,
"edges": 4143499,
"works_used": 160396,
"works_capped": 4823,
"tags": {
"amplifier": 609,
"mentor": 91,
"bridger": 66
},
"suspicious_profiles": 225
},
"timings": {
"load_cache_s": 15.2,
"build_graph_s": 31.3,
"metrics_s": 112.2,
"scoring_s": 0.0
},
"top_bridgers": [
{
"author_id": "A5113304257",
"name": "Jan Egger",
"score": 0.9488,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5015256836",
"name": "Giebel Bernd",
"score": 0.9379,
"bucket": "Early",
"active_years": 3,
"suspicious": false
},
{
"author_id": "A5074268016",
"name": "Anika Grüneboom",
"score": 0.9277,
"bucket": "Emerging",
"active_years": 9,
"suspicious": false
},
{
"author_id": "A5101839832",
"name": "Mohammed-Ali Sheikh",
"score": 0.9227,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5093725590",
"name": "Ahammed Suhail Odungat",
"score": 0.9178,
"bucket": "Early",
"active_years": 3,
"suspicious": false
},
{
"author_id": "A5123321088",
"name": "Heiko Wende",
"score": 0.9166,
"bucket": "Early",
"active_years": 2,
"suspicious": false
},
{
"author_id": "A5093128319",
"name": "Pascal Raszke",
"score": 0.9115,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5009410023",
"name": "Yossarian Liebsch",
"score": 0.9098,
"bucket": "Early",
"active_years": 4,
"suspicious": false
},
{
"author_id": "A5038988072",
"name": "Ulrike Schara‐Schmidt",
"score": 0.9095,
"bucket": "Emerging",
"active_years": 6,
"suspicious": false
},
{
"author_id": "A5092634227",
"name": "Abdelrahman Elwy",
"score": 0.9089,
"bucket": "Early",
"active_years": 4,
"suspicious": false
}
],
"top_mentors": [
{
"author_id": "A5043495754",
"name": "Cornelius Deuschl",
"score": 0.9533,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5063064952",
"name": "Nora Bruns",
"score": 0.9508,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5062907808",
"name": "Wolfgang P. Fendler",
"score": 0.9477,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5016126468",
"name": "Jassin Rashidi‐Alavijeh",
"score": 0.9338,
"bucket": "Established",
"active_years": 13,
"suspicious": false
},
{
"author_id": "A5041276010",
"name": "Heiko Wende",
"score": 0.9314,
"bucket": "Senior",
"active_years": 31,
"suspicious": false
},
{
"author_id": "A5036496827",
"name": "Ramazan Jabbarli",
"score": 0.9271,
"bucket": "Established",
"active_years": 13,
"suspicious": false
},
{
"author_id": "A5090806187",
"name": "Ivana Kraiselburd",
"score": 0.9262,
"bucket": "Established",
"active_years": 12,
"suspicious": false
},
{
"author_id": "A5030635588",
"name": "Birte Möhlendick",
"score": 0.9244,
"bucket": "Established",
"active_years": 14,
"suspicious": false
},
{
"author_id": "A5052523213",
"name": "Ulrich Sure",
"score": 0.9229,
"bucket": "Senior",
"active_years": 32,
"suspicious": false
},
{
"author_id": "A5016243200",
"name": "Ulf Dittmer",
"score": 0.9209,
"bucket": "Senior",
"active_years": 34,
"suspicious": false
}
],
"top_amplifiers": [
{
"author_id": "A5001941348",
"name": "Matthias Rinke",
"score": 1.0,
"bucket": "Senior",
"active_years": 25,
"suspicious": false
},
{
"author_id": "A5026928109",
"name": "Nicole Stracke",
"score": 1.0,
"bucket": "Emerging",
"active_years": 6,
"suspicious": false
},
{
"author_id": "A5072469617",
"name": "Stefan Esser",
"score": 1.0,
"bucket": "Established",
"active_years": 10,
"suspicious": false
},
{
"author_id": "A5045156629",
"name": "Mirrasoul J. Mousavi",
"score": 0.9991,
"bucket": "Senior",
"active_years": 20,
"suspicious": false
},
{
"author_id": "A5102956234",
"name": "Tanja Trarbach",
"score": 0.9988,
"bucket": "Emerging",
"active_years": 6,
"suspicious": false
},
{
"author_id": "A5108819622",
"name": "Andreas Roos",
"score": 0.9982,
"bucket": "Senior",
"active_years": 15,
"suspicious": true
},
{
"author_id": "A5060245622",
"name": "Heidi Wiehler",
"score": 0.9978,
"bucket": "Established",
"active_years": 12,
"suspicious": true
},
{
"author_id": "A5005113935",
"name": "C. L. Munch",
"score": 0.9977,
"bucket": "Emerging",
"active_years": 7,
"suspicious": true
},
{
"author_id": "A5014449031",
"name": "Boris S. Kerner",
"score": 0.9973,
"bucket": "Senior",
"active_years": 51,
"suspicious": false
},
{
"author_id": "A5034381567",
"name": "Yannick Beckmann",
"score": 0.9965,
"bucket": "Emerging",
"active_years": 9,
"suspicious": false
}
]
}
+34
View File
@@ -0,0 +1,34 @@
Cohort (9 institutions, affiliation years >= 2023):
I62318514 University of Duisburg-Essen
I4210119759 Essen University Hospital
I4210161917 West German Heart and Vascular Center Essen
I127668822 Erwin L. Hahn Institute for Magnetic Resonance Imaging
I4210090139 Rhein-Ruhr Institut für Sozialforschung und Politikberatung
I4210092428 Deutsches Textilforschungszentrum Nord-West
I4210110714 Institute for Advanced Study in the Humanities Essen
I4210146441 The Hydrogen and Fuel Cell Center
I4210154243 Institut für Energie- und Umwelttechnik
Reusing cached extract (use --force-extract to refresh).
Loaded 267467 works, 9475 focal authors (19.0s)
Graph: 864646 nodes, 5822006 edges, 228103 works used, 9238 capped, ref_year=2026 (46.6s)
Metrics for 9474 focal authors (326.0s)
Signals: patents scored for 55 authors (name-only evidence: 17), news mentions for 1369 (ambiguous names skipped: 839), CORDIS projects for 1342
Signal joins done (522.1s)
Scores -> /Users/armgdon/University/projects/smart-guide/smart-guide-code/service/scripts/multiplicators/cache/scores_I62318514.jsonl.gz (0.1s)
Deleted 9474 existing docs for I62318514
Indexed 9474 docs into multiplicators_v1 (count for I62318514: 9474) (46.8s)
{
"focal_authors_scored": 9474,
"nodes": 864646,
"edges": 5822006,
"works_used": 228103,
"works_capped": 9238,
"tags": {
"mentor": 161,
"bridger": 133,
"amplifier": 10
},
"suspicious_profiles": 400,
"es_docs_written": 9474
}
Summary -> /Users/armgdon/University/projects/smart-guide/smart-guide-code/service/scripts/multiplicators/cache/build_summary_I62318514.json
@@ -0,0 +1,37 @@
Cohort (9 institutions, affiliation years >= 2023):
I62318514 University of Duisburg-Essen
I4210119759 Essen University Hospital
I4210161917 West German Heart and Vascular Center Essen
I127668822 Erwin L. Hahn Institute for Magnetic Resonance Imaging
I4210090139 Rhein-Ruhr Institut für Sozialforschung und Politikberatung
I4210092428 Deutsches Textilforschungszentrum Nord-West
I4210110714 Institute for Advanced Study in the Humanities Essen
I4210146441 The Hydrogen and Fuel Cell Center
I4210154243 Institut für Energie- und Umwelttechnik
Reusing cached extract (use --force-extract to refresh).
Loaded 267467 works, 9475 focal authors (18.8s)
Graph: 864646 nodes, 5822006 edges, 228103 works used, 9238 capped, ref_year=2026 (45.0s)
Metrics for 9474 focal authors (319.0s)
Signals: patents scored for 55 authors (name-only evidence: 17), news mentions for 1369 (ambiguous names skipped: 839), CORDIS projects for 1342
Signal joins done (389.7s)
Scores -> /Users/armgdon/University/projects/smart-guide/smart-guide-code/service/scripts/multiplicators/cache/scores_I62318514.jsonl.gz (0.1s)
Deleted 9474 existing docs for I62318514
Indexed 9474 docs into multiplicators_v1 (count for I62318514: 9474) (11.4s)
Deleted 0 existing docs for I62318514
Indexed 9474 network docs into multiplicator_networks_v1 (92.7s)
{
"focal_authors_scored": 9474,
"nodes": 864646,
"edges": 5822006,
"works_used": 228103,
"works_capped": 9238,
"tags": {
"mentor": 161,
"bridger": 133,
"amplifier": 10
},
"suspicious_profiles": 400,
"es_docs_written": 9474,
"es_network_docs_written": 9474
}
Summary -> /Users/armgdon/University/projects/smart-guide/smart-guide-code/service/scripts/multiplicators/cache/build_summary_I62318514.json
@@ -0,0 +1,99 @@
{
"institution": {
"id": "https://openalex.org/I62318514",
"short_id": "I62318514",
"ror": "https://ror.org/04mz5ra38",
"display_name": "University of Duisburg-Essen"
},
"cohort": [
{
"id": "I62318514",
"display_name": "University of Duisburg-Essen"
},
{
"id": "I4210119759",
"display_name": "Essen University Hospital"
},
{
"id": "I4210161917",
"display_name": "West German Heart and Vascular Center Essen"
},
{
"id": "I127668822",
"display_name": "Erwin L. Hahn Institute for Magnetic Resonance Imaging"
},
{
"id": "I4210090139",
"display_name": "Rhein-Ruhr Institut für Sozialforschung und Politikberatung"
},
{
"id": "I4210092428",
"display_name": "Deutsches Textilforschungszentrum Nord-West"
},
{
"id": "I4210110714",
"display_name": "Institute for Advanced Study in the Humanities Essen"
},
{
"id": "I4210146441",
"display_name": "The Hydrogen and Fuel Cell Center"
},
{
"id": "I4210154243",
"display_name": "Institut für Energie- und Umwelttechnik"
}
],
"reproduction": {
"author_count": 6583,
"work_count": 221603,
"group_breakdown": {
"backend_compatible": 6360,
"empty_last_known_recent": 223
}
},
"field_coverage": {
"authorships_total": 4365638,
"author_position_pct": 100.0,
"is_corresponding_pct": 100.0,
"institutions_total": 3934359,
"institution_type_pct": 99.9,
"company_institutions": 82976
},
"scale": {
"works": 221603,
"authors_per_work": {
"p50": 5,
"p90": 18,
"p99": 174,
"max": 4839
},
"hyperauthorship_works_gt_100": 3179,
"pair_instances_at_cap": {
"20": 4921446,
"50": 10209552,
"100": 17642513
}
},
"career_quality": {
"authors_with_works": 6583,
"suspicious_profile_count": 302,
"suspicious_profile_pct": 4.59,
"active_years": {
"p50": 4,
"p90": 24,
"max": 63,
"mean": 8.61
}
},
"signals": {
"org_patents_for_institution": 462,
"match_type_breakdown": {
"name": 339,
"both": 65,
"institution": 58
}
},
"permissions": {
"skipped": "pass --probe-writes to test index create/bulk/delete"
}
}
@@ -0,0 +1,61 @@
{
"institution": {
"id": "https://openalex.org/I62318514",
"short_id": "I62318514",
"ror": "https://ror.org/04mz5ra38",
"display_name": "University of Duisburg-Essen"
},
"reproduction": {
"author_count": 4921,
"work_count": 183661,
"group_breakdown": {
"backend_compatible": 4740,
"empty_last_known_recent": 181
}
},
"field_coverage": {
"authorships_total": 3805507,
"author_position_pct": 100.0,
"is_corresponding_pct": 100.0,
"institutions_total": 3482939,
"institution_type_pct": 99.91,
"company_institutions": 67131
},
"scale": {
"works": 183661,
"authors_per_work": {
"p50": 5,
"p90": 17,
"p99": 144,
"max": 4839
},
"hyperauthorship_works_gt_100": 2459,
"pair_instances_at_cap": {
"20": 3912695,
"50": 7962611,
"100": 13897380
}
},
"career_quality": {
"authors_with_works": 4921,
"suspicious_profile_count": 225,
"suspicious_profile_pct": 4.57,
"active_years": {
"p50": 4,
"p90": 25,
"max": 60,
"mean": 8.94
}
},
"signals": {
"org_patents_for_institution": 436,
"match_type_breakdown": {
"name": 313,
"both": 65,
"institution": 58
}
},
"permissions": {
"create_index": 403
}
}
@@ -0,0 +1,79 @@
Sample: 60 people, matched in scores: 51, missing: 9
MISSING: Peter Bayer (A5060566345)
MISSING: Richard Kosinski (A5014403509)
MISSING: Alexandra Dmitrienko (A5042835341)
MISSING: Wilhelm Koop (A5019228221)
MISSING: Venkata Marella (A5082156768)
MISSING: Miriam Böhm (A5037448457)
MISSING: Katrin Schuldt (A5002003996)
MISSING: Friedrich Scheller (A5072565080)
MISSING: Lara Altenstädter (A5070117981)
=== mentor sub-score by known status ===
Professor n=29 median=0.740 mean=0.691 range=[0.153, 0.921]
Researcher n=22 median=0.494 mean=0.514 range=[0.242, 0.958]
=== bridger sub-score by known status ===
Professor n=29 median=0.629 mean=0.618 range=[0.291, 0.856]
Researcher n=22 median=0.469 mean=0.509 range=[0.224, 0.796]
=== amplifier sub-score by known status ===
Professor n=29 median=0.612 mean=0.584 range=[0.357, 0.840]
Researcher n=22 median=0.450 mean=0.529 range=[0.363, 0.772]
M1 exit check — professors' median mentor score (0.74) > researchers' (0.494): PASS
=== per-person (sorted by mentor score) ===
0.958 Researcher Established juniors= 30 laj= 6 Birte Möhlendick (Medicine)
0.921 Professor Senior juniors=110 laj= 11 Oliver Witzke (Medicine)
0.908 Professor Senior juniors= 56 laj= 12 Daniel Hoffmann (Biology)
0.903 Professor Senior juniors= 92 laj= 7 Matthias Gunzer (Medicine)
0.898 Professor Senior juniors= 41 laj= 16 Gerd Bacher (Engineering)
0.891 Professor Senior juniors= 48 laj= 23 Ulrike Bingel (Medicine)
0.888 Professor Senior juniors= 70 laj= 27 Bernd Sures (Biology)
0.879 Professor Senior juniors=116 laj= 6 Boris Hadaschik (Medicine)
0.862 Professor Senior juniors=128 laj= 2 Stephan Lang (Medicine)
0.848 Professor Senior juniors= 40 laj= 25 Daniel Hering (Biology)
0.833 Professor Senior juniors= 28 laj= 31 Stefan Schneegaß (Computer Science)
0.786 Professor Senior juniors= 19 laj= 27 Torben Weis (Computer Science)
0.781 Professor Senior juniors= 18 laj= 23 Pedro José Marrón (Computer Science)
0.777 Professor Senior juniors= 29 laj= 4 Corina Andronescu (Engineering)
0.762 Professor Senior juniors= 14 laj= 7 Barbara Saccà (Biology)
0.740 Professor Senior juniors= 8 laj= 15 Lucas Davi (Computer Science)
0.735 Professor Senior juniors= 13 laj= 24 Burak Atakan (Engineering)
0.723 Researcher Senior juniors= 67 laj= 0 Farnusch Kaschani (Biology)
0.722 Professor Senior juniors= 12 laj= 11 Barbara König (Computer Science)
0.712 Professor Senior juniors= 12 laj= 21 Gregor Schiele (Computer Science)
0.707 Professor Senior juniors= 10 laj= 11 Volker Gruhn (Computer Science)
0.679 Researcher Senior juniors= 16 laj= 1 Marcus Handte (Computer Science)
0.659 Professor Senior juniors= 45 laj= 0 Hartmut Schmidt (Medicine)
0.654 Researcher Senior juniors= 22 laj= 0 Daniel Grabner (Biology)
0.612 Professor Senior juniors= 13 laj= 0 Tienush Rassaf (Medicine)
0.605 Professor Senior juniors= 6 laj= 8 Jens Krüger (Computer Science)
0.601 Professor Senior juniors= 9 laj= 3 Andreas Metzger (Computer Science)
0.513 Professor Senior juniors= 4 laj= 5 Andreas Vogelsang (Computer Science)
0.500 Professor Senior juniors= 3 laj= 2 Frank Kleemann (Sociology)
0.494 Researcher Early juniors= 0 laj= 0 Bianca Kamba (Biology)
0.494 Researcher Early juniors= 0 laj= 0 Carina Liebers (Computer Science)
0.494 Researcher Early juniors= 0 laj= 0 Jonas Keppel (Computer Science)
0.494 Researcher Early juniors= 0 laj= 0 Carlos Medina Sánchez (Computer Science)
0.494 Researcher Early juniors= 0 laj= 0 Christian Scholz (Computer Science)
0.494 Researcher Early juniors= 0 laj= 0 Tobias Mikolas (Engineering)
0.494 Researcher Early juniors= 0 laj= 0 Julia Schwichtenberg (Medicine)
0.494 Researcher Early juniors= 0 laj= 0 Antonia Görtz (Sociology)
0.494 Researcher Early juniors= 0 laj= 0 Lisa Mansfeld (Sociology)
0.488 Researcher Emerging juniors= 0 laj= 0 Simon Janzon (Computer Science)
0.488 Researcher Emerging juniors= 0 laj= 0 Christian Niesler (Computer Science)
0.488 Researcher Emerging juniors= 0 laj= 0 Pascal Winkler (Computer Science)
0.488 Researcher Emerging juniors= 0 laj= 0 Soheil Salighe (Engineering)
0.488 Researcher Emerging juniors= 0 laj= 0 Sabrina Guckenbiehl (Medicine)
0.488 Researcher Emerging juniors= 0 laj= 0 Zülal Cibir (Medicine)
0.418 Researcher Senior juniors= 6 laj= 0 Stefan Hanenberg (Computer Science)
0.377 Professor Senior juniors= 2 laj= 0 Ute Klammer (Sociology)
0.251 Researcher Senior juniors= 1 laj= 0 Kathrin Januschke (Biology)
0.242 Researcher Established juniors= 0 laj= 0 Andreas Jansen (Sociology)
0.240 Professor Senior juniors= 1 laj= 0 Helen Baykara-Krumme (Sociology)
0.227 Professor Senior juniors= 1 laj= 0 Marcel Erlinghagen (Sociology)
0.153 Professor Senior juniors= 0 laj= 0 Gregor Bongaerts (Sociology)
Report -> /Users/armgdon/University/projects/smart-guide/smart-guide-code/service/scripts/multiplicators/cache/validation_I62318514.json
@@ -0,0 +1,62 @@
{
"missing": [
"Peter Bayer (A5060566345)",
"Richard Kosinski (A5014403509)",
"Alexandra Dmitrienko (A5042835341)",
"Wilhelm Koop (A5019228221)",
"Venkata Marella (A5082156768)",
"Miriam Böhm (A5037448457)",
"Katrin Schuldt (A5002003996)",
"Friedrich Scheller (A5072565080)",
"Lara Altenstädter (A5070117981)"
],
"by_status": {
"Professor": {
"mentor": {
"n": 29,
"median": 0.74,
"mean": 0.691,
"min": 0.153,
"max": 0.921
},
"bridger": {
"n": 29,
"median": 0.629,
"mean": 0.618,
"min": 0.291,
"max": 0.856
},
"amplifier": {
"n": 29,
"median": 0.612,
"mean": 0.584,
"min": 0.357,
"max": 0.84
}
},
"Researcher": {
"mentor": {
"n": 22,
"median": 0.494,
"mean": 0.514,
"min": 0.242,
"max": 0.958
},
"bridger": {
"n": 22,
"median": 0.469,
"mean": 0.509,
"min": 0.224,
"max": 0.796
},
"amplifier": {
"n": 22,
"median": 0.45,
"mean": 0.529,
"min": 0.363,
"max": 0.772
}
}
},
"m1_exit_mentor_check": "PASS"
}
@@ -0,0 +1,70 @@
{
"missing": [
"Barbara Saccà (A5075803366)",
"Peter Bayer (A5060566345)",
"Richard Kosinski (A5014403509)",
"Alexandra Dmitrienko (A5042835341)",
"Christian Niesler (A5069184110)",
"Pascal Winkler (A5081189339)",
"Wilhelm Koop (A5019228221)",
"Venkata Marella (A5082156768)",
"Miriam Böhm (A5037448457)",
"Soheil Salighe (A5041884757)",
"Tobias Mikolas (A5002909977)",
"Oliver Witzke (A5087456839)",
"Ulrike Bingel (A5002281474)",
"Katrin Schuldt (A5002003996)",
"Helen Baykara-Krumme (A5010111732)",
"Friedrich Scheller (A5072565080)",
"Lara Altenstädter (A5070117981)"
],
"by_status": {
"Professor": {
"mentor": {
"n": 25,
"median": 0.715,
"mean": 0.663,
"min": 0.153,
"max": 0.921
},
"bridger": {
"n": 25,
"median": 0.603,
"mean": 0.598,
"min": 0.229,
"max": 0.849
},
"amplifier": {
"n": 25,
"median": 0.655,
"mean": 0.604,
"min": 0.173,
"max": 0.957
}
},
"Researcher": {
"mentor": {
"n": 18,
"median": 0.493,
"mean": 0.503,
"min": 0.153,
"max": 0.924
},
"bridger": {
"n": 18,
"median": 0.508,
"mean": 0.521,
"min": 0.181,
"max": 0.804
},
"amplifier": {
"n": 18,
"median": 0.413,
"mean": 0.543,
"min": 0.161,
"max": 0.971
}
}
},
"m1_exit_mentor_check": "PASS"
}