//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testReadFullValue() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testReadFullValue() { Stream @is = this.GetType().ClassLoader.getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt"); sbyte[] data = new sbyte[@is.available()]; DataInputStream dataInputStream = new DataInputStream(@is); dataInputStream.readFully(data); dataInputStream.close(); MockValueFields valueFields = new MockValueFields(); string filename = "file.txt"; valueFields.TextValue = filename; valueFields.ByteArrayValue = data; string mimeType = "text/plain"; string encoding = "UTF-16"; valueFields.TextValue2 = mimeType + SEPARATOR + encoding; FileValue fileValue = serializer.readValue(valueFields, true); assertThat(fileValue.Filename, @is(filename)); assertThat(fileValue.MimeType, @is(mimeType)); assertThat(fileValue.Encoding, @is("UTF-16")); assertThat(fileValue.EncodingAsCharset, @is(Charset.forName("UTF-16"))); checkStreamFromValue(fileValue, "text"); }
private static void loadCharMap(sbyte enc) { int num = 0; for (int index = 1; index < (int)enc; ++index) { if (((long)SDKTextUtils.s_textEncodings & (long)(1 << index)) != 0L) { ++num; } } DataInputStream dataInputStream = new DataInputStream(JavaLib.getResourceAsStream("charmap", false)); dataInputStream.skip((long)(num << 8)); for (int index = 0; index != 128; ++index) { SDKTextUtils.s_charMapISO[index] = (ushort)dataInputStream.readShort(); } dataInputStream.close(); if (SDKTextUtils.s_currentFont == null) { return; } SDKTextUtils.s_currentFont.refreshISOOffsets(); }
public void setFontData(sbyte[] data) { if (data == null) { this.m_textDirection = 0; this.m_lineDirection = 0; this.m_leading = 0; this.m_ascent = 0; this.m_descent = 0; this.m_spaceSpace = 0; this.m_charSpace = 0; this.m_numChars = 0; this.m_numGlyphs = 0; this.m_utfCodeArray = new ushort[0]; this.m_charDataOffsetArray = new ushort[0]; this.m_charData = new sbyte[0]; this.m_ISOOffsetMap = new ushort[0]; } else { DataInputStream dataInputStream1 = new DataInputStream((InputStream) new ByteArrayInputStream(data, 12)); int num = (int)dataInputStream1.readByte(); this.m_textDirection = (int)dataInputStream1.readByte(); this.m_lineDirection = (int)dataInputStream1.readByte(); this.m_leading = (int)dataInputStream1.readByte(); this.m_ascent = (int)dataInputStream1.readByte(); this.m_descent = (int)dataInputStream1.readByte(); this.m_spaceSpace = (int)dataInputStream1.readByte(); this.m_charSpace = (int)dataInputStream1.readByte(); this.m_numChars = (int)dataInputStream1.readShort(); this.m_numGlyphs = (int)dataInputStream1.readShort(); dataInputStream1.close(); this.m_utfCodeArray = new ushort[this.m_numChars]; this.m_charDataOffsetArray = new ushort[this.m_numChars + 1]; this.m_charData = new sbyte[2 * this.m_numChars + 6 * this.m_numGlyphs]; int bufLength = 12 + (this.m_utfCodeArray.Length + this.m_charDataOffsetArray.Length) * 2 + this.m_charData.Length; DataInputStream dataInputStream2 = new DataInputStream((InputStream) new ByteArrayInputStream(data, bufLength)); dataInputStream2.skip(12L); for (int index = 0; index != this.m_numChars; ++index) { this.m_utfCodeArray[index] = (ushort)dataInputStream2.readShort(); } for (int index = 0; index != this.m_numChars; ++index) { this.m_charDataOffsetArray[index] = (ushort)dataInputStream2.readShort(); } this.m_charDataOffsetArray[this.m_numChars] = ushort.MaxValue; for (int index = 0; index != this.m_charData.Length; ++index) { this.m_charData[index] = dataInputStream2.readByte(); } dataInputStream2.close(); this.setTransform(this.m_transform); this.m_ISOOffsetMap = new ushort[256]; for (int index = 0; index != 128; ++index) { this.m_ISOOffsetMap[index] = (ushort)SDKTextUtils.getCodePos(this.m_utfCodeArray, (ushort)index, this.m_numChars); } } }
private void loadDLCData() { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append(this.m_rootFolder); stringBuffer.append(DLCManager.pathSeparatorChar); stringBuffer.append(DLCManager.DLCDATA_FILENAME); DataInputStream dataInputStream1 = new DataInputStream(JavaLib.getResourceAsStream(stringBuffer.toString(), false)); if (dataInputStream1 == null) { this.m_packCount = 0; this.m_packSellIds = new int[0]; } else { DataInputStream dataInputStream2 = dataInputStream1; this.m_packCount = dataInputStream2.readInt(); this.m_packSellIds = new int[this.m_packCount]; for (int index = 0; index < this.m_packCount; ++index) { this.m_packSellIds[index] = dataInputStream2.readInt(); } dataInputStream2.close(); } }
public static string[] load_dna(string filename) { List<string> list = new List<string>(); string[] result = null; try { FileInputStream fstream = new FileInputStream(filename); DataInputStream @in = new DataInputStream(fstream); BufferedReader buffer = new BufferedReader(new InputStreamReader(@in)); string line; while((line = buffer.readLine()) != null) { list.Add(line); } @in.close(); result = new string[list.Count]; for (int i = 0; i < list.Count; i++) { result[i] = (string)list[i]; } } catch(java.io.IOException e) { Console.WriteLine("Unable to create matrix from " + filename + ": " + e.Message); Environment.Exit(-1); } return result; }
// Token: 0x060006E0 RID: 1760 RVA: 0x0005C1C4 File Offset: 0x0005A3C4 public static void checkRMS() { MyVector myVector = new MyVector(); sbyte[] array = Rms.loadRMS("ImageSource"); if (array == null) { Service.gI().imageSource(myVector); return; } ImageSource.vRms = new MyVector(); DataInputStream dataInputStream = new DataInputStream(array); if (dataInputStream == null) { return; } try { short num = dataInputStream.readShort(); string[] array2 = new string[(int)num]; sbyte[] array3 = new sbyte[(int)num]; for (int i = 0; i < (int)num; i++) { array2[i] = dataInputStream.readUTF(); array3[i] = dataInputStream.readByte(); ImageSource.vRms.addElement(new ImageSource(array2[i], array3[i])); } dataInputStream.close(); } catch (Exception ex) { ex.StackTrace.ToString(); } Res.outz(string.Concat(new object[] { "vS size= ", ImageSource.vSource.size(), " vRMS size= ", ImageSource.vRms.size() })); for (int j = 0; j < ImageSource.vSource.size(); j++) { ImageSource imageSource = (ImageSource)ImageSource.vSource.elementAt(j); if (!ImageSource.isExistID(imageSource.id)) { myVector.addElement(imageSource); } } for (int k = 0; k < ImageSource.vRms.size(); k++) { ImageSource imageSource2 = (ImageSource)ImageSource.vRms.elementAt(k); if ((int)ImageSource.getVersionRMSByID(imageSource2.id) != (int)ImageSource.getCurrVersionByID(imageSource2.id)) { myVector.addElement(imageSource2); } } Service.gI().imageSource(myVector); }
private void readSmearInfo(string text) { DataInputStream dataInputStream = new DataInputStream(new FileInputStream(text)); if (dataInputStream.readInt() != -1060454374) { dataInputStream.close(); string text2 = new StringBuilder().append("Bad smear format for ").append(text).toString(); throw new IOException(text2); } if (dataInputStream.readInt() != this.unigrams.Length) { dataInputStream.close(); string text3 = new StringBuilder().append("Bad unigram length in ").append(text).toString(); throw new IOException(text3); } this.bigramSmearMap = new HashMap(); this.unigramSmearTerm = new float[this.unigrams.Length]; [email protected](new StringBuilder().append("Reading ").append(this.unigrams.Length).toString()); for (int i = 0; i < this.unigrams.Length; i++) { this.unigramSmearTerm[i] = dataInputStream.readFloat(); } for (int i = 0; i < this.unigrams.Length; i++) { [email protected](new StringBuilder().append("Processed ").append(i).append(" of ").append(this.loadedBigramBuffers.Length).toString()); int num = dataInputStream.readInt(); NGramBuffer bigramBuffer = this.getBigramBuffer(i); if (bigramBuffer.getNumberNGrams() != num) { dataInputStream.close(); string text4 = new StringBuilder().append("Bad ngrams for unigram ").append(i).append(" Found ").append(num).append(" expected ").append(bigramBuffer.getNumberNGrams()).toString(); throw new IOException(text4); } for (int j = 0; j < num; j++) { int wordID = bigramBuffer.getWordID(j); this.putSmearTerm(i, wordID, dataInputStream.readFloat()); } } dataInputStream.close(); }
public static bool isCepstraFileBigEndian(string filename) { File file = new File(filename); int num = (int)file.length(); DataInputStream dataInputStream = new DataInputStream(new FileInputStream(filename)); int num2 = dataInputStream.readInt() * 4 + 4; dataInputStream.close(); return(num == num2); }
// Token: 0x06000174 RID: 372 RVA: 0x0000D7C8 File Offset: 0x0000B9C8 public mFont(string strFont, string pathImage, string pathData, int space) { try { this.strFont = strFont; this.space = space; this.pathImage = pathImage; DataInputStream dataInputStream = null; this.reloadImage(); try { dataInputStream = MyStream.readFile(pathData); this.fImages = new int[(int)dataInputStream.readShort()][]; for (int i = 0; i < this.fImages.Length; i++) { this.fImages[i] = new int[4]; this.fImages[i][0] = (int)dataInputStream.readShort(); this.fImages[i][1] = (int)dataInputStream.readShort(); this.fImages[i][2] = (int)dataInputStream.readShort(); this.fImages[i][3] = (int)dataInputStream.readShort(); this.setHeight(this.fImages[i][3]); } dataInputStream.close(); } catch (Exception ex) { try { dataInputStream.close(); } catch (Exception ex2) { ex2.StackTrace.ToString(); } } } catch (Exception ex3) { ex3.StackTrace.ToString(); } }
public static NBTTagCompound func_770_a(InputStream inputstream) { var datainputstream = new DataInputStream(new GZIPInputStream(inputstream)); try { NBTTagCompound nbttagcompound = func_774_a(datainputstream); return(nbttagcompound); } finally { datainputstream.close(); } }
protected internal virtual Pool loadTransitionMatrices(string path) { this.logger.fine(new StringBuilder().append("Loading transition matrices from: ").append(path).toString()); Properties properties = new Properties(); DataInputStream dataInputStream = this.readS3BinaryHeader(path, properties); string property = properties.getProperty("version"); if (property == null || !String.instancehelper_equals(property, "1.0")) { string text = new StringBuilder().append("Unsupported version in ").append(path).toString(); throw new IOException(text); } string property2 = properties.getProperty("chksum0"); int num = (property2 == null || !String.instancehelper_equals(property2, "yes")) ? 0 : 1; this.resetChecksum(); Pool pool = new Pool(path); int num2 = this.readInt(dataInputStream); int num3 = this.readInt(dataInputStream); int num4 = this.readInt(dataInputStream); int num5 = this.readInt(dataInputStream); if (!Sphinx3Loader.assertionsDisabled && num5 != num4 * num3 * num2) { throw new AssertionError(); } for (int i = 0; i < num2; i++) { float[][] array = new float[num4][]; array[num4 - 1] = new float[num4]; this.logMath.linearToLog(array[num4 - 1]); for (int j = 0; j < num3; j++) { array[j] = this.readFloatArray(dataInputStream, num4); Utilities.nonZeroFloor(array[j], 0f); Utilities.normalize(array[j]); this.logMath.linearToLog(array[j]); } pool.put(i, array); } this.validateChecksum(dataInputStream, num != 0); dataInputStream.close(); return(pool); }
protected internal virtual GaussianWeights loadMixtureWeights(string path, float floor) { this.logger.fine(new StringBuilder().append("Loading mixture weights from: ").append(path).toString()); Properties properties = new Properties(); DataInputStream dataInputStream = this.readS3BinaryHeader(path, properties); string property = properties.getProperty("version"); if (property == null || !String.instancehelper_equals(property, "1.0")) { string text = new StringBuilder().append("Unsupported version in ").append(path).toString(); throw new IOException(text); } string property2 = properties.getProperty("chksum0"); int num = (property2 == null || !String.instancehelper_equals(property2, "yes")) ? 0 : 1; this.resetChecksum(); int num2 = this.readInt(dataInputStream); int num3 = this.readInt(dataInputStream); int num4 = this.readInt(dataInputStream); int num5 = this.readInt(dataInputStream); GaussianWeights gaussianWeights = new GaussianWeights(path, num2, num4, num3); this.logger.fine(new StringBuilder().append("Number of states ").append(num2).toString()); this.logger.fine(new StringBuilder().append("Number of streams ").append(num3).toString()); this.logger.fine(new StringBuilder().append("Number of gaussians per state ").append(num4).toString()); if (!Sphinx3Loader.assertionsDisabled && num5 != num2 * num3 * num4) { throw new AssertionError(); } for (int i = 0; i < num2; i++) { for (int j = 0; j < num3; j++) { float[] array = this.readFloatArray(dataInputStream, num4); Utilities.normalize(array); Utilities.floorData(array, floor); this.logMath.linearToLog(array); gaussianWeights.put(i, j, array); } } this.validateChecksum(dataInputStream, num != 0); dataInputStream.close(); return(gaussianWeights); }
public static void Main(string[] args) { PrintWriter @out = new PrintWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(args[1])))); DataInputStream @in = new DataInputStream(new GZIPInputStream(new FileInputStream(args[0]))); double d; try { while (true) { @out.println(@in.readDouble()); } } catch (Exception) { } @out.close(); @in.close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testReadFilenameAndByteArrayValue() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testReadFilenameAndByteArrayValue() { Stream @is = this.GetType().ClassLoader.getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt"); sbyte[] data = new sbyte[@is.available()]; DataInputStream dataInputStream = new DataInputStream(@is); dataInputStream.readFully(data); dataInputStream.close(); MockValueFields valueFields = new MockValueFields(); string filename = "file.txt"; valueFields.TextValue = filename; valueFields.ByteArrayValue = data; FileValue fileValue = serializer.readValue(valueFields, true); assertThat(fileValue.Filename, @is(filename)); assertThat(fileValue.MimeType, @is(nullValue())); checkStreamFromValue(fileValue, "text"); }
// Token: 0x06000086 RID: 134 RVA: 0x00008864 File Offset: 0x00006A64 public static string loadRMSString(string fileName) { sbyte[] array = Rms.loadRMS(fileName); if (array == null) { return(null); } DataInputStream dataInputStream = new DataInputStream(array); try { string result = dataInputStream.readUTF(); dataInputStream.close(); return(result); } catch (Exception ex) { Cout.println(ex.StackTrace); } return(null); }
private void func_22107_a(File file, ArrayList arraylist, int i, int j, IProgressUpdate iprogressupdate) { Collections.sort(arraylist); var abyte0 = new byte[4096]; int i1; for (Iterator iterator = arraylist.iterator(); iterator.hasNext(); iprogressupdate.setLoadingProgress(i1)) { var filematcher = (FileMatcher)iterator.next(); int k = filematcher.func_22205_b(); int l = filematcher.func_22204_c(); RegionFile regionfile = RegionFileCache.func_22123_a(file, k, l); if (!regionfile.isChunkSaved(k & 0x1f, l & 0x1f)) { try { var datainputstream = new DataInputStream(new GZIPInputStream(new FileInputStream(filematcher.func_22207_a()))); DataOutputStream dataoutputstream = regionfile.getChunkDataOutputStream(k & 0x1f, l & 0x1f); for (int j1 = 0; (j1 = datainputstream.read(abyte0)) != -1;) { dataoutputstream.write(abyte0, 0, j1); } dataoutputstream.close(); datainputstream.close(); } catch (IOException ioexception) { ioexception.printStackTrace(); } } i++; i1 = (int)Math.round((100D * i) / j); } RegionFileCache.func_22122_a(); }
public void func_22091_b() { try { var file = new File(field_22099_b, "session.lock"); var datainputstream = new DataInputStream(new FileInputStream(file)); try { if (datainputstream.readLong() != field_22100_d) { throw new MinecraftException("The save is being accessed from another location, aborting"); } } finally { datainputstream.close(); } } catch (IOException) { throw new MinecraftException("Failed to check session lock, aborting"); } }
public void networkShutdown(string s, object[] aobj) { if (!m_isRunning) { return; } isTerminating = true; terminationReason = s; field_20176_t = aobj; (new NetworkMasterThread(this)).start(); m_isRunning = false; try { socketInputStream.close(); socketInputStream = null; } catch (Throwable) { } try { socketOutputStream.close(); socketOutputStream = null; } catch (Throwable) { } try { networkSocket.close(); networkSocket = null; } catch (Throwable) { } }
public static Object3D[] load(InputStream stream) { DataInputStream @in = new DataInputStream(stream); sbyte[] b = new sbyte[12]; @in.readFully(b, 12); for (int index = 0; index < 12; ++index) { int num1 = (int)b[index] & (int)byte.MaxValue; int num2 = (int)Loader.M3G_FILE_IDENTIFIER[index] & (int)byte.MaxValue; } List <Object3D> rootObjectList = new List <Object3D>(30); List <Object3D> objectList = new List <Object3D>(30); objectList.Add((Object3D)null); int num = 0; while (Loader.loadSection(ref @in, ref objectList, ref rootObjectList)) { ++num; } @in.close(); return(rootObjectList.ToArray()); }
public static void loadStringsChunk(int chunkID) { if (SDKTextUtils.isLoadedStringsChunk(chunkID) && !SDKTextUtils.s_forceChunkLoad) { return; } SDKStringActualChunk actualChunk1 = SDKTextUtils.s_actualChunkArray[chunkID]; int index1 = ((int)actualChunk1.flags & 64) == 0 ? (int)SDKTextUtils.s_langIndex : 0; string str1 = ""; InputStream resourceAsStream; switch (SDKTextUtils.s_chunkConfig) { case 0: string str2 = str1 + "t_"; string sourcestring1 = new string(new char[6]); int index2 = -1; sbyte num1; do { ++index2; num1 = index2 != 5 ? SDKTextUtils.s_languageArray[index1].isoCodeArray[index2] : (sbyte)32; sourcestring1 = StringFunctions.ChangeCharacter(sourcestring1, index2, (char)num1); }while (num1 != (sbyte)32); string str3 = sourcestring1.Substring(0, index2); resourceAsStream = JavaLib.getResourceAsStream(str2 + str3, false); ushort[] chunkSizeArray = SDKTextUtils.s_languageArray[index1].chunkSizeArray; for (int index3 = 1; index3 != chunkID; ++index3) { SDKStringActualChunk actualChunk2 = SDKTextUtils.s_actualChunkArray[index3]; if (((int)actualChunk2.flags & 64) == 0 || index1 == 0) { resourceAsStream.skip((long)((actualChunk2.numStrings + 1 << 1) + (int)chunkSizeArray[index3])); } } break; case 1: string str4 = str1 + "t_"; string sourcestring2 = new string(new char[6]); int charindex = -1; sbyte num2; do { ++charindex; num2 = charindex != 5 ? SDKTextUtils.s_languageArray[index1].isoCodeArray[charindex] : (sbyte)32; sourcestring2 = StringFunctions.ChangeCharacter(sourcestring2, charindex, (char)num2); }while (num2 != (sbyte)32); string str5 = StringFunctions.ChangeCharacter(sourcestring2, charindex, char.MinValue); resourceAsStream = JavaLib.getResourceAsStream(str4 + str5 + (object)chunkID, false); break; default: return; } DataInputStream dataInputStream = new DataInputStream(resourceAsStream); int num3 = actualChunk1.numStrings + 1; int group1 = (int)actualChunk1.group; SDKStringGroup group2 = SDKTextUtils.s_groupArray[group1]; SDKStringStorageChunk storageChunk = SDKTextUtils.s_storageChunkArray[group1]; if (storageChunk.stringOffsetArray == null) { storageChunk.stringOffsetArray = new ushort[(int)group2.maxNumOffsets]; } for (int index3 = 0; index3 != num3; ++index3) { storageChunk.stringOffsetArray[index3] = (ushort)dataInputStream.readShort(); } if (storageChunk.stringData == null) { storageChunk.stringData = new sbyte[(int)group2.maxSize]; } dataInputStream.readFully(storageChunk.stringData, (int)SDKTextUtils.s_languageArray[index1].chunkSizeArray[chunkID]); group2.map = (sbyte)chunkID; dataInputStream.close(); }
protected internal virtual void loadModelLayout(InputStream inputStream) { DataInputStream dataInputStream = new DataInputStream(new BufferedInputStream(inputStream)); this.readHeader(dataInputStream); this.unigrams = this.readUnigrams(dataInputStream, this.numberNGrams[0] + 1, this.bigEndian); this.skipNGrams(dataInputStream); int i; for (i = 1; i < this.maxNGram; i++) { if (this.numberNGrams[i] > 0) { if (i == 1) { this.NGramProbTable[i] = this.readFloatTable(dataInputStream, this.bigEndian); } else { this.NGramBackoffTable[i] = this.readFloatTable(dataInputStream, this.bigEndian); this.NGramProbTable[i] = this.readFloatTable(dataInputStream, this.bigEndian); int j = 1 << this.logNGramSegmentSize; int num = this.numberNGrams[i - 1] + 1; int num2 = j; int num3 = ((num2 != -1) ? (num / num2) : (-num)) + 1; this.NGramSegmentTable[i] = this.readIntTable(dataInputStream, this.bigEndian, num3); } } } i = this.readInt(dataInputStream, this.bigEndian); if (i <= 0) { string text = new StringBuilder().append("Bad word string size: ").append(i).toString(); throw new Error(text); } this.words = this.readWords(dataInputStream, i, this.numberNGrams[0]); if (this.startWordID > -1) { UnigramProbability unigramProbability = this.unigrams[this.startWordID]; unigramProbability.setLogProbability(-99f); } if (this.endWordID > -1) { UnigramProbability unigramProbability = this.unigrams[this.endWordID]; unigramProbability.setLogBackoff(-99f); } this.applyUnigramWeight(); if (this.applyLanguageWeightAndWip) { for (int j = 0; j <= this.maxNGram; j++) { this.applyLanguageWeight(this.NGramProbTable[j], this.languageWeight); this.applyWip(this.NGramProbTable[j], this.wip); if (j > 1) { this.applyLanguageWeight(this.NGramBackoffTable[j], this.languageWeight); } } } dataInputStream.close(); }
public virtual Pool loadDensityFile(string path, float floor) { Properties properties = new Properties(); int num = 0; DataInputStream dataInputStream = this.readS3BinaryHeader(path, properties); string property = properties.getProperty("version"); if (property == null || !String.instancehelper_equals(property, "1.0")) { string text = new StringBuilder().append("Unsupported version in ").append(path).toString(); throw new IOException(text); } string property2 = properties.getProperty("chksum0"); int num2 = (property2 == null || !String.instancehelper_equals(property2, "yes")) ? 0 : 1; this.resetChecksum(); int num3 = this.readInt(dataInputStream); int num4 = this.readInt(dataInputStream); int num5 = this.readInt(dataInputStream); int[] array = new int[num4]; int i; for (i = 0; i < num4; i++) { array[i] = this.readInt(dataInputStream); } i = this.readInt(dataInputStream); this.logger.fine(new StringBuilder().append("Number of states ").append(num3).toString()); this.logger.fine(new StringBuilder().append("Number of streams ").append(num4).toString()); this.logger.fine(new StringBuilder().append("Number of gaussians per state ").append(num5).toString()); this.logger.fine(new StringBuilder().append("Vector length ").append(array.Length).toString()); this.logger.fine(new StringBuilder().append("Raw length ").append(i).toString()); for (int j = 0; j < num4; j++) { num += array[j]; } if (!Sphinx3Loader.assertionsDisabled && i != num5 * num * num3) { throw new AssertionError(); } Pool pool = new Pool(path); pool.setFeature(Pool.Feature.__NUM_SENONES, num3); pool.setFeature(Pool.Feature.__NUM_STREAMS, num4); pool.setFeature(Pool.Feature.__NUM_GAUSSIANS_PER_STATE, num5); for (int k = 0; k < num3; k++) { for (int l = 0; l < num4; l++) { for (int m = 0; m < num5; m++) { float[] array2 = this.readFloatArray(dataInputStream, array[l]); Utilities.floorData(array2, floor); pool.put(k * num4 * num5 + l * num5 + m, array2); } } } this.validateChecksum(dataInputStream, num2 != 0); dataInputStream.close(); this.numStates = num3; this.numStreams = num4; this.numGaussiansPerState = num5; this.vectorLength = array; return(pool); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void close() throws java.io.IOException public override void Close() { _dataInputStream.close(); }
public static int loadTextHeader(sbyte[] textHeader) { DataInputStream dataInputStream = new DataInputStream((InputStream) new ByteArrayInputStream(textHeader, 1024)); int num1 = (int)dataInputStream.readByte(); SDKTextUtils.s_chunkConfig = dataInputStream.readByte(); SDKTextUtils.s_textEncodings = (uint)((int)dataInputStream.readByte() << 16 | (int)dataInputStream.readByte() << 8) | (uint)dataInputStream.readByte(); int num2 = (int)dataInputStream.readShort(); SDKTextUtils.s_numLangs = dataInputStream.readByte(); sbyte num3 = dataInputStream.readByte(); sbyte num4 = dataInputStream.readByte(); SDKTextUtils.s_numStorageChunks = (sbyte)((int)num3 + 1); SDKTextUtils.s_numActualChunks = (sbyte)((int)num4 + 1); SDKTextUtils.s_languageArray = new SDKStringLanguage[(int)SDKTextUtils.s_numLangs]; SDKTextUtils.s_groupArray = new SDKStringGroup[(int)SDKTextUtils.s_numActualChunks]; SDKTextUtils.s_actualChunkArray = new SDKStringActualChunk[(int)SDKTextUtils.s_numActualChunks]; for (int index = 0; index < (int)SDKTextUtils.s_numActualChunks; ++index) { SDKTextUtils.s_groupArray[index] = new SDKStringGroup(); SDKTextUtils.s_actualChunkArray[index] = new SDKStringActualChunk(); } SDKTextUtils.s_storageChunkArray = new SDKStringStorageChunk[(int)SDKTextUtils.s_numStorageChunks]; for (int index = 0; index < (int)SDKTextUtils.s_numStorageChunks; ++index) { SDKTextUtils.s_storageChunkArray[index] = new SDKStringStorageChunk(); } SDKStringActualChunk actualChunk1 = SDKTextUtils.s_actualChunkArray[0]; SDKStringStorageChunk storageChunk = SDKTextUtils.s_storageChunkArray[0]; actualChunk1.numStrings = num2; actualChunk1.flags = sbyte.MinValue; actualChunk1.group = (sbyte)0; for (int index = 0; index != (int)SDKTextUtils.s_numLangs; ++index) { SDKTextUtils.s_languageArray[index] = new SDKStringLanguage(); SDKTextUtils.s_languageArray[index].chunkSizeArray = new ushort[(int)SDKTextUtils.s_numActualChunks]; } int num5 = num2 + 1; for (int index1 = 0; index1 != (int)SDKTextUtils.s_numLangs; ++index1) { SDKStringLanguage language = SDKTextUtils.s_languageArray[index1]; language.isoCodeArray = new sbyte[5]; for (int index2 = 0; index2 != 5; ++index2) { language.isoCodeArray[index2] = dataInputStream.readByte(); } language.encoding = (int)dataInputStream.readByte(); language.fontDifferentiator = dataInputStream.readByte(); if (num2 > 0) { if (storageChunk.stringOffsetArray == null) { storageChunk.stringOffsetArray = new ushort[(int)SDKTextUtils.s_numLangs * num5]; } for (int index2 = 0; index2 != num5; ++index2) { storageChunk.stringOffsetArray[index1 * num5 + index2] = (ushort)dataInputStream.readShort(); } } } if (num2 > 0) { int stringOffset = (int)storageChunk.stringOffsetArray[(int)SDKTextUtils.s_numLangs * num5 - 1]; storageChunk.stringData = new sbyte[stringOffset]; dataInputStream.readFully(storageChunk.stringData, stringOffset); } for (int index1 = 1; index1 != (int)SDKTextUtils.s_numActualChunks; ++index1) { SDKStringActualChunk actualChunk2 = SDKTextUtils.s_actualChunkArray[index1]; int num6 = (int)dataInputStream.readByte(); actualChunk2.flags = (sbyte)(num6 & 192); actualChunk2.group = (sbyte)(num6 & 63); actualChunk2.numStrings = (int)dataInputStream.readShort(); SDKStringGroup group = SDKTextUtils.s_groupArray[(int)actualChunk2.group]; ushort num7 = (ushort)(actualChunk2.numStrings + 1); if ((int)num7 > (int)group.maxNumOffsets) { group.maxNumOffsets = num7; } for (int index2 = 0; index2 != (int)SDKTextUtils.s_numLangs; ++index2) { int num8 = dataInputStream.readUnsignedShort(); SDKTextUtils.s_languageArray[index2].chunkSizeArray[index1] = (ushort)num8; if (num8 > (int)group.maxSize) { group.maxSize = (ushort)num8; } } } SDKTextUtils.s_currentLanguage = SDKTextUtils.s_languageArray[(int)SDKTextUtils.s_langIndex]; if (SDKTextUtils.s_currentLanguage.encoding > 1) { SDKTextUtils.loadCharMap((sbyte)SDKTextUtils.s_currentLanguage.encoding); } SDKTextUtils.s_hdrLoaded = true; dataInputStream.close(); return((int)SDKTextUtils.s_numLangs); }
public static Fst importFst(string basename, Semiring semiring) { Fst fst = new Fst(semiring); HashMap hashMap = Convert.importSymbols(new StringBuilder().append(basename).append(".input.syms").toString()); if (hashMap == null) { hashMap = new HashMap(); hashMap.put("<eps>", Integer.valueOf(0)); } HashMap hashMap2 = Convert.importSymbols(new StringBuilder().append(basename).append(".output.syms").toString()); if (hashMap2 == null) { hashMap2 = new HashMap(); hashMap2.put("<eps>", Integer.valueOf(0)); } HashMap hashMap3 = Convert.importSymbols(new StringBuilder().append(basename).append(".states.syms").toString()); FileInputStream fileInputStream = new FileInputStream(new StringBuilder().append(basename).append(".fst.txt").toString()); DataInputStream dataInputStream = new DataInputStream(fileInputStream); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(dataInputStream, "UTF-8")); int num = 1; HashMap hashMap4 = new HashMap(); string text; while ((text = bufferedReader.readLine()) != null) { string[] array = String.instancehelper_split(text, "\\t"); Integer integer; if (hashMap3 == null) { integer = Integer.valueOf(Integer.parseInt(array[0])); } else { integer = (Integer)hashMap3.get(array[0]); } State state = (State)hashMap4.get(integer); if (state == null) { state = new State(semiring.zero()); fst.addState(state); hashMap4.put(integer, state); } if (num != 0) { num = 0; fst.setStart(state); } if (array.Length > 2) { Integer integer2; if (hashMap3 == null) { integer2 = Integer.valueOf(Integer.parseInt(array[1])); } else { integer2 = (Integer)hashMap3.get(array[1]); } State state2 = (State)hashMap4.get(integer2); if (state2 == null) { state2 = new State(semiring.zero()); fst.addState(state2); hashMap4.put(integer2, state2); } if (hashMap.get(array[2]) == null) { hashMap.put(array[2], Integer.valueOf(hashMap.size())); } int iLabel = ((Integer)hashMap.get(array[2])).intValue(); if (hashMap2.get(array[3]) == null) { hashMap2.put(array[3], Integer.valueOf(hashMap2.size())); } int oLabel = ((Integer)hashMap2.get(array[3])).intValue(); float weight; if (array.Length > 4) { weight = Float.parseFloat(array[4]); } else { weight = 0f; } Arc arc = new Arc(iLabel, oLabel, weight, state2); state.addArc(arc); } else if (array.Length > 1) { float finalWeight = Float.parseFloat(array[1]); state.setFinalWeight(finalWeight); } else { state.setFinalWeight(0f); } } dataInputStream.close(); fst.setIsyms(Utils.toStringArray(hashMap)); fst.setOsyms(Utils.toStringArray(hashMap2)); return(fst); }