Exemplo n.º 1
0
		/// <summary>
		/// Create the sentence-keyword map (list of keywords in each sentence.)
		/// Create the keyword-sentence map (list of sentence indices for each keyword.)
		/// </summary>
		/// <param name="dvKeywords"></param>
		protected void CreateSentenceKeywordMaps(DataView dvKeywords)
		{
			sentenceKeywordMap.Clear();
			keywordSentenceMap.Clear();

			// For each sentence, get all the keywords in that sentence.
			pageSentences.ForEachWithIndex((s, idx) =>
				{
					List<string> keywordsInSentence = new List<string>();
					sentenceKeywordMap[idx] = keywordsInSentence;
					string sl = s.ToLower();

					// For each of the returned keywords in the view...
					dvKeywords.ForEach(row =>
						{
							string keyword = row[0].ToString();

							if (sl.Contains(keyword.ToLower()))
							{
								// Add keyword to sentence-keyword map.
								keywordsInSentence.Add(keyword);

								// Add sentence to keyword-sentence map.
								List<int> sentences;

								if (!keywordSentenceMap.TryGetValue(keyword, out sentences))
								{
									// No entry for this keyword yet, so create the sentence indices list.
									sentences = new List<int>();
									keywordSentenceMap[keyword] = sentences;
								}

								sentences.AddIfUnique(idx);
							}
						});
				});
		}
Exemplo n.º 2
0
		protected void CreateKeywordRelevanceMap(DataView dvKeywords)
		{
			minRelevance = 1;
			maxRelevance = 0;

			keywordRelevanceMap.Clear();

			dvKeywords.ForEach(row =>
				{
					double relevance = Convert.ToDouble(row[1].ToString());
					keywordRelevanceMap[row[0].ToString()] = relevance;

					(relevance < minRelevance).Then(() => minRelevance = relevance);
					(relevance > maxRelevance).Then(() => maxRelevance = relevance);
				});
		}
Exemplo n.º 3
0
		protected void CreateSortedKeywordList(DataView dvKeywords)
		{
			keywordByRelevanceList.Clear();

			dvKeywords.ForEach(row =>
				{
					double relevance = Convert.ToDouble(row[1].ToString());
					keywordByRelevanceList[relevance] = row[0].ToString();
				});
		}