Skip to main content

MLD Article Analysis

CircleCI

MLD, pronounced Mold, is a command line based application that uses natural language processing (NLP) techniques to analyze the tone, sentiment, and lexical signature of a news article of a user-inputted URL.

Disclaimer

The project is developed and maintained by students as part of Jory Morrison's mentorship program for secondary education students. There is no affiliation, endorsement, ownership, or sponsorship with or by any commercial or non-commercial entity. Ownership of this repository should not be construed as contribution or creation of intellectual property; please reference commit history for attribution of intellectual property origin.

License

Apache 2.0 License applies

Notes

As of September 2019 this project is being actively maintained. It is currently in a limited-functioning state due to changes in the Watson SDK. Please reference issues

This project uses the IBM Watson Tone Analyzer API, which requires an IMB Creative Cloud account.

Prerequisites

Cloning the Project

To clone this project, use the following command:

$ git clone https://github.com/jorymorrison/MLD.git

Installing Requirements

Use these commands to install all required dependencies:

$ cd MLD
$ pip install -r requirements.txt

Basic Usage

Once a URL to a news article is inputted, the program will process the article's text and output the sentiment in terms of polarity and subjectivity, the tone, and five key words that make up the article's lexical signature.

Enter the URL of a news article as the first argument when calling in command line:https://abcnews.go.com/Politics/john-mccain-memorials-start-longtime-senators-body-lying/story?id=57472926
Retrieving satus code...Successfully retrieved status code: 200
Successfully retrieved representation.
Creating results file...
Successfully created results file at: /home/libbymadren/MLD\'John McCain will always have our back': Politicians pay tribute to the late senator-2018-08-29 19:47:37.537351.txt
Successfully wrote retrieval status to results file.
Successfully wrote retrieval to results file.
Successfully retrieved document sentiment.
Successfully retrieved document tone.
Successfully accessed corpus with 2 invalid documents.
Successfully calculated lexical signature.
Successfully wrote output to results file.
Exiting program...

The article's title, body text, and all output results are submitted to a results txt folder found in the repository.

Obtaining Watson API Keys

The first time this program runs, the program will search for Watson API keys. If none are found, you will be instructed to set your Watson username and password.

To access the Watson API Keys, log into your IBM Creative Cloud Account and locate the Tone Analyzer page. Click Create, and a username and password will be generated for you. Copy these and set them in the application by either editing the config.conf file, or by setting environmental variables:

$ export WATSON_USER="apikey"
$ export WATSON_PASS=<apikey-url>

Output Synopsis

Json Schema:

{
    "article": {
        "body": <body-text>,
		"date": <date>,
        "title": <title>,
        "url": <url>
    },
    "sentiment": {
        "polarity": <value 0-1>,
        "subjectivity": <value 0-1>
    },
    "signature": {
        <most frequent>: <value 0-1>,
        <most frequent>: <value 0-1>,
        <most frequent>: <value 0-1>,
        <most frequent>: <value 0-1>,
        <most frequent>: <value 0-1>
    },
    "tone": {
		<tone>: <value 0-1>,
		<tone>: <value 0-1>,
		<tone>: <value 0-1>,
		<tone>: <value 0-1>,
		<tone>: <value 0-1>,
		<tone>: <value 0-1>
	}
}

Sentiment:

Polarity: Scale -1 - 1 (-1 being very negative, 0 being neutral, 1 being very positive)

Subjectivity: Scale 0 - 1 (0 is very objective, 1 is very subjective)

Tone:

Tonal scores are displayed on a scale from 0.5 - 1, with lower scores indicating emotions less present in the document, and higher scores indicating emotions that are likely perceived in the content. Scores higher than 0.75 should be consider very emotional. For in depth documentation on the IBM Watson Tonal Analyzer go to: https://console.bluemix.net/docs/services/tone-analyzer/using-tone.html#using-the-general-purpose-endpoint

Lexical Signature:

Lexical signature is represented by the top 5 words in a document according to Term Frequency / Inverse Document Frequency (TF-IDF). For in depth documentation of how TF-IDF is calculated go to: https://http//www.tfidf.com Output is formatted in key-value pairs of a word and its TF-IDF score.

Metadata

Release files for MLDToolkit 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MLDToolkit 0.5.2
File Size Uploaded
MLDToolkit-0.5.2.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for MLDToolkit 0.5.2
File Interpreter ABI Platform
MLDToolkit-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.4 kB

Release files / MLDToolkit-0.5.2.tar.gz

Download URL MLDToolkit-0.5.2.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b56a45773f1d39f4e575e4e750f8b6cd9e8742d7af1e9e4f6d5a4e5f7c845d95
BLAKE2b-256 checksum
How to use checksums
8b1741ef980d733cb671ecade713a80ccad58f34d7ff6936c12f71aa85fa3419
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.8.0 tqdm/4.42.0 CPython/3.6.10

Release files / MLDToolkit-0.5.2-py3-none-any.whl

Download URL MLDToolkit-0.5.2-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf0a1581e47c53f6b340e9ec0c3ef3baf1daf60d879e1b3074c15ab62d2d4672
BLAKE2b-256 checksum
How to use checksums
27908fed1b705c824de46b42306f99aa92909a0e05bba35c0050df9f26709fce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.8.0 tqdm/4.42.0 CPython/3.6.10

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.0.8

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page