发布ICTCLAS分词模块的WebService

  • getSegWords
    功能说明:此函数可将汉语的一句话切分成词语。
    参数说明:style=0时不显示词性,style=1时显示词性;sentence为被切分的句子
  • 地址如下:
    http://it.ccnu.edu.cn/fenciWs/fc.asmx
  • 源码:

     1using System;
    2using System.Collections;
    3using System.ComponentModel;
    4using System.Data;
    5using System.Diagnostics;
    6using System.Web;
    7using System.Web.Services;
    8using dotICTCLAS;
    9using System.Text;
    10namespace fenciWS
    11{
    12    /// <summary>
    13    /// fc 的摘要说明。
    14    /// </summary>

    15 [WebService(Namespace="http://it.ccnu.edu.cn/fenciWS")]
    16    public class fc : System.Web.Services.WebService
    17    {
    18        private static object lockob=new object();
    19       
    20        public fc()
    21        {
    22            //CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
    23            InitializeComponent();
    24        }

    25
    26        #region 组件设计器生成的代码
    27       
    28        //Web 服务设计器所必需的
    29        private IContainer components = null;
    30               
    31        /// <summary>
    32        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    33        /// 此方法的内容。
    34        /// </summary>

    35        private void InitializeComponent()
    36        {
    37        }

    38
    39        /// <summary>
    40        /// 清理所有正在使用的资源。
    41        /// </summary>

    42        protected override void Dispose( bool disposing )
    43        {
    44            if(disposing && components != null)
    45            {
    46 components.Dispose(); 47            }

    48            base.Dispose(disposing);       
    49        }

    50       
    51        #endregion

    52
    53
    54        [WebMethod(Description="功能说明:此函数可将汉语的一句话切分成词语。<br>参数说明:style=0时不显示词性,style=1时显示词性;sentence为被切分的句子",EnableSession=false)]
    55        public string getSegWords(int style,string sentence)
    56        {
    57            try
    58            {
    59                if(sentence==null || sentence=="")return "参数不完整";
    60                if(style!=0 && style!=1)return "style参数有误,只能为0或1";
    61           
    62                StringBuilder sb=new StringBuilder(50000,50000);
    63                lock(lockob)
    64                {
    65                    CICTCLAS.Init();
    66                    CICTCLAS.SetOperType(style);
    67                    CICTCLAS.ParagraphProcess(sentence,sb);
    68                    CICTCLAS.Exit();
    69                }

    70                return sb.ToString();
    71            }

    72            catch
    73            {
    74                return "服务在执行过程中出现了内部错误";
    75            }

    76        }

    77    }

    78}

    79

     

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值