単語の辞書順索引索引をテキストファイル内の位置と共に作成しようとしています。テキストファイル内の文字位置を特定して保存する方法
このフォーラムのエキスパートの助けを借りて、私は辞書的にソートされた単語のインデックスを作成できます。私は今、単語の辞書編集的にソートされたインデックスの位置を保存するのに助けが必要です
これは私がこれまで持っているものです: - 次のようなデータを含むテキストファイル(sometextfile.txt): "これはサンプルテキストファイルです「
private const string filepath = @"d:\sometextfile.txt";
using (StreamReader sr = File.OpenText(filepath))
{
string input;
//dictionary to store the position of the characters in the file as long and the lexicographically sorted value as string
var parts = new Dictionary<long,string>();
while ((input = sr.ReadLine()) != null)
{
string[] words = input.Split(' ');
foreach (var word in words)
{
var sortedSubstrings =
Enumerable.Range(0, word.Length)
.Select(i => word.Substring(i))
.OrderBy(s => s);
parts.AddRange(<store the position of the character>, sortedSubstrings);
}
}
}
こんにちは、あなたがそれを好きなら、あなたは受け入れ答えとして、または有用な答えとしてそれをマークすることができ – Fraiser
...お返事をいただき、ありがとうございます。それはあなたの "感謝"本当のブーストを与える:) – BlueMonkMN