Exemplo n.º 1
0
        /// <summary>
        /// Add - generic method
        /// </summary>
        /// <param name="__token">The token.</param>
        /// <param name="__type">The type.</param>
        public void Add(String __token, tokenGraphNodeType __type)
        {
            var tkng = new tokenGraphNode(__token, __type, this);

            if (!children.ContainsKey(__token))
            {
                children.Add(__token, tkng);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds the value matches in the <see cref="imbSCI.DataComplex.special.translationTableMulti{TKey,TValue}",apertiumDictionaryResult or wordnet query result
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="typeForKey">The type for key.</param>
 public void AddValueMatches(translationTableMulti <String, String> source, tokenGraphNodeType typeForKey)
 {
     foreach (var pair in source)
     {
         if (pair.Value == token)
         {
             Add(pair.Key, typeForKey);
         }
     }
 }
Exemplo n.º 3
0
 public void Add(IEnumerable <String> __tokens, tokenGraphNodeType __type)
 {
     foreach (String __token in __tokens)
     {
         var tkng = new tokenGraphNode(__token, __type, this);
         if (!children.ContainsKey(__token))
         {
             children.Add(__token, tkng);
         }
     }
 }
Exemplo n.º 4
0
        public void Add(IEnumerable <KeyValuePair <String, String> > source, tokenGraphNodeType typeForValue)
        {
            foreach (var pair in source)
            {
                if (!ContainsKey(pair.Key))
                {
                    tokenGraph tg = new tokenGraph(pair.Key);
                    Add(pair.Key, tg);
                }

                this[pair.Key].Add(pair.Value, typeForValue);
            }
        }
        /// <summary>
        /// Queries for graph for multiple tokens
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="scope">The scope.</param>
        /// <param name="side">The side.</param>
        /// <returns></returns>
        public tokenGraphSet queryForGraphSet(IEnumerable <String> tokens, apertiumDictQueryScope scope = apertiumDictQueryScope.startingWith, apertiumDictNeedleSide side = apertiumDictNeedleSide.native)
        {
            tokenGraphSet outset = new tokenGraphSet();

            var queryRes = query(tokens, scope, side);

            tokenGraphNodeType nType = tokenGraphNodeType.word_eng;

            if (side == apertiumDictNeedleSide.translated)
            {
                nType = tokenGraphNodeType.word_srb;
            }

            outset.Add(queryRes, nType);

            return(outset);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the <see cref="tokenGraphNode" /> with the specified <c>t</c>. If <c>t</c> not found a new child with specified <c>cType</c> is created and returned
        /// </summary>
        /// <value>
        /// The <see cref="tokenGraphNode" />.
        /// </value>
        /// <param name="t">The t.</param>
        /// <returns></returns>
        tokenGraphNode this[String t, tokenGraphNodeType cType = tokenGraphNodeType.none]
        {
            get
            {
                if (children.ContainsKey(t))
                {
                    return(children[t]);
                }
                else
                {
                    if (cType == tokenGraphNodeType.none)
                    {
                        throw new ArgumentException("There is no [" + t + "] child, and autocreation is prevented because the cType is not set");
                        return(null);
                    }

                    Add(t, cType);
                    return(children[t]);
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Adds children and their children -- where Key is child, and Value is grandchild
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="typeForGrandChild">The type for value.</param>
 /// <param name="typeForChild">The type for key.</param>
 public void AddKeyValueChildren(IEnumerable <KeyValuePair <String, String> > source, tokenGraphNodeType typeForChild, tokenGraphNodeType typeForGrandChild, Boolean inverse = false)
 {
     foreach (var pair in source)
     {
         if (inverse)
         {
             this[pair.Value, typeForChild].Add(pair.Key, typeForGrandChild);
         }
         else
         {
             this[pair.Key, typeForChild].Add(pair.Value, typeForGrandChild);
         }
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creating instance of a child token node
 /// </summary>
 /// <param name="__token">The token.</param>
 /// <param name="__type">The type.</param>
 /// <param name="__parent">The parent.</param>
 public tokenGraphNode(String __token, tokenGraphNodeType __type, tokenGraphNode __parent = null)
 {
     token  = __token;
     type   = __type;
     parent = __parent;
 }