private void AddFullEntry(string[] values) { string surface = values[0]; int[] costs = new int[] { Int32.Parse(values[1]), Int32.Parse(values[2]), Int32.Parse(values[3]) }; string[] features = new string[values.Length - 4]; Array.Copy(values, 4, features, 0, features.Length); UserDictionaryEntry entry = new UserDictionaryEntry(surface, costs, features); int[] wordIdAndLengths = new int[1 + 1]; // Surface and a single length - the length of surface wordIdAndLengths[0] = entries.Count; wordIdAndLengths[1] = surface.Length; entries.Add(entry); surfaces[surface] = wordIdAndLengths; }
private void AddSimpleEntry(string[] values) { string surface = values[0]; string segmentationValue = values[1]; string readingsValue = values[2]; string partOfSpeech = values[3]; string[] segmentation; string[] readings; string[] partOfSpeechs = partOfSpeech.SplitSpace(); if (isCustomSegmentation(surface, segmentationValue)) { segmentation = segmentationValue.SplitSpace(); readings = readingsValue.SplitSpace(); } else { segmentation = new string[] { segmentationValue }; readings = new string[] { readingsValue }; } if (segmentation.Length != readings.Length) { throw new Exception("User dictionary entry not properly formatted: " + values.Array2String()); } if (partOfSpeechs.Length != 1 && partOfSpeechs.Length != segmentation.Length) { throw new Exception("User dictionary partOfSpeech not properly formatted: " + values.Array2String()); } // { wordId, 1st token length, 2nd token length, ... , nth token length int[] wordIdAndLengths = new int[segmentation.Length + 1]; int wordId = entries.Count; wordIdAndLengths[0] = wordId; for (int i = 0; i < segmentation.Length; i++) { wordIdAndLengths[i + 1] = segmentation[i].Length; String[] features; if (partOfSpeechs.Length == 1) { features = MakeSimpleFeatures(partOfSpeech, readings[i]); } else { features = MakeSimpleFeatures(partOfSpeechs[i], readings[i]); } int[] costs = MakeCosts(surface.Length); UserDictionaryEntry entry = new UserDictionaryEntry( segmentation[i], costs, features ); entries.Add(entry); } surfaces[surface] = wordIdAndLengths; }
public string GetFeature(int wordId, params int[] fields) { UserDictionaryEntry entry = entries[wordId]; return(entry.GetFeature(fields)); }
public string[] GetAllFeaturesArray(int wordId) { UserDictionaryEntry entry = entries[wordId]; return(entry.GetAllFeaturesArray()); }
public int GetWordCost(int wordId) { UserDictionaryEntry entry = entries[wordId]; return(entry.GetWordCost()); }
public int GetRightId(int wordId) { UserDictionaryEntry entry = entries[wordId]; return(entry.GetRightId()); }