コード例 #1
0
 public virtual object Visit(SwrlBuiltIn e)
 {
     foreach (var v in e.Values)
     {
         v.accept(this);
     }
     return(e);
 }
コード例 #2
0
ファイル: dl.serializer.cs プロジェクト: jswiatkowski/cognipy
        public object Visit(SwrlBuiltIn e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("° ");
            sb.Append(":");
            sb.Append(e.builtInName);
            sb.Append(" ");
            sb.Append("(");
            for (int i = 0; i < e.Values.Count; i++)
            {
                if (i > 0)
                {
                    sb.Append(" , ");
                }
                sb.Append(e.Values[i].accept(this));
            }
            sb.Append(")");
            return(sb.ToString());
        }
コード例 #3
0
 public override object Visit(SwrlBuiltIn e)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
 public override object Visit(SwrlBuiltIn e)
 {
     return(e);
 }
コード例 #5
0
 public override object Visit(SwrlBuiltIn e)
 {
     builtinFound = true;
     return(null);
 }
コード例 #6
0
        public override object Visit(SwrlBuiltIn e)
        {
            if (model == null)
            {
                return(null);
            }
            var builtInName = e.builtInName;
            var btag        = KeyWords.Me.GetTag(mapCode(builtInName));

            if (btag == "CMP" || btag == "EQ")
            {
                var A = e.Values[1];
                var B = e.Values[0];
                AppendComparator(sb, e.builtInName, A.accept(this).ToString(), B.accept(this).ToString());
            }
            else
            {
                var lst = e.Values[e.Values.Count - 1].accept(this).ToString();;

                for (int i = 0; i < e.Values.Count - 1; i++)
                {
                    var dn = e.Values[i].accept(this).ToString();
                    lst += ", ";
                    lst += dn;
                }

                if (builtInName == "plus" || builtInName == "times" || builtInName == "followed-by")
                {
                    if (builtInName == "followed-by")
                    {
                        sb.Append("concatenateStrings(" + lst + ")");
                    }
                    else if (builtInName == "plus")
                    {
                        sb.Append("sumNumbers(" + lst + ")");
                    }
                    else if (builtInName == "times")
                    {
                        sb.Append("multiplyNumbers(" + lst + ")");
                    }
                    else
                    {
                        SwrlBuiltInNoImpl(e);
                    }
                }
                else if (builtInName == "datetime" || builtInName == "duration")
                {
                    if (builtInName == "datetime")
                    {
                        sb.Append("createDatetime(" + lst + ")");
                    }
                    else if (builtInName == "duration")
                    {
                        sb.Append("createDuration(" + lst + ")");
                    }
                }
                else if (e.builtInName == "alpha-representation-of")
                {
                    sb.Append("alpha(" + lst + ")");
                }
                else if (e.builtInName == "annotation")
                {
                    sb.Append("annotation(" + lst + ")");
                }
                else if (e.builtInName == "execute")
                {
                    sb.Append("executeExternalFunction(" + lst + ")");
                }
                else if (builtInName == "translated" || builtInName == "replaced")
                {
                    if (builtInName == "translated")
                    {
                        sb.Append("complexStringOperation('translate'," + lst + ")");
                    }
                    else if (builtInName == "replaced")
                    {
                        sb.Append("complexStringOperation('replace'," + lst + ")");
                    }
                }
                else if (builtInName == "from" || builtInName == "before" || builtInName == "after")
                {
                    if (e.builtInName == "from")
                    {
                        sb.Append("simpleStringOperation('substring'," + lst + ")");
                    }
                    else if (e.builtInName == "before")
                    {
                        sb.Append("simpleStringOperation('substring-before'," + lst + ")");
                    }
                    else if (e.builtInName == "after")
                    {
                        sb.Append("simpleStringOperation('substring-after'," + lst + ")");
                    }
                    else
                    {
                        SwrlBuiltInNoImpl(e);
                    }
                }
                else if (e.Values.Count == 3)
                {
                    if (e.builtInName == "minus")
                    {
                        sb.Append("mathBinary('subtract'," + lst + ")");
                    }
                    else if (e.builtInName == "divided-by")
                    {
                        sb.Append("mathBinary('divide'," + lst + ")");
                    }
                    else if (e.builtInName == "integer-divided-by")
                    {
                        sb.Append("mathBinary('int-divide'," + lst + ")");
                    }
                    else if (e.builtInName == "modulo")
                    {
                        sb.Append("mathBinary('modulo'," + lst + ")");
                    }
                    else if (e.builtInName == "raised-to-the-power-of")
                    {
                        sb.Append("mathBinary('power'," + lst + ")");
                    }
                    else if (e.builtInName == "rounded-with-the-precision-of")
                    {
                        sb.Append("mathBinary('round-half-to-even'," + lst + ")");
                    }
                    else
                    {
                        SwrlBuiltInNoImpl(e);
                    }
                }
                else if (e.Values.Count == 2)
                {
                    if (e.builtInName == "not")
                    {
                        sb.Append("booleanUnary('not'," + lst + ")");
                    }
                    else if (e.builtInName == "minus")
                    {
                        sb.Append("mathUnary('minus'," + lst + ")");
                    }
                    else if (e.builtInName == "absolute-value-of")
                    {
                        sb.Append("mathUnary('absolute'," + lst + ")");
                    }
                    else if (e.builtInName == "ceiling-of")
                    {
                        sb.Append("mathUnary('ceiling'," + lst + ")");
                    }
                    else if (e.builtInName == "floor-of")
                    {
                        sb.Append("mathUnary('floor'," + lst + ")");
                    }
                    else if (e.builtInName == "round-of")
                    {
                        sb.Append("mathUnary('round'," + lst + ")");
                    }
                    else if (e.builtInName == "sine-of")
                    {
                        sb.Append("mathUnary('sine'," + lst + ")");
                    }
                    else if (e.builtInName == "cosine-of")
                    {
                        sb.Append("mathUnary('cosine'," + lst + ")");
                    }
                    else if (e.builtInName == "tangent-of")
                    {
                        sb.Append("mathUnary('tangent'," + lst + ")");
                    }
                    else if (e.builtInName == "case-ignored")
                    {
                        sb.Append("stringUnary('case-ignore'," + lst + ")");
                    }
                    else if (e.builtInName == "length-of")
                    {
                        sb.Append("stringUnary('length'," + lst + ")");
                    }
                    else if (e.builtInName == "space-normalized")
                    {
                        sb.Append("stringUnary('space-normalize'," + lst + ")");
                    }
                    else if (e.builtInName == "upper-cased")
                    {
                        sb.Append("stringUnary('upper-case'," + lst + ")");
                    }
                    else if (e.builtInName == "lower-cased")
                    {
                        sb.Append("stringUnary('lower-case'," + lst + ")");
                    }
                    else if (e.builtInName == "contains-string")
                    {
                        sb.Append("stringUnary('contains'," + lst + ")");
                    }
                    else if (e.builtInName == "starts-with-string")
                    {
                        sb.Append("stringUnary('starts-with'," + lst + ")");
                    }
                    else if (e.builtInName == "ends-with-string")
                    {
                        sb.Append("stringUnary('ends-with'," + lst + ")");
                    }
                    else if (e.builtInName == "matches-string")
                    {
                        sb.Append("stringUnary('matches'," + lst + ")");
                    }
                    else if (e.builtInName == "contains-case-ignored-string")
                    {
                        sb.Append("stringUnary('contains-case-ignore'," + lst + ")");
                    }
                    else if (e.builtInName == "sounds-like-string")
                    {
                        sb.Append("stringUnary('sounds-like'," + lst + ")");
                    }
                    else
                    {
                        SwrlBuiltInNoImpl(e);
                    }
                }
                else
                {
                    SwrlBuiltInNoImpl(e);
                }
            }
            return(null);
        }
コード例 #7
0
 void SwrlBuiltInNoImpl(SwrlBuiltIn e)
 {
     throw new NotImplementedException("Builtin :" + e.builtInName + " is not supported yet.");
 }
コード例 #8
0
ファイル: ModAnalizer.cs プロジェクト: jswiatkowski/cognipy
 public object Visit(SwrlBuiltIn e)
 {
     return(CreateNull());
 }