**Algorithm for extracting nontaxonomical constraints from ontology**

Algorithm for extracting nontaxonomical constraints runs as follows: given the ontology, all the related class nodes that are bound with the object properties are identified. Content constraint is initialized to the false value in the beginning. It is then changed to true value once related class nodes are obtained. The rules are then obtained with the object property as the relation between the related classes leading to the target class. The Algorithm also tests the relation between related classes and datatype properties. The related class node and the datatype property are associated using the conditions that are imposed on the ontology. This is identified by the algorithm. The content constraint value is changed to true. The rules are then generated from the relation between object property and the datatype property leading to the target class.

The PROO ontology concepts namely Opinion and Feature and the properties namely ObjectPart and ObjectPartFeature are used in generating the machine interpretable rules on target sentiment class. These articulate that they are the features to acquire positively oriented sentiment when the opinion strength on these features has a value greater than or equal to 2.5. The corresponding class hierarchies and the related classes of the PROO ontology are presented in **Figure 1**.

The sentiments of the product features that are present near to the root of the ontology are to be improved. The features located at the higher level near the root of the ontology are considered to be more important as compared with the lower level features [16]. The product features that are present near the ontology root are the parent features obtained from the taxonomical constraints and the other features present at the same level as the parent features. Other features are obtained from the non-taxonomical constraints. In order to achieve this goal, a framework is presented in **Figure 2**.

**Figure 1.** Class hierarchies and related classes in PROO.

in the ontology and the height of the ontology are the ontology tree measures. The asterisk '\*'

**1.** Retrieve the similar products from the ontology based on the user-searched product. The common features of retrieved products and the searched product are called as 'k-common

**2.** For each of the k-common features, calculate the sentiment using the count of positive

))−count(Neg(F<sup>j</sup>

)) + count(Neg(F<sup>j</sup>

,Pi ))

Sentiment-Based Semantic Rule Learning for Improved Product Recommendations

,Pi

))

) +

))

) + height of the

);

);

)) + count(Neu(F<sup>j</sup>

http://dx.doi.org/10.5772/intechopen.72514

,Pi )) 191

,Pi

,Pi

**3.** Retrieve taxonomical and non-taxonomical sentiment rules on the product features from

**4.** Map Rule\_Positive\_Sentiment = [0.001 … 1] and Rule\_Negative\_Sentiment = [−1 … −0.001].

) < Sentiment(Fjkchild\_node, Pi

) = Sentiment(Fjkparent\_node, Pi

) == Sentiment(Fjkparent\_node, Pi

) = Sentiment(Fjkparent\_node, Pi

) ^ strength(node,rel(int)) == true)

) = Sentiment(Fjknodea, Pi

in the steps represents the multiplication operator.

,Pi

if (parentof(Fjkparent\_node, Fjkchild\_node) == true)

if (Sentiment(Fjkparent\_node, Pi

Sentiment(Fjkparent\_node, Pi

New\_Sentiment(Fjkparent\_node, Pi

if (Sentiment(Fjkchild\_node, Pi

Continue;

if(Sentiment(Fjknodea, Pi

Sentiment(Fjknodea, Pi

else if (objectproperty(nodea

count(Pos(F<sup>j</sup>

Sentiment(F<sup>j</sup>

mentions and count of negative mentions on the features as:

) = count(Pos(F<sup>j</sup>

**5.** For each k-common feature among all the similar products in ontology,

) \* depth of the Fjkchild\_node];

,nodeb

) < = 0)

ontology/100; **/\*Since to have small change in the score\*/**

New\_Sentiment(Fjknodea, Pi

) = Sentiment(Fjknodea, Pi

features.'

ontology.

{

}

{

{

{

}

[Sentiment(Fjkchild\_node, Pi

**Figure 2.** Model for improving the sentiments of the product features.

The framework is composed of main component. The improvement of sentiments of the product features using the knowledge mined from the PROO ontology for improved product recommendations is shown in a diagram as under. The first two modules, i.e., the development of PROO ontology and semantic data mining the PROO ontology, were already carried out by the researchers in their work in [17]. The proposed main component of improving the sentiments of the product features using the knowledge mined from the PROO ontology for better product recommendations is described below with the algorithm pseudo-code.
