# Innovative Application of Blockchain Technology for Digital Recipe Copyright Protection
## 4 Text Similarity Detection
### Time Complexity Analysis  
In traditional SimHash algorithms, the primary steps encompass feature extraction, feature weighting, and SimHash value construction. Notably, almost all of these steps exhibit linear time complexity. The overall time complexity of the SimHash algorithm is denoted by \(O(m\times b)\), which is determined by the hash length and the number of features, where \(m\) signifies the quantity of features in the input data, while \(b\) represents the bit length of the SimHash value. A salient distinction in time complexity between the improved model proposed in this paper and the conventional model is the inclusion of the SVM method in the former. The training time complexity of SVM, in its worst-case scenario, ranges between \(O(n^{2}\times m)\) and \(O(n^{3}\times m)\). Hence, the disparity in time complexities of the two primarily stems from the SVM's time complexity. With respect to the WMF_LDA text similarity algorithm, the main components of its time complexity are as follows: vocabulary merging and filtering at \(O(N\times M)\), WMF_LDA topic modeling at \(O(K\times N\times 1000)\), and text similarity computation at \(O(K\times M\times(M-1)/2)\), where \(N\) is the number of vocabularies, representing either the word count in individual documents or sentences or the unique word count across the entire dataset; \(M\) usually denotes the count of documents or sentences in the dataset; and \(K\) signifies the number of topics, typically indicating the number of topics to be extracted from the data in topic modeling. From a macroscopic perspective, even though traditional SimHash boasts an approximate linear time complexity, granting it superior performance in large-scale text data retrieval, its accuracy is not always on par with other sophisticated models. The p-SimHash \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Algorithm** & **Dataset Size** & **Number of Similar Data** & **FN** & **FP** \\ \hline VSM & 600 & 300 & 33 & 48 \\ \hline SimHash & 600 & 300 & 32 & 57 \\ \hline Pretrained word model & 600 & 300 & 31 & 43 \\ \hline P-SimHash & 600 & 300 & 18 & 29 \\ \hline WMF-LDA & 600 & 300 & 30 & 15 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Experimental comparison results of the Chinese dataset. Figure 9: Cluster diagram of comparative experiment on the Chinese dataset. retains the efficiency of SimHash, but by integrating concepts from machine learning and graph networks, it significantly enhances its accuracy. Nevertheless, the introduction of a machine learning model implies an addition in time complexity for p-SimHash, specifically the time complexity of SVM. In contrast, while WMF-LDA offers profound insights into text similarity modeling, its computational overhead, especially with an increasing number of documents, is noticeably more demanding. In the context of large datasets, it might necessitate substantial computational resources and time. Assuming we have \(m=300\) features and a fixed-length SimHash value:  
* Feature extraction: \(O(m)=O(300)\);
* Feature weighting: \(O(m)=O(300)\);
* Constructing SimHash value: \(O(b)\), where \(b\) is the length of the SimHash value. Assuming a value of 64, then \(O(64)\);
* SVM training (in the worst case): \(O(n^{2}\times m)\). Assuming we have \(n=1000\) samples, then \(O(1000^{2}\times 300)=O(3\times 10^{8})\). The overall time complexity of P-SimHash is approximately \(O(3\times 10^{8})\). * Vocabulary amalgamation and filtering: \(O(N\times M)=O(500\times 1000)=O(5\times 10^{5})\);
* WMF_LDA topic modeling: \(O(K\times N\times 1000)=O(10\times 500\times 1000)=O(5\times 10^{6})\);
* Text similarity computation: \(O(K\times M\times(M-1)/2)=O(10\times 1000\times 999/2)=O(5\times 10^{6})\). The overall time complexity is approximately \(O(5\times 10^{6}+5\times 10^{6}+5\times 10^{5})=O(1.05\times 10^{7})\).