Skip to main content

sentiment analysis for dcd

Project description

SentimentAnalyzer

SentimentAnalyzer 是一个情感分析工具包,基于 T5 模型,支持多种自然语言任务。用户可以选择不同的提取模式,轻松完成情感四元组、二元组、三元组等任务。

安装

你可以通过以下命令安装 SentimentAnalyzer:

pip install dcd-sentiment-analyzer

使用方法

快速开始

首先,导入并初始化 SentimentAnalyzer 类:

from DCD_sentiment_analyser import SentimentAnalyzer

analyzer = SentimentAnalyzer() # 自动下载模型文件
# 可以传入自定义模型目录用于初始化SentimentAnalyzer类
analyzer = SentimentAnalyzer(model_dir="your_model_dir")

模式选择

SentimentAnalyzer 支持以下提取模式:

  • target_opinion_aspect_polarity (对象 | 观点 | 方面 | 极性)
  • object_opinion (对象 | 观点)
  • object_opinion_aspect (对象 | 观点 | 方面)
  • object_opinion_polarity (对象 | 观点 | 极性)
  • object_aspect_polarity (对象 | 方面 | 极性)
  • aspect_polarity (方面 | 极性)
  • opinion_polarity (观点 | 极性)
  • polarity (极性)

例子

例子1: 四元组提取

text = "个头大、口感不错,就是个别坏了的或者有烂掉口子刻意用泥土封着,这样做不好。"
result = analyzer.analyze("quadruples", text)
print(result)

例子2: 情感极性判断

text = "这真是太糟糕了。"
result = analyzer.analyze("polarity", text)
print(result)

例子3: 观点与极性提取

text = "这部电影还不错。"
result = analyzer.analyze("opinion_polarity", text)
print(result)

运行环境

  • Python 3.8+
  • PyTorch
  • Transformers

联系方式

如有任何问题,请联系 younghangx@163.com

许可证

此项目基于 MIT 许可证,详细请查看 LICENSE 文件。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dcd_sentiment_analyser-0.1.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dcd_sentiment_analyser-0.1.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file dcd_sentiment_analyser-0.1.2.tar.gz.

File metadata

  • Download URL: dcd_sentiment_analyser-0.1.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.16

File hashes

Hashes for dcd_sentiment_analyser-0.1.2.tar.gz
Algorithm Hash digest
SHA256 75ee578be49d8b26d4c2ad6740056901398644b56102b2978c915db96613bf30
MD5 9cfd4cb2a105aba42760f8a817d980f3
BLAKE2b-256 fde3a64078f8195623984f61ffb8249af4b62878f88230bd3ce4a001128a9b4a

See more details on using hashes here.

File details

Details for the file dcd_sentiment_analyser-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dcd_sentiment_analyser-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ca8b3889bf9550061d8513b73e349ba4acfce5107be1523a5b5f665da1965ff
MD5 d7a0ce28a21f53a0c3e86fa9930cb8a0
BLAKE2b-256 75731a9fdce760a695b824996b82071eb12ca12eb82c14b618cf410352235a7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page