# Error Checking for Chinese Query by Mining Web Log

Authors: Jianyong Duan; Peng Mi; Hui Liu
Journal: Mathematical Problems in Engineering
 (2015)

---

## Abstract

For the search engine, error-input query is a common phenomenon. This paper uses web log as the training set for the query error checking. Through then-gram language model that is trained by web log, the queries are analyzed and checked. Some features including query words and their number are introduced into the model. At the same time data smoothing algorithm is used to solve data sparseness problem. It will improve the overall accuracy of the n-gram model. The experimental results show that it is effective.


---

## Body

## 1. Introduction

Recently, with the development of search engine technology, abundant web log is produced. These resources are naturally used into query error checking and correcting. The error checking is the crucial step for query correction. Chinese and English belong to different language families; their queries have differences among query length, spelling error, and so forth. The average lengths of queries are 1.85 words in Chinese as well as 2.35 words in English [1]. In English query log, there are nearly 10%~15% of queries with the spelling error. Although there are no spelling errors in Chinese queries because those characters out of Chinese characters library cannot be input, the phenomena that they are misused and confused occur frequently [2]. For example, there are some errors, as word omission and addition, reversing order in Chinese. These errors cannot be detected directly. The methods need a big vocabulary base learned from query logs for error checking. But the neologism emerging quickly is rarely provided in the base. For instance, there are 17.4% of queries out of the query vocabulary in the MSN data set. These uncollected vocabularies have greater risks of being misused in queries. The results show that it accounts nearly for 85% in the query error checking. Thus the dynamic refreshed query log is necessary for query correction [3].In this paper the query logs of SOGOU (http://www.sogou.com/) are used for the model learning and error checking. Although the log formats of different search engines are variations, they have some common data items, such as, query time, user ID, query, and page rank, as Table 1 shows.Table 1
Query log format of SOGOU.
Continued time
User ID
Query string
Page rank
Page number
URL
00:00:03
9717831746543397
奥运 (Olympics)
7
3
http://2008.olympic.cn/
00:00:03
7954902679225404
芜湖旅游 (Wuhu Tourism)
7
3
http://www.tourunion.com/spot/city/583340.htmThe web log contains abundant resources for error checking. We propose a query checking model by mining query log after it has been cleaned by wiping off its noise.


## 2. Related Work

Query error checking has received great attention these years; their models involve more complex language problems [4, 5]. Large scales of query logs and related corpus are also necessary for their model training. Many machine learning and natural language processing technologies which are very effective in textual entailment, free translation and transliteration, and sentence analysis have been introduced into query checking task [6]. In addition, some correction features are learned from these query logs [7, 8].There are two technical branches for query error checking, including statistical and rule-based methods, respectively [9, 10]. Rule-based methods use lexical analysis, shallow syntax analysis, or other lingual rules for query analysis and error checking. These methods have higher accuracy for query checking. The rules also have limitations for their usage, the query errors are various, and these rules can not apply in all cases. Thus a sufficiently large rule base for query error checking is needed. But the rule base is not easy to acquire. The statistical methods are based on a large corpus by some mathematical algorithms [11]. The frequency of query words can be trained for further use. The frequently cooccurring two words have more possibility of being the meaningful unit; in other words, they prefer to be the correct queries. Thus the interrelationship of the adjacent words is put into the statistical model for query error checking [12]. In this paper we propose the n-gram method with word segmentation information. It combines the language information into statistical model.


## 3. Query Error Checking Model

### 3.1. Data Preparing

The queries are put into the input box of search engine. They need some corrections or adjustments to meet user’s intents. When some results are returned, the best results will be clicked and also recorded in the log file. All these clues are saved as the query logs. Query log is the user’s operation record. These log records are some irregular data because users’ operating habits are different. When these logs are used as experimental materials, they must be preprocessed including removing this noise. Finally it provides favorable conditions.


### 3.2.n-Gram Model for Query Error Checking

We usen-gram training model to train the web log; the training data is used to detect whether the query is correct; if it is not correct query, then it prompts the error checking results; the specific operating process is shown in Figure 1.Figure 1
Query error checking model learning and its application.In the query error checking model, the most important thing is to calculate the frequency of cooccurrence of words in context. With the help of the prior distribution of words in context, the following word of every query can be predicted by its prior knowledge. This method can be used to check the query. For example, the query “大安门 (it is error form of ‘Tiananmen Square’; its correct Chinese form is 天安门)” is an error query that needs query error correction. The error checking method will predict the next word by corpus and choose the cue word for it. The formalization description is as shown below.Give a query strings=w1,w2,w3,…,wn; s means the query string which is composed of some words wi. We can compute the prior possibility of this query as (1)Ps=Pw1×Pw2∣w1×⋯×Pwn∣w1w2⋯wn-1=∏inPwi∣w1w2⋯wi-1,where wi represents Chinese word or character; the possibility of wi depends on its context; here context only means the words ahead of wi, which is the sequence of w1,w2,…,wi-1. When i=1, Pw1∣w0=Pw1.This model depends on context, such as the fact thatwi depends on wi-1 or more context words; it is a kind of context. With the increase of the length of context, it will lead to the parameters raising with exponential scale.If there areL training sets and the length of query strings is n, it will produce Li-1 histories for i and Ln free parameters. For example, L=6000 and i=3; the number of free parameters is nearly 216 billion; thus they are difficult to be calculated. The approximate method should be adopted into n-gram model as follows:(2)Ps=∏i=1nPwi∣wi-n+1⋯wi-1.It is a kind of Markov model for query checking;Pwi∣wi-n+1,…,wi-1 is its conditional possibility, also as Pwi∣wi-n+1i-1. Generally speaking, the longer the context window is, the more complex the computing cost is. Thus 2-gram and 3-gram models are often adopted. The Maximum Likelihood Estimation (MLE) is used to estimate the parameters of Pwi∣wi-n+1i-1 as follows:(3)Pwi∣wi-n+1i-1=fwi∣wi-n+1i-1=cwi-n+1i∑wicwi-n+1i-1,where ∑wicwi-n+1i is the frequency of query wi-n+1i with wi cooccurrence in the query log. The following 2-gram model is trained as shown in Figure 2. It is with 5,000 parameters as test set, respectively, with 700,000, 1,400,000, 2,100,000, and 2,800,000 items as the training sets for parameter estimation. Some groups of experiments are designed for parameter estimation. It shows that the larger the training set is, the more reliable the result for parameter estimation is. As the results shown in Figure 2, the label for x-axis is the number of covered parameters and the y-axis is the different training scales.Figure 2
Relation between parameter coverage and size of data set.From Figure2, we conclude that with the increasing of training scales, the coverage of parameters grows. But there are some words with probabilities of zero in the parameter estimation. We use query logs to train the n-gram model; there are 14.7% queries for trigram and 2.2% queries for bigram without occurring in the training, respectively. The data sparseness problem is triggered by the lack of the training corpus; it will be solved by the data smoothing method in Section 3.3.


### 3.3. Data Smoothing

Then-gram model needs large training corpus to estimate parameters. When these parameters sometime are not covered, their values will be initialized as zero; it decreases the performance of the algorithm. Thus the data smoothing method is introduced into our model.There are many kinds of methods for data smoothing. In the experiment, we will use the absolute discounting smoothing operation on the experimental data [13]; its idea is to lower the probability of seen words by subtracting a constant from their counts. It discounts the seen word probability by subtracting a constant. It assumes that ∑wiPwi∣w1,w2,…,wi-1=1, adjusts the balance between nonzero and zero parameters, and improves the performance of the model as follows:(4)Ps=∏i=1m+1Pwi∣wi-n+1i-1.


## 3.1. Data Preparing

The queries are put into the input box of search engine. They need some corrections or adjustments to meet user’s intents. When some results are returned, the best results will be clicked and also recorded in the log file. All these clues are saved as the query logs. Query log is the user’s operation record. These log records are some irregular data because users’ operating habits are different. When these logs are used as experimental materials, they must be preprocessed including removing this noise. Finally it provides favorable conditions.


## 3.2.n-Gram Model for Query Error Checking

We usen-gram training model to train the web log; the training data is used to detect whether the query is correct; if it is not correct query, then it prompts the error checking results; the specific operating process is shown in Figure 1.Figure 1
Query error checking model learning and its application.In the query error checking model, the most important thing is to calculate the frequency of cooccurrence of words in context. With the help of the prior distribution of words in context, the following word of every query can be predicted by its prior knowledge. This method can be used to check the query. For example, the query “大安门 (it is error form of ‘Tiananmen Square’; its correct Chinese form is 天安门)” is an error query that needs query error correction. The error checking method will predict the next word by corpus and choose the cue word for it. The formalization description is as shown below.Give a query strings=w1,w2,w3,…,wn; s means the query string which is composed of some words wi. We can compute the prior possibility of this query as (1)Ps=Pw1×Pw2∣w1×⋯×Pwn∣w1w2⋯wn-1=∏inPwi∣w1w2⋯wi-1,where wi represents Chinese word or character; the possibility of wi depends on its context; here context only means the words ahead of wi, which is the sequence of w1,w2,…,wi-1. When i=1, Pw1∣w0=Pw1.This model depends on context, such as the fact thatwi depends on wi-1 or more context words; it is a kind of context. With the increase of the length of context, it will lead to the parameters raising with exponential scale.If there areL training sets and the length of query strings is n, it will produce Li-1 histories for i and Ln free parameters. For example, L=6000 and i=3; the number of free parameters is nearly 216 billion; thus they are difficult to be calculated. The approximate method should be adopted into n-gram model as follows:(2)Ps=∏i=1nPwi∣wi-n+1⋯wi-1.It is a kind of Markov model for query checking;Pwi∣wi-n+1,…,wi-1 is its conditional possibility, also as Pwi∣wi-n+1i-1. Generally speaking, the longer the context window is, the more complex the computing cost is. Thus 2-gram and 3-gram models are often adopted. The Maximum Likelihood Estimation (MLE) is used to estimate the parameters of Pwi∣wi-n+1i-1 as follows:(3)Pwi∣wi-n+1i-1=fwi∣wi-n+1i-1=cwi-n+1i∑wicwi-n+1i-1,where ∑wicwi-n+1i is the frequency of query wi-n+1i with wi cooccurrence in the query log. The following 2-gram model is trained as shown in Figure 2. It is with 5,000 parameters as test set, respectively, with 700,000, 1,400,000, 2,100,000, and 2,800,000 items as the training sets for parameter estimation. Some groups of experiments are designed for parameter estimation. It shows that the larger the training set is, the more reliable the result for parameter estimation is. As the results shown in Figure 2, the label for x-axis is the number of covered parameters and the y-axis is the different training scales.Figure 2
Relation between parameter coverage and size of data set.From Figure2, we conclude that with the increasing of training scales, the coverage of parameters grows. But there are some words with probabilities of zero in the parameter estimation. We use query logs to train the n-gram model; there are 14.7% queries for trigram and 2.2% queries for bigram without occurring in the training, respectively. The data sparseness problem is triggered by the lack of the training corpus; it will be solved by the data smoothing method in Section 3.3.


## 3.3. Data Smoothing

Then-gram model needs large training corpus to estimate parameters. When these parameters sometime are not covered, their values will be initialized as zero; it decreases the performance of the algorithm. Thus the data smoothing method is introduced into our model.There are many kinds of methods for data smoothing. In the experiment, we will use the absolute discounting smoothing operation on the experimental data [13]; its idea is to lower the probability of seen words by subtracting a constant from their counts. It discounts the seen word probability by subtracting a constant. It assumes that ∑wiPwi∣w1,w2,…,wi-1=1, adjusts the balance between nonzero and zero parameters, and improves the performance of the model as follows:(4)Ps=∏i=1m+1Pwi∣wi-n+1i-1.


## 4. Experimental Results

### 4.1. Data Set

There are about 2,900,000 query logs and removing noise for experiment. After data cleaning, it collects about 440,000 query entries without duplication; its compression ratio is 15.3%.


### 4.2. Results

According to the proposed method, we use the query log to do the following experiment. Firstly, we choose 10 days of continuous data and label these queries by manual work. Secondly, randomly select three consecutive days’ data as the training set and extract 2,000 correct queries and 2,000 error queries, respectively; it consists of 4,000 queries as the test set. Finally segment the queries and train the bigram model with data smoothing processing because the coverage of bigram is good. Then acquire their parameters. We define the Word Cooccurring Distributes (WCD) as (5) when the number of cooccurring word is two, and the other numbers are the same ways as follows:(5)WCDwiwi+1=fwiwi+1∑ifwiwi+1.Figures3, 4, 5, and 6 are the distributions when the number of words is 2, 3, 4, and 5 in queries, respectively. For the watching convenience, we use the WCD to describe the correct queries and error queries, respectively, and give them new names as WCD_CQ for correct queries and WCD_EQ for error queries.Figure 3
Distribution for two words in queries.Figure 4
Distribution for three words in queries.Figure 5
Distribution for four words in queries.Figure 6
Distribution for five words in queries.From the above figures known, WCD_CQ is above WCD_EQ in certain level. It has relatively clear threshold between correct queries and error queries. The correct queries and error queries can be distinguished when the thresholds are kept in the certain level. Thus this threshold is very significant to distinguish right from error queries. They mean that the correct queries are more frequently used than error queries.By occasion the error queries are higher than threshold. We check these error queries and find that the error terms are frequently used in the web log. It is the usual thing for most users because they do not concern the spelling sometimes. We can establish the general table for those frequent error queries that are endowed with different threshold.Through the figures above, we also conclude that under the condition of the same number of query words, in most cases, WCD_CQ tends to be greater than WCD_EQ except the new net words occurring rapidly.Another phenomenon is that when the number of Chinese characters enlarges, their distribution decreases. Thus we get the relations between number and accuracy as in Table2.Table 2
Accuracy for correct queries and error queries by Chinese character.
Chinese character number
2
3
4
5
Accuracy of correct queries
84.97%
83.57%
68.39%
60.23%
Accuracy of error queries
89.25%
81.55%
85.57%
95.00%Here the meaning for measure is shown in Table3, accuracy of correct queries = A/(A+B), and accuracy of error queries = D/(C+D).Table 3
The confused set of measure.
Judged as right
Judged as wrong
Correct query
A
B
Error query
C
DThrough the experiments we can draw the following conclusion. The number of Chinese characters in queries has a great influence on a query. When the number increases, its effects on the thresholds will decrease and the ranges of thresholds also gradually turn narrower. It will lead to distinguishing the correct words difficultly.The results of above several group experiments are consistent with our expected effects. However, with the number increasing, the correct rate and the discrimination of this feature will drop down. It needs further investigation.Besides the number of Chinese characters and its possibility of affecting the error checking between correct and error queries, the number of Chinese word is also a kind of important feature. We analyze the correct queries and wrong queries, respectively as shown in Table4; the number of Chinese words in correct queries is longer than that in wrong queries. Thus it means that it is an important feature for query error checking.Table 4
Improved results by word between correct queries and error queries.
Word number
2
3
4
5
Correct queries
95.95%
85.92%
78.16%
71.59%
Error queries
86.02%
79.13%
84.08%
84.17%When the number of Chinese word as a feature is added into the model, the results are improved significantly. Table4 shows that the accuracy rate of correct queries increases to be higher than that of error queries. It means that this feature is effective.


## 4.1. Data Set

There are about 2,900,000 query logs and removing noise for experiment. After data cleaning, it collects about 440,000 query entries without duplication; its compression ratio is 15.3%.


## 4.2. Results

According to the proposed method, we use the query log to do the following experiment. Firstly, we choose 10 days of continuous data and label these queries by manual work. Secondly, randomly select three consecutive days’ data as the training set and extract 2,000 correct queries and 2,000 error queries, respectively; it consists of 4,000 queries as the test set. Finally segment the queries and train the bigram model with data smoothing processing because the coverage of bigram is good. Then acquire their parameters. We define the Word Cooccurring Distributes (WCD) as (5) when the number of cooccurring word is two, and the other numbers are the same ways as follows:(5)WCDwiwi+1=fwiwi+1∑ifwiwi+1.Figures3, 4, 5, and 6 are the distributions when the number of words is 2, 3, 4, and 5 in queries, respectively. For the watching convenience, we use the WCD to describe the correct queries and error queries, respectively, and give them new names as WCD_CQ for correct queries and WCD_EQ for error queries.Figure 3
Distribution for two words in queries.Figure 4
Distribution for three words in queries.Figure 5
Distribution for four words in queries.Figure 6
Distribution for five words in queries.From the above figures known, WCD_CQ is above WCD_EQ in certain level. It has relatively clear threshold between correct queries and error queries. The correct queries and error queries can be distinguished when the thresholds are kept in the certain level. Thus this threshold is very significant to distinguish right from error queries. They mean that the correct queries are more frequently used than error queries.By occasion the error queries are higher than threshold. We check these error queries and find that the error terms are frequently used in the web log. It is the usual thing for most users because they do not concern the spelling sometimes. We can establish the general table for those frequent error queries that are endowed with different threshold.Through the figures above, we also conclude that under the condition of the same number of query words, in most cases, WCD_CQ tends to be greater than WCD_EQ except the new net words occurring rapidly.Another phenomenon is that when the number of Chinese characters enlarges, their distribution decreases. Thus we get the relations between number and accuracy as in Table2.Table 2
Accuracy for correct queries and error queries by Chinese character.
Chinese character number
2
3
4
5
Accuracy of correct queries
84.97%
83.57%
68.39%
60.23%
Accuracy of error queries
89.25%
81.55%
85.57%
95.00%Here the meaning for measure is shown in Table3, accuracy of correct queries = A/(A+B), and accuracy of error queries = D/(C+D).Table 3
The confused set of measure.
Judged as right
Judged as wrong
Correct query
A
B
Error query
C
DThrough the experiments we can draw the following conclusion. The number of Chinese characters in queries has a great influence on a query. When the number increases, its effects on the thresholds will decrease and the ranges of thresholds also gradually turn narrower. It will lead to distinguishing the correct words difficultly.The results of above several group experiments are consistent with our expected effects. However, with the number increasing, the correct rate and the discrimination of this feature will drop down. It needs further investigation.Besides the number of Chinese characters and its possibility of affecting the error checking between correct and error queries, the number of Chinese word is also a kind of important feature. We analyze the correct queries and wrong queries, respectively as shown in Table4; the number of Chinese words in correct queries is longer than that in wrong queries. Thus it means that it is an important feature for query error checking.Table 4
Improved results by word between correct queries and error queries.
Word number
2
3
4
5
Correct queries
95.95%
85.92%
78.16%
71.59%
Error queries
86.02%
79.13%
84.08%
84.17%When the number of Chinese word as a feature is added into the model, the results are improved significantly. Table4 shows that the accuracy rate of correct queries increases to be higher than that of error queries. It means that this feature is effective.


## 5. Conclusion

In this paper, we propose an error checking modeln-gram model. The error checking method uses the different Chinese character number of queries as a kind of feature and gets their threshold to check the query. Then the Chinese word number of queries is introduced into the model to improve the performance. The new feature combination increases the accuracy of correct queries and the recall of error queries.Although this method achieves the anticipated effect, when the word number of queries is more 6, its performance will decrease. The following work will continue to improve the error checking method.



---

*Source: 985204-2015-10-05.xml*