public override void LoadFromJson(IJsonObject jsonNode)
 {
     foreach (IJsonObject child in jsonNode["turtles"].AsList)
     {
         var obj = new TurtleDataModel();
         obj.LoadFromJson(child);
         ObjectData.Add(obj.ID, obj);
     }
     foreach (IJsonObject child in jsonNode["tables"].AsList)
     {
         var obj = new TableDataModel();
         obj.LoadFromJson(child);
         ObjectData.Add(obj.ID, obj);
     }
     foreach (IJsonObject child in jsonNode["seats"].AsList)
     {
         var obj = new SeatDataModel();
         obj.LoadFromJson(child);
         ObjectData.Add(obj.ID, obj);
     }
     foreach (IJsonObject child in jsonNode["decorations"].AsList)
     {
         var obj = new DecorationDataModel();
         obj.LoadFromJson(child);
         ObjectData.Add(obj.ID, obj);
     }
 }
示例#2
0
 public override void LoadFromJson(IJsonObject jsonNode)
 {
     Position = ToVector3(jsonNode["position"]);
     if (jsonNode["rotation"] != null)
     {
         Rotation = Quaternion.Euler(ToVector3(jsonNode["rotation"]));
     }
     Scale = ToVector3(jsonNode["scale"]);
     Projection = jsonNode["projection"].AsString.Equals("perspective") ? CameraProjection.PERSPECTIVE : CameraProjection.ORTHOGRAPHIC;
     FieldOfView = jsonNode["fieldOfView"] != null ? jsonNode["fieldOfView"].AsFloat : 0;
 }
示例#3
0
 public override void LoadFromJson(IJsonObject jsonNode)
 {
     foreach (var seatJSON in jsonNode.AsList)
     {
         Vector2 position = new Vector2(seatJSON["position"][0].AsInt, seatJSON["position"][1].AsInt);
         Vector2 direction = new Vector2(seatJSON["direction"][0].AsInt, seatJSON["direction"][1].AsInt);
         Seats.Add(new SeatModel()
         {
             Position = position,
             Direction = direction,
             StaticData = ObjectDatabaseModel.Instance[seatJSON["seatID"].AsString]
         });
     }
 }
        public override bool VisitObject(IJsonObject value)
        {
            foreach (var kv in _value)
            {
                IJsonValue v;
                if (!value.TryGetValue(kv.Key, out v))
                {
                    return false;
                }

                var filter = new JsonFilter(kv.Value);
                if (!filter.Matches(v))
                {
                    return false;
                }
            }
            return true;
        }
示例#5
0
 public Matcher VisitObject(IJsonObject value)
 {
     return(new ObjectMatcher(new JsonFilter(value)));
 }
示例#6
0
        public JsonDeserializer(string jsonString)
        {
            JsonReader reader = new JsonReader(jsonString);

            this._obj = reader.JsonRead();
        }
 /// <summary>
 /// プロパティを追加します.
 /// </summary>
 /// <param name="propName">プロパティ名.</param>
 /// <param name="propValue">プロパティ値.</param>
 public JsonObjectBuilder Append(string propName, IJsonObject propValue)
 {
     propsDict[propName] = propValue;
     return(this);
 }
示例#8
0
 private static Vector3 ToVector3(IJsonObject node)
 {
     return new Vector3(node[0].AsFloat, node[1].AsFloat, node[2].AsFloat);
 }
示例#9
0
 public JsonDeserializer(IJsonObject obj)
 {
     this._obj = obj;
 }
示例#10
0
 public override void LoadFromJson(IJsonObject jsonNode)
 {
     if (jsonNode["speed"] != null)
     {
         Speed = jsonNode["speed"].AsFloat;
     }
     base.LoadFromJson(jsonNode);
 }
示例#11
0
 public Snapshot(IJsonObject jsonObject, Firebase reference)
 {
     JsonObject = jsonObject;
     Reference  = reference;
 }
示例#12
0
 /// <summary>
 /// <code>Object</code>型のJSONノードを組み立てるためのビルダーを生成します.
 /// </summary>
 /// <param name="proto">プロパティの初期値を提供する<see cref="IJsonObject"/>.</param>
 public static JsonObjectBuilder Builder(IJsonObject proto)
 {
     return(JsonObjectBuilder.GetInstance(proto));
 }
示例#13
0
 /// <summary>
 /// このJSONノードが持つプロパティのうち指定された名前のプロパティを返します.
 /// 指定された名前のプロパティが存在しない場合は引数で指定されたデフォルト値を返します.
 /// </summary>
 /// <returns>プロパティ値.</returns>
 /// <param name="name">プロパティ名.</param>
 /// <param name="fallback">デフォルト値.</param>
 public IJsonObject GetProperty(string name, IJsonObject fallback)
 {
     return(HasProperty(name) ? GetProperty(name) : fallback);
 }
示例#14
0
 /// <summary>
 /// Loads this model from a parsed JSON node.
 /// </summary>
 /// <param name="jsonNode">The parsed JSON node from which Model data should be loaded.</param>
 public virtual void LoadFromJson(IJsonObject jsonNode)
 {
 }
示例#15
0
 public override bool VisitObject(IJsonObject value)
 {
     return(_filter.Matches(value));
 }
示例#16
0
 public override void LoadFromJson(IJsonObject jsonNode)
 {
     Width  = jsonNode["dimensions"][0].AsInt;
     Height = jsonNode["dimensions"][1].AsInt;
     base.LoadFromJson(jsonNode);
 }
 public JsonDeserializationException(IJsonObject jsonObject, Type targetType, string msg) : base(jsonObject.Position, msg)
 {
     this._jsonType   = jsonObject.Type;
     this._targetType = targetType;
 }
示例#18
0
 /// <summary>
 /// Loads this model from a parsed JSON node.
 /// </summary>
 /// <param name="jsonNode">The parsed JSON node from which Model data should be loaded.</param>
 public virtual void LoadFromJson(IJsonObject jsonNode)
 {
 }
示例#19
0
 public override void LoadFromJson(IJsonObject jsonNode)
 {
     EdgePaddingPixels = jsonNode["edgePadding"].AsInt;
 }
示例#20
0
        private static void FormatHelper(IJsonObject json,
                                         IJsonFormatOptions opts,
                                         StringBuilder buff,
                                         int depth)
        {
            if (json.Type != JsonObjectType.Array && !json.TypeIs(JsonObjectType.Object))
            {
                buff.Append(json.ToString());
                return;
            }

            if (json.Type == JsonObjectType.Array)
            {
                buff.Append('[');
                bool empty = true;
                foreach (IJsonObject item in json.AsArray())
                {
                    if (empty)
                    {
                        empty = false;
                    }
                    else
                    {
                        buff.Append(',');
                    }
                    FormatHelperNewLine(opts, buff);
                    FormatHelperIndent(opts, buff, depth + 1);
                    FormatHelper(item, opts, buff, depth + 1);
                }
                if (!empty)
                {
                    FormatHelperNewLine(opts, buff);
                    FormatHelperIndent(opts, buff, depth);
                }
                buff.Append(']');
            }
            else if (json.Type == JsonObjectType.Object)
            {
                buff.Append('{');
                bool empty = true;
                foreach (IJsonProperty p in json.Properties)
                {
                    if (empty)
                    {
                        empty = false;
                    }
                    else
                    {
                        buff.Append(',');
                    }
                    FormatHelperNewLine(opts, buff);
                    FormatHelperIndent(opts, buff, depth + 1);
                    buff.Append(Quotes(p.Name)).Append(' ').Append(':').Append(' ');
                    FormatHelper(p.Value, opts, buff, depth + 1);
                }
                if (!empty)
                {
                    FormatHelperNewLine(opts, buff);
                    FormatHelperIndent(opts, buff, depth);
                }
                buff.Append('}');
            }
        }
示例#21
0
 public override bool VisitObject(IJsonObject value)
 {
     return _filter.Matches(value);
 }
