This commit is contained in:
owenchen committed 2026-05-29 13:03:00 +08:00
1 parent 597b88d075
commit 527205520b
12 files changed
+104 -43

No files matched your search

-3
View File
@@ -92,8 +92,6 @@ namespace CloudBuilder.Topshelf.Python
}
return null;
}
public List<HanlpConstituencyNode> GetHanlpCon(string text)
{
@@ -138,7 +136,6 @@ namespace CloudBuilder.Topshelf.Python
return null;
}
public List<string> GetTokCoarse(string text)
{
try
+5 -4
View File
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace CloudBuilder.Topshelf.Python
{
@@ -179,11 +180,11 @@ namespace CloudBuilder.Topshelf.Python
/// <param name="nodes">所有节点</param>
/// <param name="itemId">节点ID</param>
/// <returns>节点对象,如果未找到则返回null</returns>
public static HanlpConstituencyNode GetNodeTopLabelById(List<HanlpConstituencyNode> nodes, int itemId, string label)
public static HanlpConstituencyNode GetNodeTopLabelById(List<HanlpConstituencyNode> nodes, int itemId, string[] label)
{
HanlpConstituencyNode nd = GetNodeFatherById(nodes, itemId);
if (label == nd.Label && nd.Children > 0) return nd;
if (label.Where(x => x == nd.Label).Any() && nd.Children > 0) return nd;
while (nd.FatherId > 0)
{
@@ -199,9 +200,9 @@ namespace CloudBuilder.Topshelf.Python
/// <param name="nodes">所有节点</param>
/// <param name="itemId">节点ID</param>
/// <returns>节点对象,如果未找到则返回null</returns>
public static string GetNodeBottomLabelById(List<HanlpConstituencyNode> nodes, int itemId, string label)
public static string GetNodeBottomLabelById(List<HanlpConstituencyNode> nodes, int itemId, string[] label)
{
HanlpConstituencyNode[] nds = nodes?.Where(node => node.FatherId == itemId && node.Label == label && node.Children > 0).ToArray();
HanlpConstituencyNode[] nds = nodes?.Where(node => node.FatherId == itemId && label.Where(x => x == node.Label).Any() && node.Children > 0).ToArray();
if (nds == null || nds.Length == 0) return null;
HanlpConstituencyNode father;
List<string> list = new List<string>();
+2
View File
@@ -79,6 +79,8 @@ namespace CloudBuilder.Topshelf.Python
// 2. 关闭 Python 运行时(关键!)
if (PythonEngine.IsInitialized)
{
AppContext.SetSwitch("System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization", true);
PythonEngine.Shutdown(); // 销毁 Python 解释器
}