Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何划分词性 #6

Open
GoogleCodeExporter opened this issue Jul 28, 2015 · 0 comments
Open

如何划分词性 #6

GoogleCodeExporter opened this issue Jul 28, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

// 贴一段我自己补充的,增加词性标注的代码。 
用户词典中指定词性暂时只想到用KV数据库反查的方案。
// 请求时加上在?w后面加上&t=1,或者是POST下带上?t=1即可

        /* 接收GET表单参数 */
        const char *httpcws_input_words = evhttp_find_header (&httpcws_http_query, "w");
        /* 是否做词性标注 */
        const char *httpcws_tagged = evhttp_find_header (&httpcws_http_query, "t");
        int tag_words = 0;
        if (httpcws_tagged != NULL) {
            tag_words = httpcws_tagged[0] == '1' ? 1 : 0;
        }

        const char *httpcws_output_tmp = NULL;
        char *httpcws_output_words = "\0";
        if (tcsql_input_postbuffer != NULL) {
            char *tcsql_input_postbuffer_tmp = (char *) malloc(EVBUFFER_LENGTH(req->input_buffer)+1);
            memset (tcsql_input_postbuffer_tmp, '\0', EVBUFFER_LENGTH(req->input_buffer)+1);
            strncpy(tcsql_input_postbuffer_tmp, tcsql_input_postbuffer, EVBUFFER_LENGTH(req->input_buffer));
            char *decode_uri = urldecode(tcsql_input_postbuffer_tmp);
            free(tcsql_input_postbuffer_tmp);
            httpcws_output_tmp = ICTCLAS_ParagraphProcess(decode_uri, tag_words);
            free(decode_uri);
            httpcws_output_words = strdup(httpcws_output_tmp);
            trim (httpcws_output_words);
        } else if (httpcws_input_words != NULL) {
            char *httpcws_input_words_tmp = strdup(httpcws_input_words);
            char *decode_uri = urldecode(httpcws_input_words_tmp);
            free(httpcws_input_words_tmp);
            httpcws_output_tmp = ICTCLAS_ParagraphProcess(decode_uri, tag_words);
            free(decode_uri);
            httpcws_output_words = strdup(httpcws_output_tmp);
            trim (httpcws_output_words);
        } else {
            httpcws_output_words = strdup("");
        }

Original issue reported on code.google.com by [email protected] on 20 Mar 2012 at 10:02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant