/// <summary> /// Initialize a new instance of StandardTokenizer. /// </summary> /// <param name="file">The dawg format file.</param> public StandardTokenizer(string file) { using (var stream = Utils.LoadDawgFile(file)) { var decoder = new DawgDecoder(Dawg.FILEVERSION); _dawg = decoder.Decode(stream); } }
/// <summary> /// Initialize a new instance of StandardTokenizer. /// </summary> /// <param name="file">The dawg format file.</param> public StandardTokenizer(string file) { if (!File.Exists(file)) { throw new FileNotFoundException("The file of dawg does not exist.", file); } using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) { var decoder = new DawgDecoder(Dawg.FILEVERSION); _dawg = decoder.Decode(fs); } }
public static WordDict LoadFrom(Stream input) { var decoder = new DawgDecoder(Dawg.FILEVERSION); var dawg = decoder.Decode(input); var wordUtil = new WordDict(); foreach (var pair in dawg.MatchsPrefix(null)) { wordUtil.AddInternal(pair.Key, pair.Value); } return(wordUtil); }
public static WordUtil LoadFrom(Stream input) { var decoder = new DawgDecoder(Dawg.FILEVERSION); var dawg = decoder.Decode(input); var wordUtil = new WordUtil(); foreach (var pair in dawg.MatchsPrefix(null)) { wordUtil.AddInternal(pair.Key, pair.Value); } return wordUtil; }
/// <summary> /// Initialize a new instance of StandardTokenizer. /// </summary> /// <param name="src">The stream of the dawg file.</param> public StandardTokenizer(Stream src) { var decoder = new DawgDecoder(Dawg.FILEVERSION); _dawg = decoder.Decode(src); }