Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void update() throws org.maltparser.core.exception.MaltChainedException
        public void update()
        {
            parentFeature.update();
            FeatureValue value = parentFeature.FeatureValue;

            if (value is SingleFeatureValue)
            {
                string symbol = ((SingleFeatureValue)value).Symbol;
                if (((FeatureValue)value).NullValue)
                {
                    multipleFeatureValue.addFeatureValue(parentFeature.SymbolTable.getSymbolStringToCode(symbol), symbol);
                    multipleFeatureValue.NullValue = true;
                }
                else
                {
                    string prefixStr;
                    if (symbol.Length - prefixLength > 0)
                    {
                        prefixStr = symbol.Substring(0, prefixLength);
                    }
                    else
                    {
                        prefixStr = symbol;
                    }
                    int code = table.addSymbol(prefixStr);
                    multipleFeatureValue.addFeatureValue(code, prefixStr);
                    multipleFeatureValue.NullValue = false;
                }
            }
            else if (value is MultipleFeatureValue)
            {
                multipleFeatureValue.reset();
                if (((MultipleFeatureValue)value).NullValue)
                {
                    multipleFeatureValue.addFeatureValue(parentFeature.SymbolTable.getSymbolStringToCode(((MultipleFeatureValue)value).FirstSymbol), ((MultipleFeatureValue)value).FirstSymbol);
                    multipleFeatureValue.NullValue = true;
                }
                else
                {
                    foreach (string symbol in ((MultipleFeatureValue)value).Symbols)
                    {
                        string prefixStr;
                        if (symbol.Length - prefixLength > 0)
                        {
                            prefixStr = symbol.Substring(0, prefixLength);
                        }
                        else
                        {
                            prefixStr = symbol;
                        }
                        int code = table.addSymbol(prefixStr);
                        multipleFeatureValue.addFeatureValue(code, prefixStr);
                        multipleFeatureValue.NullValue = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void update() throws org.maltparser.core.exception.MaltChainedException
        public void update()
        {
            multipleFeatureValue.reset();
            parentFeature.update();
            FunctionValue value = parentFeature.FeatureValue;

            if (value is SingleFeatureValue)
            {
                string symbol = ((SingleFeatureValue)value).Symbol;
                if (((FeatureValue)value).NullValue)
                {
                    multipleFeatureValue.addFeatureValue(parentFeature.SymbolTable.getSymbolStringToCode(symbol), symbol);
                    multipleFeatureValue.NullValue = true;
                }
                else
                {
                    string[] items;
                    try
                    {
                        items = separatorsPattern.split(symbol);
                    }
                    catch (PatternSyntaxException e)
                    {
                        throw new FeatureException("The split feature '" + ToString() + "' could not split the value using the following separators '" + separators + "'", e);
                    }
                    for (int i = 0; i < items.Length; i++)
                    {
                        if (items[i].Length > 0)
                        {
                            multipleFeatureValue.addFeatureValue(table.addSymbol(items[i]), items[i]);
                        }
                    }
                    multipleFeatureValue.NullValue = false;
                }
            }
            else if (value is MultipleFeatureValue)
            {
                if (((MultipleFeatureValue)value).NullValue)
                {
                    multipleFeatureValue.addFeatureValue(parentFeature.SymbolTable.getSymbolStringToCode(((MultipleFeatureValue)value).FirstSymbol), ((MultipleFeatureValue)value).FirstSymbol);
                    multipleFeatureValue.NullValue = true;
                }
                else
                {
                    foreach (string symbol in ((MultipleFeatureValue)value).Symbols)
                    {
                        string[] items;
                        try
                        {
                            items = separatorsPattern.split(symbol);
                        }
                        catch (PatternSyntaxException e)
                        {
                            throw new FeatureException("The split feature '" + ToString() + "' could not split the value using the following separators '" + separators + "'", e);
                        }
                        for (int i = 0; i < items.Length; i++)
                        {
                            multipleFeatureValue.addFeatureValue(table.addSymbol(items[i]), items[i]);
                        }
                        multipleFeatureValue.NullValue = false;
                    }
                }
            }
        }