LMI // Rewrite documentation in Chinese.

This commit is contained in:
ShikiSuen 2022-06-18 14:45:12 +08:00
parent 6d4adea6ed
commit 2a97a6a80a
1 changed files with 25 additions and 27 deletions

View File

@ -24,9 +24,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// NOTE: We still keep some of the comments left by Zonble,
// regardless that he is not in charge of this Swift module
import Foundation
//
@ -39,27 +36,23 @@ private var lmSymbols = vChewing.LMCoreNS(
)
extension vChewing {
/// LMInstantiator is a facade for managing a set of models including
/// the input method language model, user phrases and excluded phrases.
/// LMInstantiatorLMI
/// LanguageModel 使
///
///
/// It is the primary model class that the input controller and input compositor
/// of vChewing talks to. When the input compositor starts to build a sentence
/// from a series of BPMF readings, it passes the readings to the model to see
/// if there are valid unigrams, and use returned unigrams to produce the final
/// results.
/// LMI 調
/// LMI
///
///
/// LMInstantiator combine and transform the unigrams from the primary language
/// model and user phrases. The process is
/// LMI
///
/// 1) Get the original unigrams.
/// 2) Drop the unigrams whose value is contained in the exclusion map.
/// 3) Replace the values of the unigrams using the phrase replacement map.
/// 4) Drop the duplicated phrases from the generated unigram array.
/// 1.
/// 2.
/// 3.
/// 4.
///
/// The controller can ask the model to load the primary input method language
/// model while launching and to load the user phrases anytime if the custom
/// files are modified. It does not keep the reference of the data pathes but
/// you have to pass the paths when you ask it to load.
/// LMI LMI
///
public class LMInstantiator: Megrez.LanguageModel {
//
public var isPhraseReplacementEnabled = false
@ -76,9 +69,9 @@ extension vChewing {
/// LMCoreEX 2010-2013 mac
/// LMCoreNS plist
//
/// Reverse
/// Reverse
//
// Reverse
// Reverse
var lmCore = LMCoreNS(
reverse: false, consolidate: false, defaultScore: -9.9, forceDefaultScore: false
)
@ -194,12 +187,12 @@ extension vChewing {
// MARK: - Core Functions (Public)
/// Not implemented since we do not have data to provide bigram function.
///
// public func bigramsForKeys(preceedingKey: String, key: String) -> [Megrez.Bigram] { }
/// Returns a list of available unigram for the given key.
/// @param key:String represents the BPMF reading or a symbol key.
/// For instance, it you pass "ˇ", it returns "" and other possible candidates.
/// LMI
/// - Parameter key:
/// - Returns:
override open func unigramsFor(key: String) -> [Megrez.Unigram] {
if key == " " {
///
@ -267,6 +260,11 @@ extension vChewing {
// MARK: - Core Functions (Private)
///
/// - Parameters:
/// - unigrams:
/// - filteredPairs:
/// - Returns:
func filterAndTransform(
unigrams: [Megrez.Unigram],
filter filteredPairs: Set<Megrez.KeyValuePair>