wasBayesSharp
/BayesSharp/BayesClassifier.cs |
@@ -141,9 +141,19 @@ |
/// <param name="json">The json content to be loaded</param> |
public void ImportJsonData(string json) |
{ |
_tags = JsonConvert.DeserializeObject<TagDictionary<TTokenType, TTagType>>(json); |
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> |
/// Export Bayes Text Classifier to a json string |
@@ -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 |
} |
} |
} |
/BayesSharp/BayesSharp.csproj |
@@ -44,7 +44,7 @@ |
</PropertyGroup> |
<ItemGroup> |
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
<HintPath>..\..\packages\Newtonsoft.Json.10.0.2\lib\net40\Newtonsoft.Json.dll</HintPath> |
<HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath> |
<Private>True</Private> |
</Reference> |
<Reference Include="System" /> |