Skip to content
/ bias Public

Measures the percentage of words with negative or positive biases in a text document.

Notifications You must be signed in to change notification settings

katurian/bias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

bias

bias.py tokenizes a text file, then gives a sentiment polarity score (-1:1) to every word in the document. If any word has a score above or below 0, the variable bias = bias + 1. Once the for loop completes, bias.py divides bias by the total number of words in the document. The returned output represents the percentage of biased language in said *.txt, based on the python textblob package.

https://textblob.readthedocs.io/en/dev/quickstart.html#sentiment-analysis

Setup

Install the dependencies listed in requirements.txt, e.g:

pip install -r requirements.txt

Usage

Call bias.bias() or execute bias.py with text file location as first argument. See some sample text files in examples/ directory. Examples of usage:

from bias import bias
with open("./examples/breitbart_short.txt", 'r') as infile:
    bias(infile)
python bias.py ./examples/economist.txt

About

Measures the percentage of words with negative or positive biases in a text document.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages