コード例 #1
0
 public string Format(Stream input)
 {
     using (MemoryStream byteOutput = ByteBufferIO.Read(input))
     {
         return(Format(byteOutput.ToArray()));
     }
 }
コード例 #2
0
        public void SetUp()
        {
            string costs = "" +
                           "3 3\n" +
                           "0 0 1\n" +
                           "0 1 2\n" +
                           "0 2 3\n" +
                           "1 0 4\n" +
                           "1 1 5\n" +
                           "1 2 6\n" +
                           "2 0 7\n" +
                           "2 1 8\n" +
                           "2 2 9\n";

            using (ConnectionCostsCompiler compiler = new ConnectionCostsCompiler())
                using (var outputStream = File.Create(costFile))
                {
                    var    bytes       = Encoding.UTF8.GetBytes(costs);
                    Stream inputStream = new MemoryStream(bytes);
                    compiler.ReadCosts(inputStream);
                    compiler.Compile(outputStream);
                }

            using (var readStream = File.OpenRead(costFile))
                using (var reader = new BinaryReader(readStream))
                {
                    int size        = reader.ReadRawInt32();
                    var costsBuffer = new MemoryStreamWrapper(ByteBufferIO.Read(readStream));
                    connectionCosts = new ConnectionCosts(size, costsBuffer);
                }
        }
コード例 #3
0
ファイル: TokenInfoBuffer.cs プロジェクト: mes51/Kuromoji.NET
 public TokenInfoBuffer(Stream input)
 {
     Buffer         = ByteBufferIO.Read(input);
     TokenInfoCount = Buffer.ReadInt32(IntBytes * 2);
     PosInfoCount   = Buffer.ReadInt32(IntBytes * 3);
     FeatureCount   = Buffer.ReadInt32(IntBytes * 4);
     EntrySize      = TokenInfoCount * ShortBytes + PosInfoCount + FeatureCount * IntBytes;
 }
コード例 #4
0
 private static ConnectionCosts Read(Stream input)
 {
     try
     {
         lock (input)
         {
             using (BinaryReader reader = new BinaryReader(input))
             {
                 int size  = reader.ReadRawInt32();
                 var costs = new MemoryStreamWrapper(ByteBufferIO.Read(reader));
                 return(new ConnectionCosts(size, costs));
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("ConnectionCosts.Read: " + ex.Message);
     }
 }
コード例 #5
0
        public TokenInfoBuffer(Stream inputStream)
        {
            try
            {
                if (buffer != null)
                {
                    buffer.Dispose();
                }

                buffer         = new MemoryStreamWrapper(ByteBufferIO.Read(inputStream));
                tokenInfoCount = GetTokenInfoCount();
                posInfoCount   = GetPosInfoCount();
                featureCount   = GetFeatureCount();
                entrySize      = GetEntrySize(tokenInfoCount, posInfoCount, featureCount);
            }
            catch (Exception ex)
            {
                throw new IOException("TokenInfoBuffer Constructor: " + ex.Message);
            }
        }
コード例 #6
0
 public StringValueMapBuffer(Stream inputStream)
 {
     buffer      = new MemoryStreamWrapper(ByteBufferIO.Read(inputStream));
     streamArray = buffer.Stream.ToArray();
     size        = buffer.ReadInt32();
 }
コード例 #7
0
 public StringValueMapBuffer(Stream input)
 {
     Buffer = ByteBufferIO.Read(input);
     Size   = Buffer.ReadInt32(0);
 }
コード例 #8
0
 public FST(Stream input) : this(ByteBufferIO.Read(input).ToArray())
 {
 }