diff --git a/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift b/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift index 67c2bef9..10cd3df2 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmAssociates.swift @@ -52,7 +52,8 @@ extension vChewing { do { strData = try String(contentsOfFile: path, encoding: .utf8).replacingOccurrences(of: "\t", with: " ") - strData.ranges(splitBy: "\n").forEach { + strData = strData.replacingOccurrences(of: "\r", with: "\n") + strData.ranges(splitBy: "\n").filter({ !$0.isEmpty }).forEach { let neta = strData[$0].split(separator: " ") if neta.count >= 2 { let theKey = String(neta[0]) diff --git a/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift b/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift index 49978808..19eb1179 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmCoreEX.swift @@ -86,7 +86,8 @@ extension vChewing { do { strData = try String(contentsOfFile: path, encoding: .utf8).replacingOccurrences(of: "\t", with: " ") - strData.ranges(splitBy: "\n").forEach { + strData = strData.replacingOccurrences(of: "\r", with: "\n") + strData.ranges(splitBy: "\n").filter({ !$0.isEmpty }).forEach { let neta = strData[$0].split(separator: " ") if neta.count >= 2, String(neta[0]).first != "#" { if !neta[0].isEmpty, !neta[1].isEmpty { diff --git a/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift b/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift index f70cb1d7..d7df5a93 100644 --- a/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift +++ b/Source/Modules/LangModelRelated/SubLMs/lmReplacements.swift @@ -52,7 +52,8 @@ extension vChewing { do { strData = try String(contentsOfFile: path, encoding: .utf8).replacingOccurrences(of: "\t", with: " ") - strData.ranges(splitBy: "\n").forEach { + strData = strData.replacingOccurrences(of: "\r", with: "\n") + strData.ranges(splitBy: "\n").filter({ !$0.isEmpty }).forEach { let neta = strData[$0].split(separator: " ") if neta.count >= 2 { let theKey = String(neta[0])