# Short Text Classification with Tolerance-Based Soft Computing Method
## 3 Materials and Methods
### Methods
The \(computeCosineDist\) function calculates the cosine distance between each test set vector and all the representative class vectors. The \(DeterminePolarity\) function chooses the representative class that is _closest_ to the test set vector and assigns the polarity of the representative to the test set vector. In the training phase, the complexity of \(computeCosineDist\) function is \(\mathcal{O}(n^{2})\). The complexity of \(generatetolerantantpairs\) function is \(\mathcal{O}(n)\). In the testing phase, the complexity of \(DeterminePolarity\) function is \(\mathcal{O}(n)\). In the _testing phase_, the cosine distance is computed for each vector in the testing set by comparing with all representative vectors obtained in the training phase. The test set vector with the lowest cosine distance value is assigned the polarity (or category) of the representative. Figure 2: Distance Matrix for TF-IDF Vectors. ```
Input :\(TV=\{TV_{1},\dots,TV_{M}\}\), // Transformer Vectors for training \(\varepsilon>0\), // Tolerance level parameter Output :\((NT,\{(R_{1},TextCat_{1}),\dots,(R_{NT},TextCat_{NT})\})\)  NT is the size of the Tolerance class set // Create a distance matrix for all training vectors based on the function defined in Equation 2 for\(p\gets 1\)to\(M\)do for\(q\gets p+1\)to\(M\)do  computeCosineDist\((TV_{p},TV_{q},Cos_{pq})\) //a. Create object pairs satisfying the tolerance relation defined in Equation 1. \(b\). Create a neighborhood of training vectors. \(c\). Generate tolerance class set \(T\) where \(TC_{i}\) is one tolerance class member induced by the tolerance relation \(d\). Determine the majority polarity element in each \(T_{i}\) \(e\). Compute representative class vectors for\(i\gets 1\)to\(M\)do for\(j\gets i+1\)to\(M\)do  ObjectPairs \(\leftarrow\) generatetolerantpairs\((\text{Cos}_{ij},\varepsilon)\); \(N_{i}\leftarrow\) createobjectneighbour\((\text{ObjectPairs},i,TV)\); // Compute the neighbourhood \(N_{i}\) of \(i^{th}\) training vector \(TV_{i}\) forall, \(o_{1},o_{2}\in N_{i}\)do if\(o_{1},o_{2}\in ObjectPairs\)then \(TC_{i}\leftarrow\{o_{2}\}\); // Include \(o_{2}\) from \(N_{i}\) into \(TC_{i}\) \(T\gets T\cup\{TC_{i}\}\); // \(T\) is set of all tolerance classes \(TextCat_{i}\leftarrow\) computeMajorityPol\((T_{i})\); // For each \(T_{i}\), determine polarity/category by majority voting \(NT\leftarrow|T|\); // Number of tolerance classes in T // End of the process of generating set \(T\) which is set of all tolerance classes. //For each tolerance class in \(T\), generate a representative class vector and its polarity/category. \(\{(R_{1},TextCat_{1}),\dots,(R_{NT},TextCat_{NT})\}\leftarrow\) GenerateClassRepresentative\((NT)\);
```  
**Algorithm 1**Training Phase: Generating class representative vectors  
```
Input :\(\varepsilon>0\), // Tolerance level parameter, \(NT\) // Size of the tolerance class set \(T\), \(TV^{\prime}=\{TV^{\prime}_{1},\dots,TV^{\prime}_{M}\}\), // transformer vectors for testing \(\{(R_{1},TextCat_{1}),\dots,(R_{NT},TextCat_{NT})\}\) // Representative class vectors generated in the training phase and their associated polarities Output :\((TV^{\prime}=\{(TV^{\prime}_{1},TextCat_{1}),\dots,(TV^{\prime}_{M},TextCat_{ M})\})\) // Transformer vectors with assigned polarities/categories for\(i\gets 1\)to\(M\)do for\(j\gets i+1\)to\(NT\)do  computeCosineDist\((TV^{\prime}_{i},R_{j},\text{Cos}_{ij})\); \(TV^{\prime}\leftarrow\) DeterminePolarity\((Cos_{ij})\) // Computes min.