# An Ontology-Based Recommender System with an Application to the Star Trek Television Franchise
## 2 Materials and Methods
### Item Similarity
#### 2.2.3 Ontology-Based Similarity Functions
The functions \(S_{t,s}^{\text{LCH}}\), \(S_{t,s}^{\text{RES}}\) and \(S_{t,s}^{\text{JCN}}\) produce similarity scores that can be larger than unity. To keep these measures close to the unit interval, the \(c_{i}\)'s are used to scale the scores with the values \(c_{1}=3\), \(c_{2}=10\), and \(c_{3}=2\). These functions fulfill to some extent the principle of identity by returning scores close to 1 when the entities are very similar, and scores close to 0 when they have few commonalities. As in Sections 2.2.1 and 2.2.2, our goal is to build an item similarity function from the similarity functions in Equation (7). As before, the resulting functions for the items to be recommended can be substituted in Equation (1) to produce an OBF recommender method based on ontology \(O\). In so doing, we follow the exposition of [PERSON] et al. [50], who proposed soft cardinality as a mechanism to compare pairs of sets of items represented as sets of entities making use of a similarity function for entities. Let the \(i\) be represented by a set of entities in \(O\), \(i=\{t_{1},t_{2},\cdots,t_{|i|}\}\). The soft cardinality of \(i\) is defined by the formula  
\[\left\{i\right\}=\sum_{t\in i}\left(\frac{1}{\sum_{s\in i}(S^{*}_{t,s})^{p}} \right), \tag{8}\]  
where \(S^{*}_{t,s}\) is any function in Equation (7), and \(p>0\) a softness-control parameter. The intuition underlying soft cardinality is that when the entities representing \(i\) are very similar among them, then \(\left\{i\right\}\to 1\); and when the entities are pretty much differentiated, then \(\left\{i\right\}\to\left\{i\right\}\) (i.e., the classical set cardinality). To compare a pair of items \(i\) and \(j\), it is necessary to obtain \(\left\{i\cup j\right\}\), which can be computed using Equation (8). For the intersection, it is necessary to make use of the \"soft cardinality trick\", which consists of inferring the intersection form the soft cardinalities of \(i\), \(j\) and \(i\cup j\) by the following expression:  
\[\left\{i\cap j\right\}=\left\{i\right\}+\left\{j\right\}-\left\{i\cup j\right\}. \tag{9}\]  
The \"trick\" allows soft cardinality to measure non-empty intersections when \(i\cap j\) is the empty set. For instance, using again our running example of TV episode items and thematic entities, if \(i=\) (\"journey\",\"ceremony\") and \(j=\) (\"time travel\",\"wedding ceremony\"), then \(\left|i\cap j\right|=0\) while \(\left\{i\cap j\right\}>0\) because of the non-zero similarities that can be obtained from the ontology between the elements of \(i\) and \(j\). The softness control parameter \(p\) is discussed at length in [PERSON] et al. (2015). Suffice it to say here that maximal \"softness\" is obtained in the limit as \(p\) approaches \(0^{+}\) (making \(S^{p}_{t,s}\to 1\) for any \(t\) and \(s\)), maximal \"cispness\" is obtained in the limit as \(p\) approaches \(\infty\) (making \(S^{p}_{t,s}\to 1\), if \(t=s\), and \(0\) otherwise), while setting \(p=1\) leaves the values of \(S(x,y)\) unmolested. Note that soft cardinality, \(\left\{\cdot\right\}\), generalizes the set theoretic notion of cardinality defined above to non-whole number values by exploiting pairwise similarities between entities in the calculation of item cardinality. Classical cardinality, \(\left|\cdot\right|\), by contrast, is confined to the whole numbers. The cardinality-based coefficient that we employ is the cosine index integrated with soft cardinality:  
\[s^{p}_{i,j}=\frac{\left\{i\cap j\right\}}{\sqrt{\left\{i\right\}\cdot\left\{ j\right\}}}. \tag{10}\]  
Figure 1: Primitives of the entity-similarity functions in an ontology. The function in Equation (10) is an item similarity function that can be used in Equation (1) to produce an OBF recommender. The argument \(p\) represents the entity similarity function used to build the soft cardinality operator \(\{\cdot\}\) that is one of the functions in Equation (7). Therefore, this method produces six OBF recommenders that we identify by their inner entity similarity function, namely: PATH, WUP, RES, LCH, LIN, and JCN.