示例#22
0
 public override void LoadFromJson(IJsonObject jsonNode)
 {
     EdgePaddingPixels = jsonNode["edgePadding"].AsInt;
 }
示例#23
0
 public override void LoadFromJson(IJsonObject jsonNode)
 {
     Width = jsonNode["dimensions"][0].AsInt;
     Height = jsonNode["dimensions"][1].AsInt;
     base.LoadFromJson(jsonNode);
 }
示例#24
0
 protected ResponseAction Created(IJsonObject jsonObject, Propex targets)
 {
     return Respond(HttpStatusCode.Created, jsonObject, targets);
 }
示例#25
0
 public static IWebRequest WithBody(this IWebRequest request, IJsonObject body)
 {
     return(request.WithBody(new JsonBodyContent(body)));
 }
示例#26
0
 protected ResponseAction OK(IJsonObject jsonObject, Propex targets = null)
 {
     return Respond(HttpStatusCode.OK, jsonObject, targets ?? Targets);
 }
示例#27
0
 /// <summary>
 /// RPCリクエストのパラメータを指定します.
 /// </summary>
 /// <param name="name">JSONプロパティ名.</param>
 /// <param name="value">JSONプロパティ値.</param>
 public RequestBuilder Parameter(string name, IJsonObject value)
 {
     builer.Append(name, value);
     return(this);
 }
示例#28
0
 protected ResponseAction Respond(HttpStatusCode status, IJsonObject jsonObject, Propex targets)
 {
     var options = new JsonWriterOptions(targets: targets, formatted: Formatted);
     return Respond(status, (IJsonItemWriter)jsonObject, options);
 }
示例#29
0
 public JsonDeserializer(JsonReader reader)
 {
     this._obj = reader.JsonRead();
 }
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.TypeLoadException"/>
        internal virtual void SetUpProperties(string line, bool readFile, bool writeOutputToFile, string additionalSeedWordsFiles)
        {
            IJsonReader jsonReader = Javax.Json.Json.CreateReader(new StringReader(line));
            IJsonObject objarr     = jsonReader.ReadObject();

            jsonReader.Close();
            Properties props = new Properties();

            foreach (string o in objarr.Keys)
            {
                if (o.Equals("seedWords"))
                {
                    IJsonObject obj = objarr.GetJsonObject(o);
                    foreach (string st in obj.Keys)
                    {
                        seedWords[st] = new HashSet <CandidatePhrase>();
                        IJsonArray arr = obj.GetJsonArray(st);
                        for (int i = 0; i < arr.Count; i++)
                        {
                            string val = arr.GetString(i);
                            seedWords[st].Add(CandidatePhrase.CreateOrGet(val));
                            System.Console.Out.WriteLine("adding " + val + " for label " + st);
                        }
                    }
                }
                else
                {
                    props.SetProperty(o, objarr.GetString(o));
                }
            }
            System.Console.Out.WriteLine("seedwords are " + seedWords);
            if (additionalSeedWordsFiles != null && !additionalSeedWordsFiles.IsEmpty())
            {
                IDictionary <string, ICollection <CandidatePhrase> > additionalSeedWords = GetPatternsFromDataMultiClass.ReadSeedWords(additionalSeedWordsFiles);
                logger.Info("additional seed words are " + additionalSeedWords);
                foreach (string label in seedWords.Keys)
                {
                    if (additionalSeedWords.Contains(label))
                    {
                        Sharpen.Collections.AddAll(seedWords[label], additionalSeedWords[label]);
                    }
                }
            }
            outputFile = null;
            if (readFile)
            {
                System.Console.Out.WriteLine("input value is " + objarr.GetString("input"));
                outputFile = props.GetProperty("input") + "_processed";
                props.SetProperty("file", objarr.GetString("input"));
                if (writeOutputToFile && !props.Contains("columnOutputFile"))
                {
                    props.SetProperty("columnOutputFile", outputFile);
                }
            }
            else
            {
                string systemdir = Runtime.GetProperty("java.io.tmpdir");
                File   tempFile  = File.CreateTempFile("sents", ".tmp", new File(systemdir));
                tempFile.DeleteOnExit();
                IOUtils.WriteStringToFile(props.GetProperty("input"), tempFile.GetPath(), "utf8");
                props.SetProperty("file", tempFile.GetAbsolutePath());
            }
            SetProperties(props);
            this.props = props;
            int i_1 = 1;

            foreach (string label_1 in seedWords.Keys)
            {
                string ansclstr = "edu.stanford.nlp.patterns.PatternsAnnotations$PatternLabel" + i_1;
                Type   mcCl     = (Type)Sharpen.Runtime.GetType(ansclstr);
                machineAnswerClasses[label_1] = mcCl;
                string humanansclstr = "edu.stanford.nlp.patterns.PatternsAnnotations$PatternHumanLabel" + i_1;
                humanLabelClasses[label_1] = (Type)Sharpen.Runtime.GetType(humanansclstr);
                i_1++;
            }
        }
 /// <summary>
 /// ビルダーのインスタンスを返します.
 /// 引数で指定指定されたJSONノードのプロパティは
 /// ビルダーにより生成されるJSONノードにコピーされます。
 /// </summary>
 /// <returns>ビルダー.</returns>
 /// <param name="prototype">Prototype.</param>
 public static JsonObjectBuilder GetInstance(IJsonObject prototype)
 {
     return(prototype == null?GetInstance() : new JsonObjectBuilder(prototype));
 }
        public static TwitterException Parse(string str)
        {
            IJsonObject obj = JsonConverter.Parse(str);

            return(obj is JsonArray?Parse(obj as JsonArray) : Parse(obj as JsonObject));
        }
