Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
ToneTint is a Python package that provides an intuitive way to perform sentiment analysis on text data and visualize the results. It splits the input text into manageable chunks, analyzes each chunk using a pre-trained sentiment analysis model, and highlights the text with background colors corresponding to the sentiment. Additionally, it displays tooltips with detailed sentiment scores when hovering over each text chunk.
ToneTint is a Python package that provides an intuitive way to perform sentiment analysis on text data and visualize the results. It splits the input text into manageable chunks, analyzes each chunk using a pre-trained sentiment analysis model, and highlights the text with background colors corresponding to the sentiment. Additionally, it displays tooltips with detailed sentiment scores when hovering over each text chunk. Perfect for Jupyter Notebooks & Steamlit.
You can install ToneTint via pip:
pip install tonetint
Alternatively, you can clone the repository and install it manually:
git clone https://github.com/janduplessis883/tonetint_package.git
cd tonetint_package
python setup.py install
from tonetint.sentiment_visualizer import ToneTint
# Initialize the visualizer
visualizer = ToneTint()
# Your input text
text = "I love sunny days. However, I hate the rain. The weather today is okay."
# Display the sentiment visualization in Jupyter Notebook
visualizer.display_notebook(text)
from tonetint.sentiment_visualizer import ToneTint
# Initialize the visualizer
visualizer = ToneTint()
# Your input text
text = "I love sunny days. However, I hate the rain. The weather today is okay."
# Display the sentiment visualization in a Streamlit app
visualizer.display_streamlit(text)
This code will display your text with:
Hovering over each text chunk will show a tooltip with the sentiment label and confidence score.
Customizing Highlight Colors
You can specify custom colors
for positive, negative, and neutral sentiments by passing a dictionary to the ToneTint
constructor:
custom_colors = {
"POS": "#aec867", # Green
"NEG": "#e8a56c", # Red
"NEU": "#f0e8d2", # Yellow
}
visualizer = ToneTint(colors=custom_colors)
Adjusting Chunk Size
You can adjust the chunk size (number of words per chunk) for more granular or broader analysis:
visualizer = ToneTint(chunk_size=10)
Using a Different Model
By default ToneTint uses nlptown/bert-base-multilingual-uncased-sentiment
from Huggingface.co The model performs well on most sentiment analysis tasks.
You can specify a different pre-trained model, more suited to your sentiment analysis usecase:
visualizer = ToneTint(model_name='distilbert/distilbert-base-uncased-finetuned-sst-2-english')
You can install the dependencies via pip:
pip install transformers nltk ipython torch sentencepiece
Contributions are welcome! If you have ideas for improvements or new features, feel free to open an issue or submit a pull request.
git checkout -b feature/YourFeature
).git commit -am 'Add some feature'
).git push origin feature/YourFeature
).Please ensure your code adheres to the existing style conventions and that all tests pass.
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer: This package uses pre-trained models from Hugging Face's Transformers library. The performance and accuracy of sentiment analysis depend on the chosen model. Always verify the outputs, especially when used for critical applications.
FAQs
ToneTint is a Python package that provides an intuitive way to perform sentiment analysis on text data and visualize the results. It splits the input text into manageable chunks, analyzes each chunk using a pre-trained sentiment analysis model, and highlights the text with background colors corresponding to the sentiment. Additionally, it displays tooltips with detailed sentiment scores when hovering over each text chunk.
We found that tonetint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.