wasBayesSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 1  →  ?path2? @ 3
/BayesSharp/BayesClassifier.cs
@@ -141,8 +141,18 @@
/// <param name="json">The json content to be loaded</param>
public void ImportJsonData(string json)
{
_tags = JsonConvert.DeserializeObject<TagDictionary<TTokenType, TTagType>>(json);
_mustRecache = true;
var result = JsonConvert.DeserializeObject<TagDictionary<TTokenType, TTagType>>(json);
switch (result != null)
{
case true:
_tags = result;
_mustRecache = true;
break;
 
default:
_tags = new TagDictionary<TTokenType, TTagType>();
break;
}
}
 
/// <summary>
@@ -150,7 +160,10 @@
/// </summary>
public string ExportJsonData()
{
return JsonConvert.SerializeObject(_tags);
return _tags?.Items != null &&
_tags.Items.Any() ?
JsonConvert.SerializeObject(_tags) :
string.Empty;
}
 
/// <summary>
@@ -317,7 +330,6 @@
return probs.OrderByDescending(p => p).Take(2048);
}
 
#endregion
 
#endregion Private Methods
}
}
}