• 大小: 72KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: C#
  • 标签: 分词  FMM  BMM  

资源简介

用C#开发的基于正向和逆向最大匹配的分词程序。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace BMM_WordDivise
{
    class BMM : DiviseStrategy
    {
        public override string Segment(String sentence Dictionary dictionary)
        {
            int maxLength = dictionary.getMaxLength(); //the length of the longest word in the dictionary
            int negPos = sentence.Length;
            int targetLength = maxLength;
            int restLength = sentence.Length;
            //ArrayList seged = new ArrayList();
            string txtSentence = ““;

            while (restLength > 0)
            {
                if (targetLength > restLength)
                    targetLength = restLength;
                String tempStr = sentence.Substring(negPos - targetLength targetLength);
                if (dictionary.checkWord(tempStr) || targetLength == 1)
                {
                    if (tempStr == “ “ || tempStr == “ “) 
                    {
                        txtSentence = tempStr + txtSentence;
                    }
                    else
                    {
                        txtSentence = tempStr + “/“ + txtSentence;
                    }
                    //seged.Add(tempStr);
                    negPos -= targetLength;
                    restLength -= targetLength;
                    targetLength = maxLength;
                }
                else
                {
                    targetLength--;
                }
            }
            //return seged;
            return txtSentence;
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      17408  2012-05-03 17:41  FMM&BMM_WordDivise\BMM_WordDivise.exe

    ..A..H.     25600  2012-05-03 17:44  FMM&BMM_WordDivise\BMM_WordDivise.suo

     文件      17408  2012-05-03 17:41  FMM&BMM_WordDivise\code\BMM_WordDivise\bin\Debug\BMM_WordDivise.exe

     文件      56832  2012-05-03 17:41  FMM&BMM_WordDivise\code\BMM_WordDivise\bin\Debug\BMM_WordDivise.pdb

     文件      14328  2012-05-03 17:43  FMM&BMM_WordDivise\code\BMM_WordDivise\bin\Debug\BMM_WordDivise.vshost.exe

     文件        490  2007-07-21 01:33  FMM&BMM_WordDivise\code\BMM_WordDivise\bin\Debug\BMM_WordDivise.vshost.exe.manifest

     文件       1649  2012-05-03 17:01  FMM&BMM_WordDivise\code\BMM_WordDivise\BMM.cs

     文件       4722  2012-04-19 12:31  FMM&BMM_WordDivise\code\BMM_WordDivise\BMM_WordDivise.csproj

     文件       1487  2012-05-03 17:44  FMM&BMM_WordDivise\code\BMM_WordDivise\Dictionary.cs

     文件        809  2012-04-19 11:51  FMM&BMM_WordDivise\code\BMM_WordDivise\DiviseFile.cs

     文件       2316  2012-04-18 13:48  FMM&BMM_WordDivise\code\BMM_WordDivise\DiviseFile.Designer.cs

     文件       5814  2012-04-18 13:48  FMM&BMM_WordDivise\code\BMM_WordDivise\DiviseFile.resx

     文件        537  2012-04-18 21:06  FMM&BMM_WordDivise\code\BMM_WordDivise\DiviseStrategy.cs

     文件       1993  2012-04-19 21:45  FMM&BMM_WordDivise\code\BMM_WordDivise\DiviseWindow.cs

     文件       6003  2012-04-19 11:20  FMM&BMM_WordDivise\code\BMM_WordDivise\DiviseWindow.Designer.cs

     文件       6231  2012-04-19 11:19  FMM&BMM_WordDivise\code\BMM_WordDivise\DiviseWindow.resx

     文件       1661  2012-05-03 17:37  FMM&BMM_WordDivise\code\BMM_WordDivise\FMM.cs

     文件       2214  2012-05-03 17:43  FMM&BMM_WordDivise\code\BMM_WordDivise\obj\Debug\BMM_WordDivise.csproj.FileListAbsolute.txt

     文件       1112  2012-05-03 16:26  FMM&BMM_WordDivise\code\BMM_WordDivise\obj\Debug\BMM_WordDivise.csproj.GenerateResource.Cache

     文件        180  2012-04-19 12:31  FMM&BMM_WordDivise\code\BMM_WordDivise\obj\Debug\BMM_WordDivise.DiviseWindow.resources

     文件      17408  2012-05-03 17:41  FMM&BMM_WordDivise\code\BMM_WordDivise\obj\Debug\BMM_WordDivise.exe

     文件        180  2012-04-19 12:31  FMM&BMM_WordDivise\code\BMM_WordDivise\obj\Debug\BMM_WordDivise.OpenDiviseFile.resources

     文件      56832  2012-05-03 17:41  FMM&BMM_WordDivise\code\BMM_WordDivise\obj\Debug\BMM_WordDivise.pdb

     文件        180  2012-04-19 12:31  FMM&BMM_WordDivise\code\BMM_WordDivise\obj\Debug\BMM_WordDivise.Properties.Resources.resources

     文件        180  2012-04-19 12:31  FMM&BMM_WordDivise\code\BMM_WordDivise\obj\Debug\BMM_WordDivise.WordDiviseModel.resources

     文件        505  2012-04-18 12:20  FMM&BMM_WordDivise\code\BMM_WordDivise\Program.cs

     文件       1360  2012-04-18 10:08  FMM&BMM_WordDivise\code\BMM_WordDivise\Properties\AssemblyInfo.cs

     文件       2878  2012-04-18 10:08  FMM&BMM_WordDivise\code\BMM_WordDivise\Properties\Resources.Designer.cs

     文件       5612  2012-04-18 10:08  FMM&BMM_WordDivise\code\BMM_WordDivise\Properties\Resources.resx

     文件       1099  2012-04-18 10:08  FMM&BMM_WordDivise\code\BMM_WordDivise\Properties\Settings.Designer.cs

............此处省略20个文件信息

评论

共有 条评论