Home

Awesome

ARElight 0.25.0

Open In Colab PyPI downloads

:point_right: DEMO :point_left:

<p align="center"> <img src="logo.png"/> </p>

ARElight is an application for a granular view onto sentiments between mentioned named entities in texts. This repository is a part of the ECIR-2024 demo paper: ARElight: Context Sampling of Large Texts for Deep Learning Relation Extraction.

Installation

pip install git+https://github.com/nicolay-r/arelight@v0.25.0

Usage: Inference

Open In Colab

Infer sentiment attitudes from text file in English:

python3 -m arelight.run.infer  \
    --sampling-framework "arekit" \
    --ner-framework "deeppavlov" \
    --ner-model-name "ner_ontonotes_bert" \
    --ner-types "ORG|PERSON|LOC|GPE" \
    --terms-per-context 50 \
    --sentence-parser "nltk:english" \
    --tokens-per-context 128 \
    --bert-framework "opennre" \
    --batch-size 10 \
    --pretrained-bert "bert-base-cased" \
    --bert-torch-checkpoint "ra4-rsr1_bert-base-cased_cls.pth.tar" \
    --backend "d3js_graphs" \
    --docs-limit 500 \
    -o "output" \
    --from-files "<PATH-TO-TEXT-FILE>"

NOTE: Applying ARElight for non-english texts

<details> <summary>

Parameters

</summary>

The complete documentation is available via -h flag:

python3 -m arelight.run.infer -h

Parameters:

Framework parameters mentioned above as well as their related setups might be ommited.

</details>

Usage: 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.

<details> <summary>

Parameters

</summary> </details> <details> <summary>

Parameter operation

</summary>

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 $(G_1 \cup G_2)$ - combine multiple graphs together.

INTERSECTION $(G_1 \cap G_2)$ - what is similar between 2 graphs?

DIFFERENCE $(G_1 - G_2)$ - what is unique in one graph, that another graph doesn't have?

</details> <details> <summary>

Parameter weights

</summary>

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.

</details>

Powered by

<p float="left"> <a href="https://github.com/nicolay-r/AREkit"><img src="https://github.com/nicolay-r/ARElight/assets/14871187/01232f7a-970f-416c-b7a4-1cda48506afe"/></a> </p>

How to cite

Our one and my personal interest is to help you better explore and analyze attitude and relation extraction related tasks with ARElight. A great research is also accompanied with the faithful reference. if you use or extend our work, please cite as follows:

@inproceedings{rusnachenko2024arelight,
  title={ARElight: Context Sampling of Large Texts for Deep Learning Relation Extraction},
  author={Rusnachenko, Nicolay and Liang, Huizhi and Kolomeets, Maxim and Shi, Lei},
  booktitle={European Conference on Information Retrieval},
  year={2024},
  organization={Springer}
}