# Fact-Checking Reasoning System for Fake Review Detection Using Answer Set Programming
## 5 Approach
### Knowledge Base
#### 5.5.2 Review Constraints and Rules  
Based on the facts from the KB, constraints and rules satisfying conditions on the facts are declared such that they formally encode the problem that needs to be solved. In our scenario, the problem we want to solve can be stated like this: _Given some facts about reviews on movies, we want to detect fake and genuine reviews and identify candidates for spam reviews._  
In our case, a set of illustrating constraints and rules (see Listing 2) has been declared, which state the following:  
1. Each review can be assigned as highly, moderately, or normal regarding the review polarity. A review will be of _highPolarityDiff_ if the difference between the sentiment score and the star rating of the review is greater or equal to 3.
2. Analogously to the previous rule, _moderatePolarityDiff_ checks if the difference between the sentiment score and the star rating of the review is greater or equal to 1 and is not believed to be of _highPolarityDiff_.
3. Analogously to the previous two rules, _normalPolarityDiff_ checks if the difference between the sentiment score and the star rating of the review is not believed to be of _highPolarityDiff_ and _moderatePolarityDiff_.
4. A review is considered as a unique review (_spamByLCS_) if the Levenshtein/Cosine similarity scores are higher in the number of lower deviating reviews than high deviating reviews.
5. The given rule states that, if any two different reviews of a certain movie have an identical source, IP address, and both reviews were written within a short time interval (e.g., 30 s, i.e., \(|z_{2}-z_{1}|<30\) s), it has to be derived and concluded that both reviews are spam candidates.
6. The given rule checks if the review can be concluded to be a genuine review if the review is not a spam candidate by the _spamByCS_ rule, not spam by timestamp, and neither high nor moderate polar (see _genuineReview_).
7. The given rule checks if the review can be concluded to be a possibly genuine review if all previous rules match. However, the review is considered to be of moderate polarity (see _possiblyGenuineReview_).
8. The given rule checks if the review can be concluded to be a possibly fake review if the review is considered to be spam by the Levenshtein Cosine similarity measure, spam by timestamp, and a moderately polar review (see _possiblyFakeReview_).  
The given rule checks if the review can be concluded to be a fake review if the review is considered to be spam by the Levenshtein Cosine similarity measure, spam by timestamp, and a highly polar review. (see _fakeReview_).
10. If the review is not believed to be of any of the previous classifications, it is considered to be a contradicted review (see _contradictedReview_).  
#1: highPolarityDiff(X) :- review(X), stars(X, S1), sentScore(X, S2), |S1 - S2| >= 3.  
#2: moderatePolarityDiff(X) :- review(X), stars(X, S1), sentScore(X, S2), |S1 - S2| > 1, not highPolarityDiff(X).  
#3: normalPolarity(X) :- review(X), not highPolarityDiff(X), not moderatePolarityDiff(X).  
#4: spamByLCS(X) :- review(X), revCS(X, Y, K), Y > K.  
#5: spamByTimestamp(X;Y) :- hasRev(M1,X), hasRev(M2,Y), M1=M2, X!=Y, hasIP(X,I1), hasIP(Y,I2), I1=I2, review(X), timestamp_of_Review(X,Z1), review(Y), timestamp_of_Review(Y,Z2), |Z2-Z1|<time_interval.  
#6: genuineRev(X) :- review(X), not spamByLCS(X), not spamByTimestamp(X), not highPolarityDiff(X), not moderatePolarityDiff(X).  
#7: possiblyGenuineRev(X) :- review(X), not spamByCS(X), not spamByTimestamp(X), not highPolarityDiff(X).  
#8: possiblyFakeRev(X) :- review(X), spamByCS(X), spamByTimestamp(X), moderatePolarityDiff(X).  
#9: fakeRev(X) :- review(X), spamByLCS(X), spamByTimestamp(X), highPolarityDiff(X).  
#10: contradicatedRev(X) :- review(X), not fakeRev(X), not possiblyFakeRev(X), not genuineRev(X), not possiblyGenuineRev(X).