public void Search() { try { Stopwatch sw = new Stopwatch(); sw.Start(); parser = new Parse(LoadingAndSavingPath + "\\stop_words.txt", Stemming); searcher = new Searcher(this); var documentsRank = searcher.Search(QueryToSearch); queryFilesNameResults = documentsRank.Keys.ToList().Select(d => d.DocName).ToList(); QueryResults = new Dictionary <string, Dictionary <Document, double> >(); QueryResults.Add(QueryID.ToString(), documentsRank); sw.Stop(); TimeSpan ts = sw.Elapsed; string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds); // return ending message to user SearchDone($"Number of relevent documents: {documentsRank.Count} ,Search Run Time: {elapsedTime} "); } catch (Exception e) { throw e; } }
public bool Equals(QueryResultKey other) { if (other == null) { return(false); } return(QueryID.Equals(other.QueryID)); }
public int CompareTo(QueryResultKey other) { if (other == null || !QueryID.Equals(other.QueryID)) { return(-1); } return(QueryID.CompareTo(other.QueryID)); }
public override bool Equals(object obj) { QueryResultKey other = obj as QueryResultKey; if ((QueryID == null && other != null) || (QueryID != null && other == null)) { return(false); } if (QueryID == null && other.QueryID == null) { return(true); } return(QueryID.Equals(other.QueryID)); }
/// <summary> /// Кодирование заголовка запроса в формат, /// пригодный для отправки на сервер. /// </summary> /// <returns></returns> public IEnumerable <string> Encode() { string glued = _GlueCommand(); List <string> result = new List <string> { glued, Workstation.ToInvariantString(), glued, ClientID.ToInvariantString(), QueryID.ToInvariantString() }; // Документация на сервер неверно описывает формат // клиентского пакета. На самом деле он таков (для команды А): // общая длина пакета // 'A' // АРМ, например 'C' // 'A' // ID клиента, например 523444 // номер команды, для A всегда 1 // пароль // имя пользователя // пустая строка // пустая строка // пустая строка if (!string.IsNullOrEmpty(Password)) { result.Add(Password); } if (!string.IsNullOrEmpty(UserName)) { result.Add(UserName); } while (result.Count < 10) { result.Add(string.Empty); } return(result); }
public override int GetHashCode() { //Best algorithm for overriding GetHashCode(): https://stackoverflow.com/a/263416 int hash = 17; hash = hash * 23 + (string.IsNullOrEmpty(QueryID) ? string.Empty.GetHashCode() : QueryID.GetHashCode()); hash = hash * 23 + (string.IsNullOrEmpty(QueryName) ? string.Empty.GetHashCode() : QueryName.GetHashCode()); return(hash); }