プリンキピア

第16章自然言語処理:応用

16.1. Sentiment Analysis and the Dataset16.1 感情分析とデータセット

With the proliferation of online social media and review platforms, a plethora of opinionated data has been logged, bearing great potential for supporting decision making processes. Sentiment analysis studies people’s sentiments in their produced text, such as product reviews, blog comments, and forum discussions. It enjoys wide applications to fields as diverse as politics (e.g., analysis of public sentiments towards policies), finance (e.g., analysis of sentiments of the market), and marketing (e.g., product research and brand management).
英語のヒント
オンラインのソーシャルメディアやレビューのプラットフォームが急増したことで、意見を含んだ大量のデータが記録されてきており、意思決定の過程を支える大きな可能性をもっている。感情分析は、製品のレビュー、ブログのコメント、フォーラムでの議論のような、人々が生み出したテキストの中の感情を研究する。感情分析は、政治(たとえば政策に対する世論の感情の分析)、金融(たとえば市場の感情の分析)、マーケティング(たとえば製品の調査やブランドの管理)のような多様な分野に幅広く応用されている。
Since sentiments can be categorized as discrete polarities or scales (e.g., positive and negative), we can consider sentiment analysis as a text classification task, which transforms a varying-length text sequence into a fixed-length text category. In this chapter, we will use Stanford’s large movie review dataset for sentiment analysis. It consists of a training set and a testing set, either containing 25000 movie reviews downloaded from IMDb. In both datasets, there are equal number of “positive” and “negative” labels, indicating different sentiment polarities.
英語のヒント
感情は離散的な極性や尺度(たとえば肯定的と否定的)に分類できるので、感情分析は、可変長のテキストの系列を固定長のテキストのカテゴリに変換するテキスト分類のタスクとみなせる。この章では、感情分析に、スタンフォードの大規模な映画レビューのデータセットを使う。これは訓練集合とテスト集合からなり、どちらもIMDbからダウンロードした25000件の映画レビューを含む。どちらのデータセットでも、異なる感情の極性を示す「positive」(肯定的)と「negative」(否定的)のラベルが同数ある。
import os
import torch
from torch import nn
from d2l import torch as d2l