コード例 #1
0
        /// <summary>Evaluates substrings that are common to all (!) of the <see cref="_listOfSelectedTableNames"/> and updates the <see cref="_commonSubstringsList">list of common substrings</see> with the result.</summary>
        private void UpdateListOfCommonSubstringsCharacterWise()
        {
            var gsa = Altaxo.Collections.Text.GeneralizedSuffixArray.FromSeparateWords(_listOfSelectedTableNames, true);
            var lcs = new Altaxo.Collections.Text.LongestCommonSubstringA(gsa)
            {
                StoreVerboseResults = true
            };

            lcs.Evaluate();
            if (lcs.MaximumNumberOfWordsWithCommonSubstring == _listOfSelectedTableNames.Count)
            {
                _commonSubstringsList = new SelectableListNodeList();
                foreach (var pos in lcs.GetSubstringPositionsCommonToTheNumberOfWords(_listOfSelectedTableNames.Count))
                {
                    var first        = pos.FirstPosition;
                    var commonString = _listOfSelectedTableNames[first.WordIndex].Substring(first.Start, first.Count);
                    _commonSubstringsList.Add(new SelectableListNode(commonString, pos, false));
                }
                _commonSubstringsList[0].IsSelected = true;
            }
        }
コード例 #2
0
        /// <summary>Searches for common substrings in the selected table names. The character entity here is not a character from a string, but a name part, as created by <see cref="SplitNameIntoParts"/>.</summary>
        private void UpdateListOfCommonSubstringsSubfolderWise()
        {
            var words = new List <string[]>();

            foreach (var tableName in _listOfSelectedTableNames)
            {
                var parts = SplitNameIntoParts(tableName);
                words.Add(parts);
            }
            var gsa = Altaxo.Collections.Text.GeneralizedSuffixArray.FromSeparateWords(words, true);
            var lcs = new Altaxo.Collections.Text.LongestCommonSubstringA(gsa)
            {
                StoreVerboseResults = true
            };

            lcs.Evaluate();
            if (lcs.MaximumNumberOfWordsWithCommonSubstring == _listOfSelectedTableNames.Count)
            {
                _commonSubstringsList = new SelectableListNodeList();
                foreach (var pos in lcs.GetSubstringPositionsCommonToTheNumberOfWords(_listOfSelectedTableNames.Count))
                {
                    var first        = pos.FirstPosition;
                    var commonString = JoinPartsToName(words[first.WordIndex], first.Start, first.Count);
                    var poss         = new List <Altaxo.Collections.Text.SubstringPosition>();

                    foreach (var entry in pos) // we have to convert our positions which ar subfolderWise into character-wise positions
                    {
                        var word    = words[entry.WordIndex];
                        var toStart = JoinPartsToName(word, 0, entry.Start);
                        poss.Add(new Collections.Text.SubstringPosition(entry.WordIndex, toStart.Length, commonString.Length));
                    }
                    _commonSubstringsList.Add(new SelectableListNode(commonString, poss, false));
                }
                _commonSubstringsList[0].IsSelected = true;
            }
        }
コード例 #3
0
		/// <summary>Searches for common substrings in the selected table names. The character entity here is not a character from a string, but a name part, as created by <see cref="SplitNameIntoParts"/>.</summary>
		private void UpdateListOfCommonSubstringsSubfolderWise()
		{
			List<string[]> words = new List<string[]>();

			foreach (var tableName in _listOfSelectedTableNames)
			{
				var parts = SplitNameIntoParts(tableName);
				words.Add(parts);
			}
			var gsa = Altaxo.Collections.Text.GeneralizedSuffixArray.FromSeparateWords(words, true);
			var lcs = new Altaxo.Collections.Text.LongestCommonSubstringA(gsa) { StoreVerboseResults = true };
			lcs.Evaluate();
			if (lcs.MaximumNumberOfWordsWithCommonSubstring == _listOfSelectedTableNames.Count)
			{
				_commonSubstringsList = new SelectableListNodeList();
				foreach (var pos in lcs.GetSubstringPositionsCommonToTheNumberOfWords(_listOfSelectedTableNames.Count))
				{
					var first = pos.FirstPosition;
					var commonString = JoinPartsToName(words[first.WordIndex], first.Start, first.Count);
					var poss = new List<Altaxo.Collections.Text.SubstringPosition>();

					foreach (var entry in pos) // we have to convert our positions which ar subfolderWise into character-wise positions
					{
						var word = words[entry.WordIndex];
						var toStart = JoinPartsToName(word, 0, entry.Start);
						poss.Add(new Collections.Text.SubstringPosition(entry.WordIndex, toStart.Length, commonString.Length));
					}
					_commonSubstringsList.Add(new SelectableListNode(commonString, poss, false));
				}
				_commonSubstringsList[0].IsSelected = true;
			}
		}
コード例 #4
0
		/// <summary>Evaluates substrings that are common to all (!) of the <see cref="_listOfSelectedTableNames"/> and updates the <see cref="_commonSubstringsList">list of common substrings</see> with the result.</summary>
		private void UpdateListOfCommonSubstringsCharacterWise()
		{
			var gsa = Altaxo.Collections.Text.GeneralizedSuffixArray.FromSeparateWords(_listOfSelectedTableNames, true);
			var lcs = new Altaxo.Collections.Text.LongestCommonSubstringA(gsa) { StoreVerboseResults = true };
			lcs.Evaluate();
			if (lcs.MaximumNumberOfWordsWithCommonSubstring == _listOfSelectedTableNames.Count)
			{
				_commonSubstringsList = new SelectableListNodeList();
				foreach (var pos in lcs.GetSubstringPositionsCommonToTheNumberOfWords(_listOfSelectedTableNames.Count))
				{
					var first = pos.FirstPosition;
					var commonString = _listOfSelectedTableNames[first.WordIndex].Substring(first.Start, first.Count);
					_commonSubstringsList.Add(new SelectableListNode(commonString, pos, false));
				}
				_commonSubstringsList[0].IsSelected = true;
			}
		}