Пример #1
0
		protected void AddKeywordsToGraphNode(Node node, List<SentenceInfo> keywords, int depth)
		{
			if (depth < FDG_DEPTH_LIMIT)
			{
				int idx = 0;

				foreach(SentenceInfo si in keywords)
				{
					// Limit # of keywords we display.
					if (idx++ < FDG_NODE_KEYWORD_LIMIT)
					{
						Node child = new TextNode(surface, si.Keyword);
						node.AddChild(child);

						// Get all sentences indices containing this keyword:
						List<int> containingSentences = keywordSentenceMap[si.Keyword];

						// Now get the related keywords for each of those sentences.  
						List<SentenceInfo> relatedKeywords = new List<SentenceInfo>();

						containingSentences.ForEach(cs =>
							{
								// Get the unique and previously not processed keywords in the sentence.
								List<SentenceInfo> si3 = GetKeywordsInSentence(cs).Where(sik => !parsedKeywords.Contains(sik.Keyword.ToLower())).ToList();
								// TODO: sort by relevance
								si3 = si3.RemoveDuplicates((si1, si2) => si1.Keyword.ToLower() == si2.Keyword.ToLower()).ToList();
								relatedKeywords.AddRange(si3);
								parsedKeywords.AddRange(si3.Select(sik=>sik.Keyword.ToLower()));
							});

						if (relatedKeywords.Count > 0)
						{
							AddKeywordsToGraphNode(child, relatedKeywords, depth + 1);
						}
					}
					else
					{
						break;
					}
				}
			}
		}
Пример #2
0
		protected void UpdateDirectedGraph()
		{
			mDiagram.Clear();
			parsedKeywords.Clear();

			string ctrSentence =  FirstThreeWords(pageSentences[displayedSentenceIndices[0]]);
			Node node = new TextNode(surface, ctrSentence);
			((TextNode)node).Brush = surface.greenBrush;
			mDiagram.AddNode(node);

			// Get the keywords of all sentences for the current sentence or sentences containing the selected keyword.
			List<SentenceInfo> keywords = GetSentencesKeywords();
			keywords = keywords.RemoveDuplicates((si1, si2) => si1.Keyword.ToLower() == si2.Keyword.ToLower()).ToList();
			parsedKeywords.AddRange(keywords.Select(si => si.Keyword.ToLower()));
			AddKeywordsToGraphNode(node, keywords, 0);
			mDiagram.Arrange();
		}