示例#33
0
 private Stream ReturnJSON(IJsonObject value, ChunkedMemoryStream cms)
 {
     value.Serialize(cms);
     ThreadContext.Response.ContentType = "application/json";
     return(cms);
 }
示例#34
0
 public virtual bool VisitObject(IJsonObject value)
 {
     return(false);
 }
示例#35
0
        private void SerializeObject(object obj, int depth)
        {
            if (obj == null)
            {
                WriteBytes("null"); return;
            }

            Type t = obj.GetType();

            switch (Type.GetTypeCode(t))
            {
            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.Int64:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
            case TypeCode.UInt64:
                SerializeConvertible((IConvertible)obj); return;

            case TypeCode.Double:
            case TypeCode.Decimal:
            case TypeCode.Single:
                SerializeFloat((IFormattable)obj); return;

            case TypeCode.String:
                SerializeString((string)obj); return;

            case TypeCode.Char:
                SerializeCharacter((char)obj); return;

            case TypeCode.Boolean:
                SerializeBool((bool)obj); return;

            case TypeCode.DBNull:
                WriteBytes("null"); return;

            case TypeCode.DateTime:
                SerializeDateTime((System.DateTime)obj); return;
            }

            if (t.IsArray)
            {
                Type te = t.GetElementType();
                switch (Type.GetTypeCode(te))
                {
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64:
                case TypeCode.UInt16:
                case TypeCode.UInt32:
                case TypeCode.UInt64:
                    SerializeArray((IConvertible[])obj, SerializeConvertible); return;

                case TypeCode.Double:
                case TypeCode.Decimal:
                case TypeCode.Single:
                    SerializeArray((IFormattable[])obj, SerializeFloat); return;

                case TypeCode.String:
                    SerializeArray((string[])obj, SerializeString); return;

                case TypeCode.Char:
                    SerializeArray((char[])obj, SerializeCharacter); return;

                case TypeCode.Boolean:
                    SerializeArray((bool[])obj, SerializeBool); return;

                case TypeCode.DBNull:
                    WriteBytes("null"); return;

                case TypeCode.DateTime:
                    SerializeArray((DateTime[])obj, SerializeDateTime); return;
                }

                IConvertible[] arrConv = obj as IConvertible[];
                if (arrConv != null)
                {
                    SerializeArray(arrConv, SerializeConvertible); return;
                }
            }

            JsonObject objDict = obj as JsonObject;

            if (objDict != null)
            {
                SerializeDictionary(objDict, depth); return;
            }

            JsonArray objList = obj as JsonArray;

            if (objList != null)
            {
                SerializeArray(objList, depth); return;
            }

            IJsonObject objObj = obj as IJsonObject;

            if (objObj != null)
            {
                var ocdict = objObj.SerializeJson();
                SerializeDictionary(ocdict, depth); return;
            }

            IEnumerable objEnum = obj as IEnumerable;

            if (objEnum != null && t.IsSerializable)
            {
                SerializeEnumerable(objEnum, depth); return;
            }

            IJsonBinary objBinary = obj as IJsonBinary;

            if (objBinary != null)
            {
                SerializeBinary(objBinary); return;
            }

            throw new JsonException(string.Format(
                                        "Object of type {0} is not serializable\n{1}{0}"
                                        , t.Name, this.DebugValue));
        }
        public virtual void Process(int id, Document document)
        {
            IJsonArrayBuilder clusters = Javax.Json.Json.CreateArrayBuilder();

            foreach (CorefCluster gold in document.goldCorefClusters.Values)
            {
                IJsonArrayBuilder c = Javax.Json.Json.CreateArrayBuilder();
                foreach (Mention m in gold.corefMentions)
                {
                    c.Add(m.mentionID);
                }
                clusters.Add(c.Build());
            }
            goldClusterWriter.Println(Javax.Json.Json.CreateObjectBuilder().Add(id.ToString(), clusters.Build()).Build());
            IDictionary <Pair <int, int>, bool> mentionPairs = CorefUtils.GetLabeledMentionPairs(document);
            IList <Mention> mentionsList = CorefUtils.GetSortedMentions(document);
            IDictionary <int, IList <Mention> > mentionsByHeadIndex = new Dictionary <int, IList <Mention> >();

            foreach (Mention m_1 in mentionsList)
            {
                IList <Mention> withIndex = mentionsByHeadIndex.ComputeIfAbsent(m_1.headIndex, null);
                withIndex.Add(m_1);
            }
            IJsonObjectBuilder docFeatures = Javax.Json.Json.CreateObjectBuilder();

            docFeatures.Add("doc_id", id);
            docFeatures.Add("type", document.docType == Document.DocType.Article ? 1 : 0);
            docFeatures.Add("source", document.docInfo["DOC_ID"].Split("/")[0]);
            IJsonArrayBuilder sentences = Javax.Json.Json.CreateArrayBuilder();

            foreach (ICoreMap sentence in document.annotation.Get(typeof(CoreAnnotations.SentencesAnnotation)))
            {
                sentences.Add(GetSentenceArray(sentence.Get(typeof(CoreAnnotations.TokensAnnotation))));
            }
            IJsonObjectBuilder mentions = Javax.Json.Json.CreateObjectBuilder();

            foreach (Mention m_2 in document.predictedMentionsByID.Values)
            {
                IEnumerator <SemanticGraphEdge> iterator = m_2.enhancedDependency.IncomingEdgeIterator(m_2.headIndexedWord);
                SemanticGraphEdge relation    = iterator.MoveNext() ? iterator.Current : null;
                string            depRelation = relation == null ? "no-parent" : relation.GetRelation().ToString();
                string            depParent   = relation == null ? "<missing>" : relation.GetSource().Word();
                mentions.Add(m_2.mentionNum.ToString(), Javax.Json.Json.CreateObjectBuilder().Add("doc_id", id).Add("mention_id", m_2.mentionID).Add("mention_num", m_2.mentionNum).Add("sent_num", m_2.sentNum).Add("start_index", m_2.startIndex).Add("end_index"
                                                                                                                                                                                                                                                        , m_2.endIndex).Add("head_index", m_2.headIndex).Add("mention_type", m_2.mentionType.ToString()).Add("dep_relation", depRelation).Add("dep_parent", depParent).Add("sentence", GetSentenceArray(m_2.sentenceWords)).Add("contained-in-other-mention"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                , mentionsByHeadIndex[m_2.headIndex].Stream().AnyMatch(null) ? 1 : 0).Build());
            }
            IJsonArrayBuilder featureNames = Javax.Json.Json.CreateArrayBuilder().Add("same-speaker").Add("antecedent-is-mention-speaker").Add("mention-is-antecedent-speaker").Add("relaxed-head-match").Add("exact-string-match").Add("relaxed-string-match"
                                                                                                                                                                                                                                        );
            IJsonObjectBuilder features = Javax.Json.Json.CreateObjectBuilder();
            IJsonObjectBuilder labels   = Javax.Json.Json.CreateObjectBuilder();

            foreach (KeyValuePair <Pair <int, int>, bool> e in mentionPairs)
            {
                Mention           m1      = document.predictedMentionsByID[e.Key.first];
                Mention           m2      = document.predictedMentionsByID[e.Key.second];
                string            key     = m1.mentionNum + " " + m2.mentionNum;
                IJsonArrayBuilder builder = Javax.Json.Json.CreateArrayBuilder();
                foreach (int val in CategoricalFeatureExtractor.PairwiseFeatures(document, m1, m2, dictionaries, conll))
                {
                    builder.Add(val);
                }
                features.Add(key, builder.Build());
                labels.Add(key, e.Value ? 1 : 0);
            }
            IJsonObject docData = Javax.Json.Json.CreateObjectBuilder().Add("sentences", sentences.Build()).Add("mentions", mentions.Build()).Add("labels", labels.Build()).Add("pair_feature_names", featureNames.Build()).Add("pair_features", features.Build
                                                                                                                                                                                                                                    ()).Add("document_features", docFeatures.Build()).Build();

            dataWriter.Println(docData);
        }
