Пример #1
0
        public string TransformMsd(string msd)
        {
            if (subTrees == null)
            {
                return("");
            }
            else
            {
                char   attVal           = msdSpec.GetAttrValue(msd, this.attrId);
                string thisTransform    = msdSpec.attrIdToNameMap[attrId] + "=" + attVal;
                string subTreeTransform = "";

                if (!subTrees.ContainsKey(attVal))
                {
                    attVal = '#'; //all others
                }
                if (!subTrees.ContainsKey(attVal))
                {
                    throw new Exception("Strange msd recieved for transformation? Only known msds can be used!"); //TODO check if this can be generalised
                }
                subTreeTransform = subTrees[attVal].TransformMsd(msd);
                if (subTreeTransform != "")
                {
                    thisTransform += "&";
                }
                return(thisTransform + subTreeTransform);
            }
        }
Пример #2
0
        private static MsdSplitTree SplitByMsdAttribute(List <LemmaExample> el, int attrId, MsdSpec msdSpec)
        {
            MsdSplitTree et = new MsdSplitTree(msdSpec);

            et.attrId      = attrId;
            et.subTrees    = new Dictionary <char, MsdSplitTree>();
            et.exampleList = el;

            //todo FIX IT
            MsdSplitTree etSubDef = new MsdSplitTree(msdSpec);

            etSubDef.exampleList = new List <LemmaExample>();
            et.subTrees['#']     = etSubDef;

            for (int i = 0; i < el.Count; i++)
            {
                LemmaExample e   = el[i];
                char         cls = msdSpec.GetAttrValue(e.Msd, attrId);
                if (et.subTrees.ContainsKey(cls))
                {
                    et.subTrees[cls].exampleList.Add(e);
                }
                else
                {
                    MsdSplitTree etSub = new MsdSplitTree(msdSpec);

                    et.subTrees[cls] = etSub;

                    etSub.exampleList = new List <LemmaExample>();
                    etSub.exampleList.Add(e);
                }
            }

            double ambigChild = 0;

            foreach (KeyValuePair <char, MsdSplitTree> sub in et.subTrees)
            {
                MsdSplitTree etSub = sub.Value;
                double       ambig = GetListAmbiguities(sub.Value.exampleList);
                etSub.ambigThis         = ambig;
                etSub.ambigChild        = ambig;
                etSub.ambigRecurs       = ambig;
                etSub.subTreeSizeRecurs = 1;
                ambigChild += ambig;
            }

            et.ambigChild        = ambigChild;
            et.ambigRecurs       = ambigChild;
            et.subTreeSizeRecurs = et.subTrees.Count;

            return(et);
        }