我试图从字符串列表创建一个反向文档索引的XML,但无法将所有字符串转换为FSharpList<>并在某些迭代中获得此异常:
编辑消息:FSharp.Core.dll中出现“System.Exception”类型的第一次机会异常。该程序执行没有问题,但XML是错误的,因为所有单词都不会被访问。
我无法理解为什么它适用于某些字符串而不适用于其他字符串。
我使用此处的代码将列表转换为FSharp:http://lookingsharp.wordpress.com/2011/03/08/converting-an-ilist-to-an-fsharplist/
是因为我在foreach中创建了var fsharpList2吗?
ToFSharpList()函数将C#列表转换为F#列表。
foreach (string st in doclist)
{
list3.Clear();
split = st.Split(' ');
foreach (string str in split)
{
if (str != null)
try
{
list3.Add(Module2.stem(str.ToLower())); //using stemmer written in F#
}
catch
{
list3.Add(str.ToLower());
}
}
//foreach(string str in list3)
//richTextBox1.Text += str;
var fsharpList2 = list3.ToFSharpList(); //to convert list of stemmed distinct words to FSharpList
var perdoc_without_stopword = Module2.stopword(fsharpList2); //Using Stopword to remove stopwords in the list
foreach (string str in perdoc_without_stopword)
all_processes_words.Add(str);
all_processes_words.Count();
var list5 = WordFrequencyUtils.CountWordFrequencies(perdoc_without_stopword); //Calculating word frequencies }
编辑调试输出(最后一行不断重复):
'Amazon.ECS.SampleApp.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users \sid\Desktop\AmazonProductAdvertisingAPI\Amazon.ECS.SampleApp\bin\Debug\stopstem.dll', Symbols loaded.
'Amazon.ECS.SampleApp.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users \sid\Desktop\AmazonProductAdvertisingAPI\Amazon.ECS.SampleApp\bin\Debug\Library1.dll', Symbols loaded.
A first chance exception of type 'System.Exception' occurred in FSharp.Core.dll
A first chance exception of type 'System.Exception' occurred in FSharp.Core.dll
A first chance exception of type 'System.Exception' occurred in FSharp.Core.dll
A first chance exception of type 'System.Exception' occurred in FSharp.Core.dll
A first chance exception of type 'System.Exception' occurred in FSharp.Core.dll