示例#37
0
 public JsonBodyContent(IJsonObject jsonObject)
 {
     _jsonObject = jsonObject;
 }
 public ObjectComparerVisitor(IJsonObject value)
 {
     _value = value;
 }
示例#39
0
 public override void LoadFromJson(IJsonObject jsonNode)
 {
     ID = jsonNode["id"].AsString;
     FriendlyID = jsonNode["friendlyID"].AsString;
     if (jsonNode["dimensions"] != null)
     {
         Width = jsonNode["dimensions"][0].AsInt;
         Height = jsonNode["dimensions"][1].AsInt;
     }
 }
示例#40
0
 public void AddRange(IJsonObject jsonObject)
 {
     AddRange(jsonObject.KeyValuePairs);
 }
示例#41
0
 private Stream ReturnJSON(IJsonObject value, ChunkedMemoryStream cms)
 {
     value.Serialize(cms);
     ThreadContext.Response.ContentType = "application/json";
     return cms;
 }
示例#42
0
 /// <summary>
 /// レスポンスの本文の文字列を設定します.
 /// </summary>
 /// <returns></returns>
 /// <param name="b">文字列</param>
 public ResponseBuilder Body(string b)
 {
     json = JsonObject.FromString(b);
     return(this);
 }
示例#43
0
 internal Response(IRequest req, HttpStatusCode statusCode, IJsonObject body)
 {
     Request    = req;
     StatusCode = statusCode;
     Body       = body;
 }
示例#44
0
 public static string ToJson(this IJsonObject obj)
 {
     return(obj.KeyValuePairs.Stringify());
 }
示例#45
0
 /// <summary>
 /// レスポンスの本文のJSONオブジェクトを設定します.
 /// </summary>
 /// <returns></returns>
 /// <param name="b">JSONオブジェクト</param>
 public ResponseBuilder Body(IJsonObject b)
 {
     json = b;
     return(this);
 }
示例#46
0
 public JsonBuilder Append(IJsonObject obj)
 {
     return(this.Append(obj.KeyValuePairs));
 }