Decode() public method

public Decode ( Stream stream ) : Dawg
stream Stream
return Dawg
Example #1
0
 /// <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);
     }
 }
Example #2
0
 /// <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);
     }
 }
Example #3
0
 /// <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);
     }
 }
Example #4
0
        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);
        }
Example #5
0
        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;
        }
Example #6
0
        /// <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);
        }