//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.maltparser.core.symbol.SymbolTable loadTagset(String fileName, String tableName, String charSet, int columnCategory, int columnType, String nullValueStrategy) throws org.maltparser.core.exception.MaltChainedException public virtual SymbolTable loadTagset(string fileName, string tableName, string charSet, int columnCategory, int columnType, string nullValueStrategy) { try { StreamReader br = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read), charSet); string fileLine; TrieSymbolTable table = addSymbolTable(tableName, columnCategory, columnType, nullValueStrategy); while (!ReferenceEquals((fileLine = br.ReadLine()), null)) { table.addSymbol(fileLine.Trim()); } br.Close(); return(table); } catch (FileNotFoundException e) { throw new SymbolException("The tagset file '" + fileName + "' cannot be found. ", e); } catch (UnsupportedEncodingException e) { throw new SymbolException("The char set '" + charSet + "' is not supported. ", e); } catch (IOException e) { throw new SymbolException("The tagset file '" + fileName + "' cannot be loaded. ", e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public TrieSymbolTable addSymbolTable(String tableName, int columnCategory, int columnType, String nullValueStrategy) throws org.maltparser.core.exception.MaltChainedException public virtual TrieSymbolTable addSymbolTable(string tableName, int columnCategory, int columnType, string nullValueStrategy) { TrieSymbolTable symbolTable = symbolTables[tableName]; if (symbolTable == null) { symbolTable = new TrieSymbolTable(tableName, trie, columnCategory, nullValueStrategy); symbolTables[tableName] = symbolTable; } return(symbolTable); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public TrieSymbolTable addSymbolTable(String tableName) throws org.maltparser.core.exception.MaltChainedException public virtual TrieSymbolTable addSymbolTable(string tableName) { TrieSymbolTable symbolTable = symbolTables[tableName]; if (symbolTable == null) { symbolTable = new TrieSymbolTable(tableName, trie); symbolTables[tableName] = symbolTable; } return(symbolTable); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public TrieSymbolTable addSymbolTable(String tableName, org.maltparser.core.symbol.SymbolTable parentTable) throws org.maltparser.core.exception.MaltChainedException public virtual TrieSymbolTable addSymbolTable(string tableName, SymbolTable parentTable) { TrieSymbolTable symbolTable = symbolTables[tableName]; if (symbolTable == null) { TrieSymbolTable trieParentTable = (TrieSymbolTable)parentTable; symbolTable = new TrieSymbolTable(tableName, trie, trieParentTable.Category, trieParentTable.NullValueStrategy); symbolTables[tableName] = symbolTable; } return(symbolTable); }
public virtual string getValue(TrieNode node, TrieSymbolTable table) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); TrieNode tmp = node; while (tmp != root) { sb.Append(tmp.Character); tmp = tmp.Parent; } return(sb.ToString()); }
/// <summary> /// Returns the entry of the symbol table 'table' /// </summary> /// <param name="table"> which symbol table </param> /// <returns> the entry of the symbol table 'table' </returns> public virtual int?getEntry(TrieSymbolTable table) { if (table != null) { if (table.Equals(cachedKeyEntry)) { return(cachedValueEntry); } else if (entries != null) { return(entries[table]); } } return(null); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public TrieNode addValue(StringBuilder symbol, TrieSymbolTable table, int code) throws org.maltparser.core.symbol.SymbolException public virtual TrieNode addValue(StringBuilder symbol, TrieSymbolTable table, int code) { TrieNode node = root; for (int i = symbol.Length - 1; i >= 0; i--) { if (i == 0) { node = node.getOrAddChild(true, symbol[i], table, code); } else { node = node.getOrAddChild(false, symbol[i], table, code); } } return(node); }
/// <summary> /// Adds and/or retrieve a child trie node. It only adds a entry if the parameter isWord is true. /// </summary> /// <param name="isWord"> true if it is a word (entry), otherwise false </param> /// <param name="c"> the character to the child node </param> /// <param name="table"> which symbol table to look in or add to </param> /// <param name="code"> the integer representation of the string value </param> /// <returns> the child trie node that corresponds to the character </returns> /// <exception cref="SymbolException"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public TrieNode getOrAddChild(boolean isWord, char c, TrieSymbolTable table, int code) throws org.maltparser.core.symbol.SymbolException public virtual TrieNode getOrAddChild(bool isWord, char c, TrieSymbolTable table, int code) { if (cachedValueTrieNode == null) { cachedValueTrieNode = new TrieNode(c, this); cachedKeyChar = c; if (isWord) { cachedValueTrieNode.addEntry(table, code); } return(cachedValueTrieNode); } else if (cachedKeyChar == c) { if (isWord) { cachedValueTrieNode.addEntry(table, code); } return(cachedValueTrieNode); } else { TrieNode child = null; if (children == null) { children = new HashMap <char, TrieNode>(); child = new TrieNode(c, this); children[c] = child; } else { child = children[c]; if (child == null) { child = new TrieNode(c, this); children[c] = child; } } if (isWord) { child.addEntry(table, code); } return(child); } }
public virtual int?getEntry(string value, TrieSymbolTable table) { TrieNode node = root; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final char[] chars = value.toCharArray(); char[] chars = value.ToCharArray(); int i = chars.Length - 1; for (; i >= 0 && node != null; i--) { node = node.getChild(chars[i]); } if (i < 0 && node != null) { return(node.getEntry(table)); } return(null); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public TrieNode addValue(String value, TrieSymbolTable table, int code) throws org.maltparser.core.symbol.SymbolException public virtual TrieNode addValue(string value, TrieSymbolTable table, int code) { TrieNode node = root; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final char[] chars = value.toCharArray(); char[] chars = value.ToCharArray(); for (int i = chars.Length - 1; i >= 0; i--) { if (i == 0) { node = node.getOrAddChild(true, chars[i], table, code); } else { node = node.getOrAddChild(false, chars[i], table, code); } } return(node); }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (GetType() != obj.GetType()) { return(false); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final TrieSymbolTable other = (TrieSymbolTable)obj; TrieSymbolTable other = (TrieSymbolTable)obj; return((ReferenceEquals(name, null)) ? ReferenceEquals(other.name, null) : name.Equals(other.name)); }
/// <summary> /// Adds an entry if it does not exist /// </summary> /// <param name="table"> which symbol table to add an entry </param> /// <param name="code"> the integer representation of the string value </param> /// <exception cref="SymbolException"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void addEntry(TrieSymbolTable table, int code) throws org.maltparser.core.symbol.SymbolException private void addEntry(TrieSymbolTable table, int code) { if (table == null) { throw new SymbolException("Symbol table cannot be found. "); } if (cachedValueEntry == null) { if (code != -1) { cachedValueEntry = code; table.updateValueCounter(code); } else { cachedValueEntry = table.increaseValueCounter(); } cachedKeyEntry = table; } else if (!table.Equals(cachedKeyEntry)) { if (entries == null) { entries = new HashMap <TrieSymbolTable, int>(); } if (!entries.ContainsKey(table)) { if (code != -1) { entries[table] = code; table.updateValueCounter(code); } else { entries[table] = table.increaseValueCounter(); } } } }