/// <summary> /// Adds a new category to the Graphmaster structure /// </summary> /// <param name="sPath">the PATH element of the new cCategory. NB Normalization should be done to the PATH before calling this method</param> /// <param name="sTemplate">the TEMPLATE element for the new cCategory</param> public void addCat(string sPath, string sTemplate, string filename) { // create the Category cCategory cat = new cCategory(sPath, sTemplate); // for debugging cat.filename = filename; // just to make sure the Path is tidy string sEnd = sPath.Trim(); // o.k. add the category to the root node of the graphmaster and let the cNodeMapper // class methods deal with it. rootNodeMapper.addCat(sEnd, cat); }
/// <summary> /// Adds a category to the graphmaster structure /// </summary> /// <param name="sEnd">a string to be mapped by this node</param> /// <param name="cat">the cCategory to be associated with the nodemapper</param> public void addCat(string sEnd, cCategory cat) { // this node represents the end of the sentence to be mapped so set // the cCategory for this node to the cCategory that was passed to the // function if (sEnd == "" || sEnd.Length <= 0) { thisCategory = cat; return; } // otherwise, this sentence requires further child nodemappers in order to // be fully mapped within the GraphMaster structure. // split the input into its component words string[] sWords = sEnd.Split(" ".ToCharArray()); // get the first word (to form the key for the child nodemapper) string sFirst = sWords[0]; // concatenate the rest of the sentence into a suffix (to act as the // sEnd argument in the child nodemapper) string endstr = sEnd.Substring(sFirst.Length, sEnd.Length - sFirst.Length); endstr = endstr.Trim(); // o.k. check we don't already have a child with the key from this sentence cNodeMapper wordmap = (cNodeMapper)htChildren[sFirst]; // if we do then pass the handling of this sentence down the branch to the // child nodemapper if (wordmap != null) { wordmap.addCat(endstr, cat); } // otherwise the child nodemapper doesn't yet exist, so create a new one else { cNodeMapper mapper = new cNodeMapper(); mapper.sWord = sFirst; mapper.addCat(endstr, cat); htChildren.Add(mapper.sWord, mapper); } }
/// <summary> /// Adds a category to the graphmaster structure /// </summary> /// <param name="sEnd">a string to be mapped by this node</param> /// <param name="cat">the cCategory to be associated with the nodemapper</param> public void addCat(string sEnd, cCategory cat) { // this node represents the end of the sentence to be mapped so set // the cCategory for this node to the cCategory that was passed to the // function if (sEnd == "" || sEnd.Length <= 0) { thisCategory = cat; return; } // otherwise, this sentence requires further child nodemappers in order to // be fully mapped within the GraphMaster structure. // split the input into its component words string[] sWords = sEnd.Split( " ".ToCharArray() ); // get the first word (to form the key for the child nodemapper) string sFirst = sWords[0]; // concatenate the rest of the sentence into a suffix (to act as the // sEnd argument in the child nodemapper) string endstr = sEnd.Substring( sFirst.Length, sEnd.Length - sFirst.Length ); endstr = endstr.Trim(); // o.k. check we don't already have a child with the key from this sentence cNodeMapper wordmap = (cNodeMapper)htChildren[sFirst]; // if we do then pass the handling of this sentence down the branch to the // child nodemapper if (wordmap != null) { wordmap.addCat(endstr, cat); } // otherwise the child nodemapper doesn't yet exist, so create a new one else { cNodeMapper mapper = new cNodeMapper(); mapper.sWord = sFirst; mapper.addCat(endstr, cat); htChildren.Add(mapper.sWord, mapper); } }