slant
enables researchers to both reliably and efficiently assess the degree to which texts β
generated either by machines or people β contain bias. The governing concern here is the
proliferation of language generation models not being met with comparable efforts to determine the
nature of the text they produce. Due to the large scale of data they produce, analysis must be fast
and simple to encourage researcher use. The advantage of such an approach is that is as easy to run
on single, smaller examples as it is to run on large datasets. Bias is detected across multiple
dimensions, primarily race/ethnicity, gender, sexual and religious orientation, and political
affiliation and ideology.
python3 -m pip install slant
All code is self documented, further information can be found there.
Get the VADER sentiment score of a given text or texts.
import slant
vader_test_sentences = [
"VADER is smart, handsome, and funny.", "VADER is smart, handsome, and funny!",
"VADER is very smart, handsome, and funny.", "VADER is VERY SMART, handsome, and FUNNY.",
"VADER is VERY SMART, handsome, and FUNNY!!!",
"VADER is VERY SMART, uber handsome, and FRIGGIN FUNNY!!!",
"VADER is not smart, handsome, nor funny.", "The book was good.",
"At least it isn't a horrible book.", "The book was only kind of good.",
"The plot was good, but the characters are uncompelling and the dialog is not great.",
"Today SUX!", "Today only kinda sux! But I'll get by, lol", "Make sure you :) or :D today!",
"Catch utf-8 emoji such as π and π and π", "Not bad at all"
]
print(slant.sentiment(vader_test_sentences))
Determine whether a given text or texts contains potential bias words.
import slant
print(slant.has_bias_words(some_text))
Return found bias words, if any, within a given text or texts.
import slant
print(slant.get_bias_words(some_text))
Return the most frequently words, not including stop words, in a given text or texts.
import slant
print(slant.top_words(some_text))
slant
's non-exhaustive list of bias words.
import slant
print(slant.bias_words)
slant
's non-exhaustive list of stop words.
import slant
print(slant.stop_words)