Skip to content

如何划分词性 #6

@GoogleCodeExporter

Description

@GoogleCodeExporter
// 贴一段我自己补充的,增加词性标注的代码。 
用户词典中指定词性暂时只想到用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 chenggon...@gmail.com on 20 Mar 2012 at 10:02

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions