Text-based gender prediction for Twitter.
Project description
A packaged version, adapted to Python 3, of the TwitterGenderPredictor code by JT Wolohan, which itself is a Python 2 implementation of Sap et al.’s gender prediction algorithm for Twitter. SPEKS stands for Sap, Park, Eichstaedt, Kern and Stilwell, the first five writers of the paper describing the algorithm implemented here.
>>> from speks import predict_gender_by_tweets
>>> gender = predict_gender_by_tweets(" ".join(["Please Do.", "Join me in praying!"]))
1 Features
Supports Python 3.
pip-installable.
Fully tested.
2 Installation
pip install speks
3 Use
This is a Python 3, packaged version of the TwitterGenderPredictor code by JT Wolohan, which itself is a Python 2 implementation of Sap et al.’s gender prediction algorithm for Twitter. The algorithm should be 90% accurate given a large sample of users and a reasonable amount of data for each user.
You can have the package predict the gender of a Twitter user by providing the predict_gender_by_tweets function with a string containing tweets contents.
>>> from speks import predict_gender_by_tweets
>>> gender = predict_gender_by_tweets(" ".join(["No touchy", "Trial by fire"]))
4 Licensing
Most of the code was released by JT Wolohan under the MPL 2.0 license, and thus I’m releasing my additions under the same license. However, the tokenization code - although slightly adapted - was originally written by Christopher Potts and released under the CC BY-NC-SA 3.0 license, and thus remains released under this license.
5 Contributing
Current package maintainer and author is Shay Palachy (shay.palachy@gmail.com); You are more than welcome to approach him for help. Contributions are very welcomed.
5.1 Installing for development
Clone:
git clone git@github.com:shaypal5/speks.git
Install in development mode, including test dependencies:
cd speks
pip install -e '.[test]'
5.2 Running the tests
To run the tests use:
cd speks
pytest
5.3 Adding documentation
The project is documented using the numpy docstring conventions, which were chosen as they are perhaps the most widely-spread conventions that are both supported by common tools such as Sphinx and result in human-readable docstrings. When documenting code you add to this project, follow these conventions.
Additionally, if you update this README.rst file, use python setup.py checkdocs to validate it compiles.
6 Credits
Algorithm by Sap et al. Original code by JT Wolohan, with tokenization code by Christopher Potts. Packaging and Python 3 adaptation by Shay Palachy.
Original paper reference: Sap, M., Park, G., Eichstaedt, J., Kern, M., Stillwell, D., Kosinski, M., … & Schwartz, H. A. (2014). Developing age and gender predictive lexica over social media. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP) (pp. 1146-1151).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file speks-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: speks-0.0.1-py3-none-any.whl
- Upload date:
- Size: 97.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0ee5c518214a9123dd176a49469cce8f783d12c12732e41c90c0380d1c45a90 |
|
MD5 | db8d65e5b3d2c5baadeca8bf1245c15c |
|
BLAKE2b-256 | 3b94fd91a8b5c5d123854a3ca7db07695b15515282f4100bc3bb6e222d334c6b |