예제 #1
0
        /// <summary>
        /// Creates a new instance of <see cref="WikiDataHelper"/>.
        /// </summary>
        /// <param name="api">The WikiData API encapsulation.</param>
        public WikiDataHelper(WikibaseApi api)
        {
            if ( api == null )
                throw new ArgumentNullException("api");
            Api = api;
            _entityProvider = new EntityProvider(Api);

            var entities = GlobalData.CompleteGeocodeList();
            _allEntities = entities.FlatList();
        }
예제 #2
0
        internal static Entity newFromArray(WikibaseApi api, JsonObject data)
        {
            if (data.get("type") != null)
            {
                switch (data.get("type").asString())
                {
                case "item":
                    return(new Item(api, data));

                case "property":
                    return(new Property(api, data));
                }
            }
            throw new Exception("Unknown type");
        }
예제 #3
0
 internal Entity(WikibaseApi api, JsonObject data)
 {
     this.api = api;
     this.fillData(data);
 }
예제 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="api">The api</param>
 public Entity(WikibaseApi api) : this(api, new JsonObject()) { }
예제 #5
0
 internal static Entity newFromArray(WikibaseApi api, JsonObject data)
 {
     if (data.get("type") != null)
     {
         switch (data.get("type").asString())
         {
             case "item":
                 return new Item(api, data);
             case "property":
                 return new Property(api, data);
         }
     }
     throw new Exception("Unknown type");
 }
예제 #6
0
 internal Item(WikibaseApi api, JsonObject data) : base(api, data)
 {
 }
예제 #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="api">The api</param>
 public Item(WikibaseApi api) : base(api)
 {
 }
예제 #8
0
 internal Property(WikibaseApi api, JsonObject data) : base(api, data) { }
예제 #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="api">The api</param>
 public Item(WikibaseApi api) : base(api) { }
예제 #10
0
 internal Entity(WikibaseApi api, JsonObject data)
 {
     this.api = api;
     this.fillData(data);
 }
예제 #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="api">The api</param>
 public Entity(WikibaseApi api) : this(api, new JsonObject())
 {
 }
예제 #12
0
        private Dictionary<Entity, String> RetrieveWikpediaLinks(IEnumerable<Entity> entities, Language language)
        {
            var result = new Dictionary<Entity, String>();
            var api = new WikibaseApi("https://www.wikidata.org", "TambonBot");
            var helper = new WikiDataHelper(api);
            foreach ( var entity in entities.Where(x => x.wiki != null && !String.IsNullOrEmpty(x.wiki.wikidata)) )
            {
                var item = helper.GetWikiDataItemForEntity(entity);
                if ( item != null )
                {
                    var links = item.getSitelinks();
                    String languageLink;
                    String wikiIdentifier = String.Empty;
                    switch ( language )
                    {
                        case Language.German:
                            wikiIdentifier = "dewiki";
                            break;

                        case Language.English:
                            wikiIdentifier = "enwiki";
                            break;

                        case Language.Thai:
                            wikiIdentifier = "thwiki";
                            break;
                    }
                    if ( item.getSitelinks().TryGetValue(wikiIdentifier, out languageLink) )
                    {
                        result[entity] = languageLink;
                    }
                }
            }
            return result;
        }
예제 #13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="api">The api</param>
 public EntityProvider(WikibaseApi api)
 {
     this.api = api;
 }
예제 #14
0
 internal Item(WikibaseApi api, JsonObject data) : base(api, data) { }
예제 #15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="api">The api</param>
 public Property(WikibaseApi api) : base(api)
 {
 }
예제 #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="api">The api</param>
 public Property(WikibaseApi api) : base(api) { }
예제 #17
0
 internal Property(WikibaseApi api, JsonObject data) : base(api, data)
 {
 }
예제 #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="api">The api</param>
 public EntityProvider(WikibaseApi api)
 {
     this.api = api;
 }