Menu

Douyin comments sentiment analysis in Python
📰

Douyin comments sentiment analysis in Python

DEV Community: nlp·Qovia·about 19 hours ago
#s55ZUgOu
#devtonlp#devto#dev#comments#douyin
Reading 0:00
15s threshold

I build Qovia, the API used in this post. The approach (fetch comments as JSON, score them locally) works with any source that gives you Douyin comments, and the scoring part is plain Python.

Douyin is the Chinese version of TikTok, and its comment sections are where people say what they think of a product, a campaign or a news item. In this tutorial we'll write a script that:

searches Douyin for a keyword and picks a video,

pages through that video's comments,

scores each comment's sentiment locally,

prints a summary, with the most-liked positive and negative comments.

Setup

You need Python 3.9+, requests and snownlp (a small Chinese-text sentiment library):

pip install requests snownlp export QOVIA_KEY = sk-qovia-... # key from the Qovia console

Enter fullscreen mode

Exit fullscreen mode

Get a key from Qovia . Requests authenticate with Authorization: Bearer <key> .

Step 1: one helper

Responses come in an envelope: the result is in data , billing info is in meta ( meta.charged_usd ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.