本文整理汇总了C#中DataService.GetDoc方法的典型用法代码示例。如果您正苦于以下问题:C# DataService.GetDoc方法的具体用法?C# DataService.GetDoc怎么用?C# DataService.GetDoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataService
的用法示例。
在下文中一共展示了DataService.GetDoc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetrieveDocuments
static void RetrieveDocuments(string sourceUrl, string lbl, string corpusFileOut, string cacheFileOut, string timeStart, string timeEnd)
{
Debug.Assert(!lbl.Contains("\t"));
StreamWriter corpus = new StreamWriter(corpusFileOut, /*append=*/Utils.VerifyFileNameOpen(corpusFileOut), Encoding.UTF8);
StreamWriter cache = new StreamWriter(cacheFileOut, /*append=*/Utils.VerifyFileNameOpen(cacheFileOut));
DataService service = new DataService();
Console.WriteLine("Retrieving document references ...");
string[][] docRefs = service.GetDocRefs(sourceUrl, timeStart, timeEnd);
int i = 0;
foreach (string[] row in docRefs)
{
string time = row[0];
string corpusId = row[1];
string docId = row[2];
i++;
string cacheKey = corpusId + "\t" + docId + "\t" + lbl;
if (!mCache.Contains(cacheKey))
{
Console.WriteLine("Retrieving document # {0} / {1} ...", i, docRefs.Length);
try
{
string txt = service.GetDoc(corpusId, docId, "txt", false/*ignored*/, /*changesOnly=*/false, time);
if (!txt.StartsWith("*** "))
{
txt = Utils.ToOneLine(txt, /*compact=*/true).Replace('\t', ' ');
corpus.WriteLine(lbl + "\t" + txt);
corpus.Flush();
cache.WriteLine(cacheKey);
cache.Flush();
mCache.AddRange(GenerateCacheKeys(corpusId, docId, lbl));
}
else
{
Console.WriteLine(txt); // error message from the service
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
else
{
Console.WriteLine("*** Document found in cache.");
}
}
corpus.Close();
cache.Close();
}