예제 #1
0
        /// <summary>
        /// Returns <i>true</i> if the graph element has a label for the symbol table, otherwise <i>false</i>.
        /// </summary>
        /// <param name="table"> the symbol table </param>
        /// <returns> <i>true</i> if the graph element has a label for the symbol table, otherwise <i>false</i>. </returns>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean hasLabel(org.maltparser.core.symbol.SymbolTable table) throws org.maltparser.core.exception.MaltChainedException
        public virtual bool hasLabel(SymbolTable table)
        {
            if (labelSet != null)
            {
                return(labelSet.containsKey(table));
            }
            return(false);
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setRootLabels(String rootLabelOption, java.util.SortedMap<String, org.maltparser.core.symbol.SymbolTable> edgeSymbolTables) throws org.maltparser.core.exception.MaltChainedException
		public virtual void setRootLabels(string rootLabelOption, SortedDictionary<string, SymbolTable> edgeSymbolTables)
		{
			if (edgeSymbolTables == null)
			{
				return;
			}
			else if (ReferenceEquals(rootLabelOption, null) || rootLabelOption.Trim().Length == 0)
			{
				foreach (SymbolTable table in edgeSymbolTables.Values)
				{
					rootLabelCodes.put(table, table.addSymbol(DEFAULT_ROOTSYMBOL));
				}
			}
			else if (rootLabelOption.Trim().IndexOf(',') == -1)
			{
				int index = rootLabelOption.Trim().IndexOf('=');
				if (index == -1)
				{
					foreach (SymbolTable table in edgeSymbolTables.Values)
					{
						rootLabelCodes.put(table, table.addSymbol(rootLabelOption.Trim()));
					}
				}
				else
				{
					string name = rootLabelOption.Trim().Substring(0, index);
					if (edgeSymbolTables[name] == null)
					{
						throw new SyntaxGraphException("The symbol table '" + name + "' cannot be found when defining the root symbol. ");
					}
					else
					{
						rootLabelCodes.put(edgeSymbolTables[name], edgeSymbolTables[name].addSymbol(rootLabelOption.Trim().Substring(index + 1)));
						if (edgeSymbolTables.Count > 1)
						{
							foreach (SymbolTable table in edgeSymbolTables.Values)
							{
								if (!table.Name.Equals(name))
								{
									rootLabelCodes.put(table, table.addSymbol(DEFAULT_ROOTSYMBOL));
								}
							}
						}
					}
				}
			}
			else
			{
				string[] items = rootLabelOption.Trim().Split(",", true);
				for (int i = 0; i < items.Length; i++)
				{
					int index = items[i].Trim().IndexOf('=');
					if (index == -1)
					{
						throw new SyntaxGraphException("The root symbol is undefinied. ");
					}
					else
					{
						string name = items[i].Trim().Substring(0, index);
						if (edgeSymbolTables[name] == null)
						{
							throw new SyntaxGraphException("The symbol table'" + name + "' cannot be found when defining the root symbol. ");
						}
						else
						{
							rootLabelCodes.put(edgeSymbolTables[name], edgeSymbolTables[name].addSymbol(items[i].Trim().Substring(index + 1)));
						}
					}
				}
				foreach (SymbolTable table in edgeSymbolTables.Values)
				{
					if (!rootLabelCodes.containsKey(table))
					{
						rootLabelCodes.put(table, table.addSymbol(DEFAULT_ROOTSYMBOL));
					}
				}
			}
		}