Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public int addSymbol(String symbol) throws org.maltparser.core.exception.MaltChainedException
        public virtual int addSymbol(string symbol)
        {
            if (nullValues == null || !nullValues.isNullValue(symbol))
            {
                if (ReferenceEquals(symbol, null) || symbol.Length == 0)
                {
                    throw new SymbolException("Symbol table error: empty string cannot be added to the symbol table");
                }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final TrieNode node = trie.addValue(symbol, this, -1);
                TrieNode node = trie.addValue(symbol, this, -1);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int code = node.getEntry(this);
                int code = node.getEntry(this).Value;
                if (!codeTable.ContainsKey(code))
                {
                    codeTable[code] = node;
                }
                return(code);
            }
            else
            {
                return(nullValues.symbolToCode(symbol));
            }
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public int addSymbol(String symbol) throws org.maltparser.core.exception.MaltChainedException
        public int addSymbol(string symbol)
        {
            if (nullValues == null || !nullValues.isNullValue(symbol))
            {
                if (ReferenceEquals(symbol, null) || symbol.Length == 0)
                {
                    throw new SymbolException("Symbol table error: empty string cannot be added to the symbol table");
                }

                if (type == SymbolTable_Fields.REAL)
                {
                    addSymbolValue(symbol);
                }
                if (!symbolCodeMap.ContainsKey(symbol))
                {
                    int code = valueCounter;
                    symbolCodeMap[symbol] = code;
                    codeSymbolMap[code]   = symbol;
                    valueCounter++;
                    return(code);
                }
                else
                {
                    return(symbolCodeMap[symbol]);
                }
            }
            else
            {
                return(nullValues.symbolToCode(symbol));
            }
        }