# Enhancing Short-Term Sales Prediction with Microblogs: A Case Study of the Movie Box Office
## 3 Framework of the Microblog-Based Short-Term Sales Prediction
### Sentiment Analysis
Formula (4) shows the definition of the sentiment polarity of a document, which is represented as the weighted sum of the sentiment polarity of each word in the document. \[\mathit{senti}_{m}=\sum_{n=1}^{N}\mathit{weight}_{m,n}*\mathit{senti}_{n} \tag{4}\]  
Therefore, we can say that a document has positive sentiment if its \(\mathit{senti}_{m}\) is positive. If \(\mathit{senti}_{m}\) is below zero, the document has negative sentiment. Finally, if \(\mathit{senti}_{m}\) is zero, the document contains neutral sentiment. If the microblog content contains positive emotions, the user's evaluation of the topic content described by the microblog is positive, which can actively promote real-world information such as commodities and stock prices. On the contrary, if the microblog content contains negative emotions, the evaluation held by users is negative, meaning that it has a negative impact on the information. Therefore, this paper considers the positive and negative sentiment of microblogs simultaneously and calculates the proportional difference between the positive and negative sentiment scores within one day. Such a proportional difference is then used to predict future information. Formula (5) shows the definition of the proportional difference. \[\mathit{pd}_{d}=\frac{|Count\_Positive_{d}-Count\_Negative_{d}|}{Count_{d}} \tag{5}\]  
Consequently, we present the algorithm for extracting sentiment analysis features in Algorithm 1. ```
0: The set of all the related microblogs in one day, M;
0: Sentiment Feature pd
0: \(M_{\mathit{pre}}\) is the set of the preprocessed microblogs \(T\) is the set of all the topics in the LDA Model /* Preprocessing microblogs */
1: \(M_{\mathit{pre}}\)\(\leftarrow\)\(M\)\(\mathit{a}\)\(\mathit{f}\)\(\mathit{f}\) preprocessing /* Modeling LDA */
2: \(T\), \(\mathit{p}(z_{t}|m)\), \(\mathit{p}(n|z_{t})\)\(\leftarrow\)\(\mathit{LDA}\)\(\mathit{Model}\)\(\mathit{in}\)\(M_{\mathit{pre}}\) /* Calculating topic similarity for each pair<\(t_{1}\), \(t_{2}\)>\(\mathit{in}\)\(T\) */
3: \(similarity_{z_{t_{1}},z_{t_{2}}}\)\(\leftarrow\) computed by Formula (1) /* Extracting the sentiment feature */
4: \(\mathit{poscnt}\), \(\mathit{negcnt}\), \(\mathit{totalcnt}\)\(\leftarrow\) 0
5: for each \(\mathit{prem}_{m}\) in \(M_{\mathit{pre}}\)do
6: \(\mathit{senti}_{m}\)\(\leftarrow\) 0
7: for each \(\mathit{word}_{n}\) in \(\mathit{prem}_{m}\)do
8: \(\mathit{senti}_{n}\)\(\leftarrow\) computed by Formula (3)
9: \(\mathit{weight}_{m,n}\)\(\leftarrow\) computed by Formula (2)
10: \(\mathit{senti}_{m}\)\(\leftarrow\)\(\mathit{senti}_{m}+\mathit{weight}_{m,n}*\mathit{senti}_{n}\)
11: end for
12: if\(\mathit{senti}_{m}>0\)then
13: \(\mathit{poscnt}\)\(\leftarrow\)\(\mathit{poscnt}+1\)
14: else if\(\mathit{senti}_{m}<0\)then
15: \(\mathit{negcnt}\)\(\leftarrow\)\(\mathit{negcnt}+1\)
16: end if
17: \(\mathit{totalcnt}\)\(\leftarrow\)\(\mathit{totalcnt}+1\)
18: end for
19: \(\mathit{pd}\)\(\leftarrow\)\(\frac{\mathit{poscnt}-\mathit{negcnt}}{\mathit{totalcnt}}\)
20: return pd
```  
**Algorithm 1**_Sentiment Feature Extraction_