?? resultfilter.cs
字號:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using ServiceRanking;
namespace UDDI_Explorer
{
class ResultFilter
{
class CompareItem : IComparer
{
public int Compare(object x, object y)
{
float descent = ((Data)y).Weight - ((Data)x).Weight;
return Convert.ToInt32(descent * 100);
}
}
class Data
{
public TreeNode Node;
public float Weight;
}
public TreeNode[] Rank(TreeNodeCollection nodes, string query)
{
UDDIServiceList list = new UDDIServiceList();
ArrayList descList = new ArrayList();
foreach (TreeNode node in nodes)
{
UDDIService tag = node.Tag as UDDIService;
if (tag != null && tag.Descriptions != string.Empty)
{
descList.Add(tag.Descriptions + " " + node.Text);
}
else
descList.Add(node.Text);
}
descList.Add(query);
string[] docs = (string[])descList.ToArray(typeof(string));
TFIDFMeasure measure = new TFIDFMeasure(docs);
ArrayList sortedList = new ArrayList();
SyntacticSimilarity syntac = new SyntacticSimilarity();
for (int i = 0; i < docs.Length - 1; i++)
{
Data data = new Data();
data.Node = nodes[i];
float syntax = syntac.ComputeCombinedSimilarity ((string)docs[docs.Length - 1], docs[i]);
float tf_idf = measure.GetSimilarity(i, docs.Length - 1);
data.Weight = Math.Max (syntax , tf_idf) ;
sortedList.Add(data);
}
if (sortedList.Count > 1)
{
CompareItem comparer = new CompareItem();
sortedList.Sort(comparer);
}
TreeNode[] newOrder = new TreeNode[sortedList.Count];
for (int i = 0; i < sortedList.Count; i++)
{
newOrder[i] = ((Data)sortedList[i]).Node;
}
return newOrder;
}
public ResultFilter()
{
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -