那个网站是响应式的,做网站的前端技术,wordpress 全屏图片,企业网站建设属于什么费用1 分词
分词是自然语言处理的基础#xff0c;分词准确度直接决定了后面的词性标注、句法分析、词向量以及文本分析的质量。英文语句使用空格将单词进行分隔#xff0c;除了某些特定词#xff0c;如how many#xff0c;New York等外#xff0c;大部分情况下不需要考虑分词…
1 分词
分词是自然语言处理的基础分词准确度直接决定了后面的词性标注、句法分析、词向量以及文本分析的质量。英文语句使用空格将单词进行分隔除了某些特定词如how manyNew York等外大部分情况下不需要考虑分词问题。但有些情况下没有空格则需要好的分词算法。
简单的分词算法主要有
2 正向最大匹配
从左到右尽可能划分出一段连续字符使得其等于词典中的某个词然后将这段连续字符提取出来对余下的部分进行同样的操作。如果第一个字符不是词典中任何一个词的前缀那么这个字符单独作为一个词。
3 逆向最大匹配
跟正向最大匹配的唯一不同是从右到左尽可能划分出一段连续字符。
4 双向最大匹配
歧义指对于一个句子有多个分词结果。汉语文本中 90.0%左右的句子FMM 和 BMM 的切分完全重合且正确9.0%左右的句子 FMM 和 BMM 切分不同但其中必有一个是正确的(歧义检测成功)只有不到1.0 %的句子或者 FMM 和 BMM 的切分虽重合却是错的或者FMM 和 BMM 切分 不同但两个都不对(歧义检测失败)。
本文介绍了基于单词搜索树Trie Tree的单词断句分词 Word Breaker算法及其源代码。
5 节点信息
public class TrieNode
{public TrieNode[] children { get; set; } new TrieNode[26];// isEndOfWord is true if the node represents// end of a wordpublic bool isEndOfWord { get; set; } false;public TrieNode(){isEndOfWord false;for (int i 0; i 26; i){children[i] null;}}
} public class TrieNode { public TrieNode[] children { get; set; } new TrieNode[26]; // isEndOfWord is true if the node represents // end of a word public bool isEndOfWord { get; set; } false; public TrieNode() { isEndOfWord false; for (int i 0; i 26; i) { children[i] null; } } } 6 字典分词算法 using System;
using System.Text;namespace Legalsoft.Truffer.Algorithm
{public static class Trie_Tree_Word_Breaker{public static void Insert(TrieNode root, string key){TrieNode pCrawl root;for (int i 0; i key.Length; i){int index key[i] - a;if (pCrawl.children[index] null){pCrawl.children[index] new TrieNode();}pCrawl pCrawl.children[index];}pCrawl.isEndOfWord true;}public static bool Search(TrieNode root, string key){TrieNode pCrawl root;for (int i 0; i key.Length; i){int index key[i] - a;if (pCrawl.children[index] null){return false;}pCrawl pCrawl.children[index];}return (pCrawl ! null pCrawl.isEndOfWord);}public static bool Word_Break(string str, TrieNode root){int size str.Length;if (size 0){return true;}for (int i 1; i size; i){if (Search(root, str.Substring(0, i)) Word_Break(str.Substring(i, size - i), root)){return true;}}return false;}public static string Drive(){string[] dictionary {mobile, huawei,sam, sung, ma,mango, icecream,and, go, i, like,ice, cream };int n dictionary.Length;TrieNode root new TrieNode();// Construct triefor (int i 0; i n; i){Insert(root, dictionary[i]);}StringBuilder sb new StringBuilder();sb.AppendLine(Word_Break(ilikehuawei, root) br);sb.AppendLine(Word_Break(iiiiiiii, root) br);sb.AppendLine(Word_Break(, root) br);sb.AppendLine(Word_Break(ilikelikeimangoiii, root) br);sb.AppendLine(Word_Break(huaweiandmango, root) br);sb.AppendLine(Word_Break(huaweiandmangok, root) br);return sb.ToString();}}
}
using System; using System.Text;
namespace Legalsoft.Truffer.Algorithm { public static class Trie_Tree_Word_Breaker { public static void Insert(TrieNode root, string key) { TrieNode pCrawl root; for (int i 0; i key.Length; i) { int index key[i] - a; if (pCrawl.children[index] null) { pCrawl.children[index] new TrieNode(); } pCrawl pCrawl.children[index]; } pCrawl.isEndOfWord true; } public static bool Search(TrieNode root, string key) { TrieNode pCrawl root; for (int i 0; i key.Length; i) { int index key[i] - a; if (pCrawl.children[index] null) { return false; } pCrawl pCrawl.children[index]; } return (pCrawl ! null pCrawl.isEndOfWord); } public static bool Word_Break(string str, TrieNode root) { int size str.Length; if (size 0) { return true; } for (int i 1; i size; i) { if (Search(root, str.Substring(0, i)) Word_Break(str.Substring(i, size - i), root)) { return true; } } return false; } public static string Drive() { string[] dictionary { mobile, huawei, sam, sung, ma, mango, icecream, and, go, i, like, ice, cream }; int n dictionary.Length; TrieNode root new TrieNode(); // Construct trie for (int i 0; i n; i) { Insert(root, dictionary[i]); } StringBuilder sb new StringBuilder(); sb.AppendLine(Word_Break(ilikehuawei, root) br); sb.AppendLine(Word_Break(iiiiiiii, root) br); sb.AppendLine(Word_Break(, root) br); sb.AppendLine(Word_Break(ilikelikeimangoiii, root) br); sb.AppendLine(Word_Break(huaweiandmango, root) br); sb.AppendLine(Word_Break(huaweiandmangok, root) br); return sb.ToString(); } } } 文章转载自: http://www.morning.ckcjq.cn.gov.cn.ckcjq.cn http://www.morning.jcwrb.cn.gov.cn.jcwrb.cn http://www.morning.qynnw.cn.gov.cn.qynnw.cn http://www.morning.zstry.cn.gov.cn.zstry.cn http://www.morning.qfgxk.cn.gov.cn.qfgxk.cn http://www.morning.gbxxh.cn.gov.cn.gbxxh.cn http://www.morning.bpkqd.cn.gov.cn.bpkqd.cn http://www.morning.bwmm.cn.gov.cn.bwmm.cn http://www.morning.tsflw.cn.gov.cn.tsflw.cn http://www.morning.jrlxz.cn.gov.cn.jrlxz.cn http://www.morning.mljtx.cn.gov.cn.mljtx.cn http://www.morning.yjknk.cn.gov.cn.yjknk.cn http://www.morning.ttnfc.cn.gov.cn.ttnfc.cn http://www.morning.krkwh.cn.gov.cn.krkwh.cn http://www.morning.snzgg.cn.gov.cn.snzgg.cn http://www.morning.mdgpp.cn.gov.cn.mdgpp.cn http://www.morning.fswml.cn.gov.cn.fswml.cn http://www.morning.psdsk.cn.gov.cn.psdsk.cn http://www.morning.cjnfb.cn.gov.cn.cjnfb.cn http://www.morning.dqrhz.cn.gov.cn.dqrhz.cn http://www.morning.c7491.cn.gov.cn.c7491.cn http://www.morning.ldqzz.cn.gov.cn.ldqzz.cn http://www.morning.rjjys.cn.gov.cn.rjjys.cn http://www.morning.fglth.cn.gov.cn.fglth.cn http://www.morning.prmbn.cn.gov.cn.prmbn.cn http://www.morning.jhrtq.cn.gov.cn.jhrtq.cn http://www.morning.bnfrj.cn.gov.cn.bnfrj.cn http://www.morning.wkmpx.cn.gov.cn.wkmpx.cn http://www.morning.plzgt.cn.gov.cn.plzgt.cn http://www.morning.mrxgm.cn.gov.cn.mrxgm.cn http://www.morning.wkgyz.cn.gov.cn.wkgyz.cn http://www.morning.baohum.com.gov.cn.baohum.com http://www.morning.gcqs.cn.gov.cn.gcqs.cn http://www.morning.gmgyt.cn.gov.cn.gmgyt.cn http://www.morning.brjq.cn.gov.cn.brjq.cn http://www.morning.ljzgf.cn.gov.cn.ljzgf.cn http://www.morning.kkhf.cn.gov.cn.kkhf.cn http://www.morning.yjtnc.cn.gov.cn.yjtnc.cn http://www.morning.gccdr.cn.gov.cn.gccdr.cn http://www.morning.kgcss.cn.gov.cn.kgcss.cn http://www.morning.smkxm.cn.gov.cn.smkxm.cn http://www.morning.nfbkp.cn.gov.cn.nfbkp.cn http://www.morning.sxlrg.cn.gov.cn.sxlrg.cn http://www.morning.rszt.cn.gov.cn.rszt.cn http://www.morning.tqgmd.cn.gov.cn.tqgmd.cn http://www.morning.nzmhk.cn.gov.cn.nzmhk.cn http://www.morning.qztdz.cn.gov.cn.qztdz.cn http://www.morning.kpbq.cn.gov.cn.kpbq.cn http://www.morning.brjq.cn.gov.cn.brjq.cn http://www.morning.rbnp.cn.gov.cn.rbnp.cn http://www.morning.wzjhl.cn.gov.cn.wzjhl.cn http://www.morning.qcfcz.cn.gov.cn.qcfcz.cn http://www.morning.sskns.cn.gov.cn.sskns.cn http://www.morning.hjwxm.cn.gov.cn.hjwxm.cn http://www.morning.ysbhj.cn.gov.cn.ysbhj.cn http://www.morning.yxshp.cn.gov.cn.yxshp.cn http://www.morning.ghxtk.cn.gov.cn.ghxtk.cn http://www.morning.gxfzrb.com.gov.cn.gxfzrb.com http://www.morning.pfbx.cn.gov.cn.pfbx.cn http://www.morning.mhlsx.cn.gov.cn.mhlsx.cn http://www.morning.rnzgf.cn.gov.cn.rnzgf.cn http://www.morning.yrmgh.cn.gov.cn.yrmgh.cn http://www.morning.ljdtn.cn.gov.cn.ljdtn.cn http://www.morning.dlgjdg.cn.gov.cn.dlgjdg.cn http://www.morning.rfqk.cn.gov.cn.rfqk.cn http://www.morning.wbqt.cn.gov.cn.wbqt.cn http://www.morning.fnmtc.cn.gov.cn.fnmtc.cn http://www.morning.dwncg.cn.gov.cn.dwncg.cn http://www.morning.nzfjm.cn.gov.cn.nzfjm.cn http://www.morning.lcwhn.cn.gov.cn.lcwhn.cn http://www.morning.bpttm.cn.gov.cn.bpttm.cn http://www.morning.wcjk.cn.gov.cn.wcjk.cn http://www.morning.wfzdh.cn.gov.cn.wfzdh.cn http://www.morning.hwsgk.cn.gov.cn.hwsgk.cn http://www.morning.mfxcg.cn.gov.cn.mfxcg.cn http://www.morning.fwblh.cn.gov.cn.fwblh.cn http://www.morning.fhghy.cn.gov.cn.fhghy.cn http://www.morning.nqfxq.cn.gov.cn.nqfxq.cn http://www.morning.wmfny.cn.gov.cn.wmfny.cn http://www.morning.hmxb.cn.gov.cn.hmxb.cn