# E-SAWM: A Semantic Analysis-Based ODF Watermarking Algorithm for Edge Cloud Scenarios
## 3 Model and Algorithm
### Dynamic Watermarking Algorithm for OFD
#### 3.2.1 Semantic Analysis Model  
In the realm of natural language processing, computers often face challenges when dealing with complex text systems. Consequently, the conversion of \"words\" into a form that computers can easily handle has emerged as a pressing concern. To tackle this challenge, word2 vec has introduced the concept of mapping \"words\" to real number vectors, known as word embedding, resulting in word vectors. The Word2 Vec model encompasses two primary variants: Skip-Gram and CBOW (Continuous Bag-of-Words). Intuitively, Skip-Gram predicts the context given an input word, whereas CBOW predicts the input word based on the context [19].  
Figure 8: Adding watermark when the application side shares externally.  
Figure 7: Adding watermark when application-side employees download data from the database.  
* Skip-Gram model In the skip-gram model, every word is associated with two d-dimensional vectors, which are utilized to calculate conditional probabilities. Specifically, for a word indexed as \(i\) in the lexicon, the two vectors are represented by \(v_{i}\in\mathbb{R}^{d}\) and \(\mathbf{u}_{i}\in\mathbb{R}^{d}\) when it functions as a central word and a contextual word, respectively. When provided with a central word (\(w_{c}\)) (indexed as \(c\) in the dictionary), the conditional probability of generating any context word (\(w_{o}\)) (indexed as \(o\) in the dictionary) can be modeled through a softmax operation on the dot product of the vectors as follows: \[P(w_{o}\mid w_{c})=\frac{\exp(u_{o}^{T}v_{c})}{\sum_{i\in\mathbb{\mathbb{\mathbb{ \mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{ \mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{                 }}}}}}}}}}} \exp(u_{i}^{T}v_{c})\] (1) where the set of word table indexes is \(V=0,1,...,|V|-1\). Given a text sequence of length \(T\), where the words at time step t are denoted as \(w^{(t)}\), assume that the context words are generated independently given any central word. For a context window (\(m\)), the likelihood function of the jump meta model is the probability of generating all context words given any central word: \[\prod_{t=1}^{T}\prod_{-m\leq j\leq n,j\
eq 0}\log P(w^{(t+j)}|w^{(t)})\] (2)
* CBOW model CBOW is a variation of the skip-word model, with the main distinction being that CBOW assumes that the central word is generated based on the surrounding contextual words within the text sequence. In CBOW, the inclusion of multiple context words is considered. To calculate the conditional probabilities, the context word vectors are averaged. Let \(v_{i}\in\mathbb{R}^{d}\) and \(\mathbf{u}_{i}\in\mathbb{R}^{d}\) represent the vectors corresponding to the context words and central words, respectively, for any word at index \(i\) in the dictionary. The conditional probability of generating a central word (\(w_{c}\)) (indexed by \(c\) in the word list) given the context words (\(w_{o1},...,w_{o}2m\)) (indexed by \(o_{1},...,o_{2}m\) in the word list) can be represented using the following equation: \[P(w_{c}|w_{o1},\ldots,w_{o2m})=\frac{\exp\Bigl{(}\frac{1}{2m}u_{c}^{T}(v_{o1 }+\ldots+v_{o2m})\Bigr{)}}{\sum_{i\in\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{ \mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{\mathbb{ \mathbb{ \mathbb{    \  
Skip-gram provides better word vectors for these words but requires more training time. Conversely, CBOW is more efficient in such cases. The choice between the models depends on specific requirements. For higher prediction accuracy and lower training efficiency, the Skip-gram model is preferred. Conversely, the CBOW model can be chosen [20].