Global Geopolitical Risk Project: News NLP
Notebook NewsApp demonstrate the usage of Python package pip install news-nlp
https://pypi.org/project/news-nlp/
This project aims to measure country-level Geopolitical Risk (GPR) based on news data. This risk index consists of seven predefined components, including Conflict, Terror Thteat, Corruption, Environment, Social, Governance (ESG) and foreign policy. This project covers:
- identifying search terms using NLP TF-IDF method;
- an unsupervised clustering model (K-means) to categorise search terms into five groups.
- an NLP deep learning model to classify news articles into the predefined topics.
- an hierarchy statistical model to infer news event location at country level and then
- an geolocator in terms of longitude, latitude, and population
- a supervised sentiment classifier to categorize GPR news articles into three classes, positive, neutral, and negative.
news-nlp
pacakge
Section 1: Usage of -
download sample news dataset from
data
folder -
Suggect to run it in conda virtual environment named news_nlp
conda create -n news_nlp python=3.10 -y
conda activate news_nlp
- install dependcies
python -m spacy download en_core_web_lg
install cliff docker image to geoloate text data in terms of lan, lon, popualtion, location name, location type etc
docker pull rahulbot/cliff-clavin:2.6.1
docker run -p 8080:8080 -m 8G -d --name cliff rahulbot/cliff-clavin:2.6.1
where cliff
is the name of container
- install News_NLP
pip install news-nlp
Section 2: Docker Image
(no need to config development environment)
-
https://hub.docker.com/repository/docker/zhenxianlu/news-nlp-amd64/general
-
download docker image
docker pull zhenxianlu/news-nlp-amd64:latest
-
check local images
docker images
-
start this image
sudo docker run -itd --name news-nlp zhenxianlu/news-nlp-amd64:latest /bin/bash
wherenews-nlp
is to name the contianer -
check running containers
sudo docker ps
-
keep container running
sudo docker attach news-nlp
-
create bridge network to connect
news-nlp
container withcliff
containersudo docker network create -n my-net
create a bridge named my-netsudo docker network connect my-net news-nlp
sudo docker network connect my-net cliff
-
check the IPs of the contianers connected to
my-net
sudo docker network inspect my-net
copy the IP of containercliff
for future use, it should something like that172.**.*.*
-
Enter container
sudo docker container attach news-nlp
-
Enter folder
cd News_NLP/
-
Open
geolocator.py
byvim
and amend the linemy_cliff = Cliff('http://0.0.0.0:8080')
asmy_cliff = Cliff('http://172.**.*.*:8080')
-
Back to parent folder
cd ..
-
Excute
pyhton main.py
-
Additonally, copy file from container to host on the terminal of host
sudo docker cp nlp:/NewsApp/News_NLP/data/new_data.csv /host/path/target
lasted updated on Feb 8, 2023