本文整理汇总了C#中BinarySerializer.Close方法的典型用法代码示例。如果您正苦于以下问题:C# BinarySerializer.Close方法的具体用法?C# BinarySerializer.Close怎么用?C# BinarySerializer.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinarySerializer
的用法示例。
在下文中一共展示了BinarySerializer.Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CategorizerDemo
static CategorizerDemo()
{
string fileName = HttpContext.Current.Server.MapPath("App_Data\\model.bin");
BinarySerializer binReader = new BinarySerializer(fileName, FileMode.Open);
mBowSpace = new BowSpace(binReader);
mBowSpace.CutLowWeightsPerc = 0.2;
mCategorizer = Utils.LoadDictionary<string, IModel<string>>(binReader);
binReader.Close();
mReady = true;
}
示例2: TwitterSentimentDemo
static TwitterSentimentDemo()
{
string modelFileName = HttpContext.Current.Server.MapPath("App_Data\\AdCfy.bin");
string bowSpcFileName = HttpContext.Current.Server.MapPath("App_Data\\AdCfyBowSpc.bin");
mClassifier = new SvmBinaryClassifier<int>();
mClassifier.LoadModel(modelFileName);
BinarySerializer bs = new BinarySerializer(bowSpcFileName, FileMode.Open);
mBowSpace = new BowSpace(bs);
bs.Close();
mReady = true;
}
示例3: DocumentCategorizerComponent
static DocumentCategorizerComponent()
{
Logger.GetLogger(typeof(DocumentCategorizerComponent)).Info("CategorizerComponent", "Loading model ...");
string fileName = Utils.GetConfigValue("CategorizationModel", ".\\CategorizationModel.bin");
BinarySerializer binReader = new BinarySerializer(fileName, FileMode.Open);
mBowSpace = new BowSpace(binReader);
mBowSpace.CutLowWeightsPerc = 0.2;
mCategorizer = Utils.LoadDictionary<string, IModel<string>>(binReader);
binReader.Close();
//using (BinarySerializer writer = new BinarySerializer(@"C:\Work\AchimPipe\DocumentCategorizerModel.bin", FileMode.Create))
//{
// mBowSpace.Save(writer);
// Utils.SaveDictionary<string, IModel<string>>(mCategorizer, writer);
//}
Logger.GetLogger(typeof(DocumentCategorizerComponent)).Info("CategorizerComponent", "Done.");
}
示例4: Main
static void Main(string[] args)
{
LanguageDetector langDet = LanguageDetector.GetLanguageDetectorPrebuilt();
//LanguageDetector langDet = new LanguageDetector();
//langDet.ReadCorpus(@"C:\Users\mIHA\Desktop\langdet");
LanguageProfile p = langDet.FindMatchingLanguage("To je slovenski stavek. Čeprav ga naš detektor ne zazna pravilno. Mogoče šumniki pomagajo...");
Console.WriteLine(p.Language);
p = langDet.FindMatchingLanguage("I love you.");
Console.WriteLine(p.Language);
p = langDet.FindMatchingLanguage("Baš te volim.");
Console.WriteLine(p.Language);
p = langDet.FindMatchingLanguage("Je t'aime.");
Console.WriteLine(p.Language);
foreach (LanguageProfile pr in langDet.LanguageProfiles)
{
BinarySerializer ser = new BinarySerializer(string.Format(@"C:\Users\mIHA\Desktop\langdet\{0}.ldp", pr.Language), FileMode.Create);
pr.Save(ser);
ser.Close();
}
//Console.WriteLine(langDet.GetLanguageProfile("et"));
//StreamWriter w = new StreamWriter("c:\\krneki\\langSim.txt");
//foreach (LanguageProfile p in langDet.LanguageProfiles)
//{
// w.Write("{0}\t", p.Code);
//}
//w.WriteLine();
//foreach (LanguageProfile p in langDet.LanguageProfiles)
//{
// foreach (LanguageProfile p2 in langDet.LanguageProfiles)
// {
// //w.Write("{0}\t", Math.Max(p.CalcSpearman(p2), p2.CalcSpearman(p)));
// }
// w.WriteLine();
//}
//w.Close();
}
示例5: GetLanguageDetectorPrebuilt
public static LanguageDetector GetLanguageDetectorPrebuilt()
{
LanguageDetector ld = new LanguageDetector();
Assembly assembly = Assembly.GetExecutingAssembly();
foreach (string resName in assembly.GetManifestResourceNames())
{
if (resName.EndsWith(".ldp"))
{
// load language detector profile
BinarySerializer ser = new BinarySerializer(assembly.GetManifestResourceStream(resName));
LanguageProfile langProfile = new LanguageProfile(ser);
ser.Close();
ld.AddLanguageProfile(langProfile);
mLogger.Debug("GetLanguageDetectorPrebuilt", "Loaded resource {0}.", resName);
}
}
return ld;
}