ARE-d3js

January 4, 2026 ยท View on GitHub

A D3.js GUI for Information Retrieval and Visualization of Extracted Relations.

Stack:

  • Flask -- web server
  • ARElight -- AI / NLP backend ๐Ÿค–
    • nlp-thidgate -- providers for NLP components ๐Ÿ“ฆ๏ธ
interface

Installation

Clone project and install dependencies:

pip install -r dependencies.txt

Usage

python3 server.py

You may follow the UI page at http://127.0.0.1:8000/

Data Layout

noutput/
โ”œโ”€โ”€ description/
    โ””โ”€โ”€ ...         // graph descriptions in JSON.
โ”œโ”€โ”€ force/
    โ””โ”€โ”€ ...         // force graphs in JSON.
โ”œโ”€โ”€ radial/
    โ””โ”€โ”€ ...         // radial graphs in JSON.
โ””โ”€โ”€ index.html      // main HTML demo page. 

Graph Operations

For graph analysis you can perform several graph operations by this script:

  1. Arguments mode:
python3 -m arelight.run.operations \
	--operation "<OPERATION-NAME>" \
	--graph_a_file output/force/boris.json \
  	--graph_b_file output/force/rishi.json \
  	--weights y \
  	-o output \
  	--description "[OPERATION] between Boris Johnson and Rishi Sunak on X/Twitter"
  1. Interactive mode:
python3 -m arelight.run.operations

arelight.run.operations allows you to operate ARElight's outputs using graphs: you can merge graphs, find their similarities or differences.

Parameters

  • --graph_a_file and --graph_b_file are used to specify the paths to the .json files for graphs A and B, which are used in the operations. These files should be located in the <your_output/force> folder.
  • --name -- name of the new graph.
  • --description -- description of the new graph.
  • --host -- determines the server port to host after the calculations.
  • -o -- option allows you to specify the path to the folder where you want to store the output. You can either create a new output folder or use an existing one that has been created by ARElight.

Parameter operation

Preparation

Consider that you used ARElight script for X/Twitter to infer relations from messages of UK politicians Boris Johnson and Rishi Sunak:

python3 -m arelight.run.infer ...other arguments... \
	-o output --collection-name "boris" --from-files "twitter_boris.txt"
	
python3 -m arelight.run.infer  ...other arguments... \
	-o output --collection-name "rishi" --from-files "twitter_rishi.txt"

According to the results section, you will have output directory with 2 files force layout graphs:

output/
โ”œโ”€โ”€ force/
    โ”œโ”€โ”€  rishi.json
    โ””โ”€โ”€  boris.json

List of Operations

You can do the following operations to combine several outputs, ot better understand similarities, and differences between them:

UNION (G1โˆชG2)(G_1 \cup G_2) - combine multiple graphs together.

  • The result graph contains all the vertices and edges that are in G1G_1 and G2G_2. The edge weight is given by We=We1+We2W_e = W_{e1} + W_{e2}, and the vertex weight is its weighted degree centrality: Wv=โˆ‘eโˆˆEvWe(e)W_v = \sum_{e \in E_v} W_e(e).
    python3 -m arelight.run.operations --operation UNION \
        --graph_a_file output/force/boris.json \
        --graph_b_file output/force/rishi.json \
        --weights y -o output --name boris_UNION_rishi \
        --description "UNION of Boris Johnson and Rishi Sunak Twits"
    
    union

INTERSECTION (G1โˆฉG2)(G_1 \cap G_2) - what is similar between 2 graphs?

  • The result graph contains only the vertices and edges common to G1G_1 and G2G_2. The edge weight is given by We=minโก(We1,We2)W_e = \min(W_{e1},W_{e2}), and the vertex weight is its weighted degree centrality: Wv=โˆ‘eโˆˆEvWe(e)W_v = \sum_{e \in E_v} W_e(e).
    python3 -m arelight.run.operations --operation INTERSECTION \
        --graph_a_file output/force/boris.json \
        --graph_b_file output/force/rishi.json \
        --weights y -o output --name boris_INTERSECTION_rishi \
        --description "INTERSECTION between Twits of Boris Johnson and Rishi Sunak"
    
    intersection

DIFFERENCE (G1โˆ’G2)(G_1 - G_2) - what is unique in one graph, that another graph doesn't have?

  • NOTE: this operation is not commutative (G1โˆ’G2)โ‰ G2โˆ’G1)(G_1 - G_2) โ‰  G_2 - G_1))_
  • The results graph contains all the vertices from G1G_1 but only includes edges from E1E_1 that either don't appear in E2E_2 or have larger weights in G1G_1 compared to G2G_2. The edge weight is given by We=We1โˆ’We2W_e = W_{e1} - W_{e2} if eโˆˆE1e \in E_1, eโˆˆE1โˆฉE2e \in E_1 \cap E_2 and We1(e)>We2(e)W_{e1}(e) > W_{e2}(e).
    python3 -m arelight.run.operations --operation DIFFERENCE \
        --graph_a_file output/force/boris.json \
        --graph_b_file output/force/rishi.json \
        --weights y -o output --name boris_DIFFERENCE_rishi \
        --description "Difference between Twits of Boris Johnson and Rishi Sunak"
    
    difference

Parameter weights

You have the option to specify whether to include edge weights in calculations or not. These weights represent the frequencies of discovered edges, indicating how often a relation between two instances was found in the text analyzed by ARElight.

  • --weights
    • y: the result will be based on the union, intersection, or difference of these frequencies.
    • n: all weights of input graphs will be set to 1. In this case, the result will reflect the union, intersection, or difference of the graph topologies, regardless of the frequencies. This can be useful when the existence of relations is more important to you, and the number of times they appear in the text is not a significant factor.

    Note that using or not using the weights option may yield different topologies:

    weights