• robotiumsolo

    robotium-solo-5.3.1 robotium-solo-5.3.1-javadoc 帮助文档 ExampleTestProject_Eclipse ExampleTestProject_v5.2.1

    0
    60
    1.45MB
    2017-11-29
    10
  • ASP.NET NIIT考试复习资料

    新建一个用户控件,以下陈述正确的是: 必须在第一行包含<%@Control %>指令。 必须在页面中包含<%@Control %>指令,出现在第几行没关系。 必须在第一行包含<%@ Register %>指令。 用户控件后缀名必须为 .ascx 必须在页面中包含<%@Page %>指令 A,D C,D B,D A,E 3

    0
    30
    2.82MB
    2014-04-04
    2
  • C#中文分词 .NET直接引用版

    直接把NICTCASA.DLL 添加引用 把DATA文件放入bin Debug Data目录即可 namespace Test1 { public partial class Form1 : Form { NICTCLAS nictclas; public Form1() { InitializeComponent(); try { nictclas = new NICTCLAS(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) nictclas.OperateType = eOperateType.OnlySegment; else if (radioButton2.Checked) nictclas.OperateType = eOperateType.FirstTag; else if (radioButton3.Checked) nictclas.OperateType = eOperateType.SecondTag; if (radioButton4.Checked) nictclas.OutputFormat = eOutputFormat.PKU; else if (radioButton5.Checked) nictclas.OutputFormat = eOutputFormat._973; else if (radioButton6.Checked) nictclas.OutputFormat = eOutputFormat.XML; DateTime start = DateTime.Now; string result = ""; nictclas.ParagraphProcessing(textBox1.Text,ref result); DateTime finish = DateTime.Now; TimeSpan t = (TimeSpan)(finish - start); textBox3.Text = t.TotalMilliseconds.ToString() + "ms"; textBox2.Text = result; } private void textBox1_TextChanged(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } }

    0
    193
    29.16MB
    2014-04-04
    32
  • TF-IDF C#版

    namespace Test.TFIDF { class IF_IDF { /// <summary> /// 获取拆分后的词组以及每个词的出现次数 /// </summary> /// <param name="text"></param> /// <returns></returns> public Dictionary<string, int> GetWordsFrequnce(string text) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); Regex regex = new Regex(@"[\u4e00-\u9fa5]");//分拣出中文字符 MatchCollection results = regex.Matches(text); int temp; foreach (Match word in results) { if (dictionary.TryGetValue(word.Value, out temp)) { temp++; dictionary.Remove(word.Value); dictionary.Add(word.Value, temp); } else { dictionary.Add(word.Value, 1); } } return dictionary; } /// <summary> /// 文档中出现次数最多的词的出现次数 /// </summary> /// <param name="wordsfre">拆分后的词组字典</param> /// <returns></returns> public int MaxWordFrequence( Dictionary<string, int> wordsfre) { Dictionary<string, int>.ValueCollection values = wordsfre.Values; int maxfre = 0; foreach (int value in values) { if (maxfre < value) { maxfre = value; } } return maxfre; } /// <summary> /// 计算某词的IF,返回结果 /// </summary> /// <param name="wordFre"></param> /// <param name="maxFre"></param> /// <returns></returns>

    4
    89
    2KB
    2014-04-04
    22
  • 文本相似度计算(TF-IDF)C#

    namespace ServiceRanking { /// <summary> /// Summary description for TF_IDFLib. /// </summary> public class TFIDFMeasure { private string[] _docs; private string[][] _ngramDoc; private int _numDocs=0; private int _numTerms=0; private ArrayList _terms; private int[][] _termFreq; private float[][] _termWeight; private int[] _maxTermFreq; private int[] _docFreq; public class TermVector { public static float ComputeCosineSimilarity(float[] vector1, float[] vector2) { if (vector1.Length != vector2.Length) throw new Exception("DIFER LENGTH"); float denom=(VectorLength(vector1) * VectorLength(vector2)); if (denom == 0F) return 0F; else return (InnerProduct(vector1, vector2) / denom); } public static float InnerProduct(float[] vector1, float[] vector2) { if (vector1.Length != vector2.Length) throw new Exception("DIFFER LENGTH ARE NOT ALLOWED"); float result=0F; for (int i=0; i < vector1.Length; i++) result += vector1[i] * vector2[i]; return result; } public static float VectorLength(float[] vector) { float sum=0.0F; for (int i=0; i < vector.Length; i++) sum=sum + (vector[i] * vector[i]); return (float)Math.Sqrt(sum); } } private IDictionary _wordsIndex=new Hashtable() ; public TFIDFMeasure(string[] documents) { _docs=documents; _numDocs=documents.Length ; MyInit(); } private void GeneratNgramText() { } private ArrayList GenerateTerms(string[] docs) { ArrayList uniques=new ArrayList() ; _ngramDoc=new string[_numDocs][] ; for (int i=0; i < docs.Length ; i++) { Tokeniser tokenizer=new Tokeniser() ; string[] words=tokenizer.Partition(docs[i]); for (int j=0; j < words.Length ; j++) if (!uniques.Contains(words[j]) ) uniques.Add(words[j]) ; } return uniques; } private static object AddElement(IDictionary collection, object key, object newValue) { object element=collection[key]; collection[key]=newValue; return element; } private int GetTermIndex(string term) { object index=_wordsIndex[term]; if (index == null) return -1; return (int) index; } private void MyInit() { _terms=GenerateTerms (_docs ); _numTerms=_terms.Count ; _maxTermFreq=new int[_numDocs] ; _docFreq=new int[_numTerms] ; _termFreq =new int[_numTerms][] ; _termWeight=new float[_numTerms][] ; for(int i=0; i < _terms.Count ; i++) { _termWeight[i]=new float[_numDocs] ; _termFreq[i]=new int[_numDocs] ; AddElement(_wordsIndex, _terms[i], i); } GenerateTermFrequency (); GenerateTermWeight(); } private float Log(float num) { return (float) Math.Log(num) ;//log2 } private void GenerateTermFrequency() { for(int i=0; i < _numDocs ; i++) { string curDoc=_docs[i]; IDictionary freq=GetWordFrequency(curDoc); IDictionaryEnumerator enums=freq.GetEnumerator() ; _maxTermFreq[i]=int.MinValue ; while (enums.MoveNext()) { string word=(string)enums.Key; int wordFreq=(int)enums.Value ; int termIndex=GetTermIndex(word); _termFreq [termIndex][i]=wordFreq; _docFreq[termIndex] ++; if (wordFreq > _maxTermFreq[i]) _maxTermFreq[i]=wordFreq; } } } private void GenerateTermWeight() { for(int i=0; i < _numTerms ; i++) { for(int j=0; j < _numDocs ; j++) _termWeight[i][j]=ComputeTermWeight (i, j); } } private float GetTermFrequency(int term, int doc) { int freq=_termFreq [term][doc]; int maxfreq=_maxTermFreq[doc]; return ( (float) freq/(float)maxfreq ); } private float GetInverseDocumentFrequency(int term) { int df=_docFreq[term]; return Log((float) (_numDocs) / (float) df ); } private float ComputeTermWeight(int term, int doc) { float tf=GetTermFrequency (term, doc); float idf=GetInverseDocumentFrequency(term); return tf * idf; } private float[] GetTermVector(int doc) { float[] w=new float[_numTerms] ; for (int i=0; i < _numTerms; i++) w[i]=_termWeight[i][doc]; return w; } public float GetSimilarity(int doc_i, int doc_j) { float[] vector1=GetTermVector (doc_i); float[] vector2=GetTermVector (doc_j); return TermVector.ComputeCosineSimilarity(vector1, vector2) ; } private IDictionary GetWordFrequency(string input) { string convertedInput=input.ToLower() ; Tokeniser tokenizer=new Tokeniser() ; String[] words=tokenizer.Partition(convertedInput); Array.Sort(words); String[] distinctWords=GetDistinctWords(words); IDictionary result=new Hashtable(); for (int i=0; i < distinctWords.Length; i++) { object tmp; tmp=CountWords(distinctWords[i], words); result[distinctWords[i]]=tmp; } return result; } private string[] GetDistinctWords(String[] input) { if (input == null) return new string[0]; else { ArrayList list=new ArrayList() ; for (int i=0; i < input.Length; i++) if (!list.Contains(input[i])) // N-GRAM SIMILARITY? list.Add(input[i]); return Tokeniser.ArrayListToArray(list) ; } } private int CountWords(string word, string[] words) { int itemIdx=Array.BinarySearch(words, word); if (itemIdx > 0) while (itemIdx > 0 && words[itemIdx].Equals(word)) itemIdx--; int count=0; while (itemIdx < words.Length && itemIdx >= 0) { if (words[itemIdx].Equals(word)) count++; itemIdx++; if (itemIdx < words.Length) if (!words[itemIdx].Equals(word)) break; } return count; } } }

    4
    947
    29KB
    2014-04-04
    45
上传资源赚积分or赚钱