HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
      • Create new note
      • Create a note from template
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Save as template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
    Menu Sharing Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- breaks: true # False means NOT to render line breaks as hard line breaks. --- Wikidata 入門筆記 1 - 基本使用 ============================== ###### tags: `Wikidata` {%hackmd pPCm34WnTpyby2g957L4Gg %} :::info [(以書本模式瀏覽)](https://hackmd.io/@jd3main/H1TpO43CX/) ::: ## 參考連結 * [Wikidata](https://www.wikidata.org/) * [Wikidata Query](https://query.wikidata.org/) * [User Manual](https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual) * [Query Help](https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Wikidata_Query_Help) * [How to use data on Wikimedia projects](https://www.wikidata.org/wiki/Wikidata:How_to_use_data_on_Wikimedia_projects) ## Wikidata 是什麼? [Wikidata](https://www.wikidata.org/) 是一個開放的知識庫,和維基百科一樣人人都可以進行編輯 有別於維基百科,Wikidata 提供的是**結構化的資料** 方便從政府等資料庫匯入,以及其他程式的取用 ## 概觀 [首頁](https://www.wikidata.org/): ![](https://i.imgur.com/WXnBWqC.png) 你可以隨便點選一個條目來看看 一個項目的頁面大概長像這樣 ![](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Datamodel_in_Wikidata.svg/1280px-Datamodel_in_Wikidata.svg.png) #### 名詞說明 | | 暫譯 | | 例 | |-------------|-----|-|-| | Label | 標籤 | 項目的可閱讀名稱 | 地球 | | Identifier (ID) | 編號 | 用來唯一辨識一個項目的編號 | Q2 | | Description | 描述 | 幫助分別同樣名稱的條目的簡短敘述 | 距離太陽第三近的行星 | | Property | 屬性 | 表示 Item 擁有的屬性 | 人口 | | Value | 值 | 屬性的內容 | 7,655,957,369 | | Qualifier | 限定符 | 限定描述的範圍 | [point in time](https://www.wikidata.org/wiki/Property:P585 "Property:P585") 2018/10/11 | | Reference | 參考 | 資料來源 | ## 編輯 ### 帳號、語言設定 :::success **建議辦個帳號**來編輯,避免語言設定問題 ::: :::warning 目前 Babel 有些 bug,可能會看不到一部分在 Babel 裡設定的語言,建議一般使用者直接在右上方語言設定選取要編輯的語言 ::: 你可能會沒辦法看到想要編輯的語言 這時候你可以到 User page 去新增 [Babel](https://en.wikipedia.org/wiki/Wikipedia:Babel) > 點擊帳號名稱進入 User Page ![](https://i.imgur.com/bVeGR68.png =400x) > 按 Edit 編輯 ![](https://i.imgur.com/BLbTaNY.png =400x) 根據自己熟悉的語言填入語言資訊 例如: ``` {{#babel:zh-tw-N|zh-hant-N|zh-4|zh-hans-2|zh-cn-2|en-2|ja-1}} ``` 基本格式是 ```<語言碼>-<1~5 or N>``` N 代表你有母語水準的能力 這是我的 User page 可以參考看看:[User:Jd3main](https://www.wikidata.org/wiki/User:Jd3main) > 不同 wiki 的 user page 不會共通 > 如果你已經有維基百科的 user page,可能需要在 wikidata 裡再創一次 ### 教學、沙盒 可以來 [**這裡**](https://www.wikidata.org/wiki/Q4115189) 玩沙 如果你不嫌棄英文,這裡有兩個 [小教學](https://www.wikidata.org/wiki/Wikidata:Tours) ### 新增項目 #### 新增 Item 點這裡就可以新增 Item,**記得先確認沒有重複** ![](https://i.imgur.com/HoeWBXa.png =300x) #### 新增 Property 一般 Item 可以自己隨便加,但一個全新的 Property (P開頭的項目) 就得要經過社群討論後同意才能新增 ### 多個 Value 一個 Property 可以有多個 Value 每個 Value 可以用 Qualifier 進一步描述 ### Reference 跟維基百科一樣,會希望資料有附上參照 這個參照可以是外部連結,也可以是其他 Wikidata 項目 少數狀況會刪除沒有附 reference 的資料 ## Statement Wikidata 採用 [RDF](https://en.wikipedia.org/wiki/Resource_Description_Framework) 模型儲存。 所有的資料都是由一條條 **statement** 來描述 每個 **statement** 都是由 **項目、屬性、值** 組成的三元組(triples) 形式如: ``` <item> <property> <value> ``` 有些說明文件裡可能會用一種比較文言的說法: ``` <subject> <predicate> <object> ``` 例如,地球半徑是 6371km,可能寫成 ``` 地球 半徑 6371km ``` ## ID, Label and Description 一個名稱可能有多個意思,為了唯一的辨別事物,Wikidata 裡的項目(Item)都有一個 ID | ID | Label(en) | Description | |-|-|-| | P2067 | mass | mass (in colloquial usage also known as weight) of the item | Q11423 | mass | measure of the resistance of a physical body to acceleration; also determines the strength of its gravitational attraction | Q217295 | mass | form of sacred musical composition ID 一般有 P 和 Q 兩種開頭 P 表示是屬性 ( **P**roperty ) Q 是項目 ( Item ) > 問:為什麼 Item 是 Q? > 答:這是個謎。 而給人辨識的「名稱」則被稱為 Label 每個語言都可以有各自的 Label 和一段 Description Description 簡潔的對一個項目下定義,讓人能藉此分辨同樣 Label 的東西代表的分別是什麼 ### 良好的 Description [這個連結](https://www.wikidata.org/wiki/Help:Description) 說明了一些撰寫 Description 的基本原則 以下列出一些重點 * 避免可能更動的資訊 * 抱持中立 * 不要以句號結尾 * (en) 避免大寫開頭,除非是專有名詞 * (en) 避免冠詞開頭 (a,an,the) 另外關於常見的類型(人、地點、機構...) 可以參考幫助文件裡給的常用公式來寫 ## Qualifier 有時候一種屬性會有多個值 例如 [蒙娜麗莎](https://www.wikidata.org/wiki/Q12418) 使用了 3 種不同的材質([material used](https://www.wikidata.org/wiki/Property:P186)) 分別是:oil paint / poplar wood / wood 為了分別這些值代表的不同意義,所以用 qualifier 來標示 ![](https://i.imgur.com/ceSexFA.png =500x) ## [Query Service](https://query.wikidata.org/) Wikidata 提供了[Query Service](https://query.wikidata.org/) 可以簡單的使用 可以使用旁邊的選單式編輯器,或直接撰寫 [SPARQL](https://en.wikipedia.org/wiki/SPARQL) 進行 Query 裡面也提供了很多範例可以參考 > [官方教學](https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual) 裡有段[影片教學](https://upload.wikimedia.org/wikipedia/commons/5/5a/Wikidata_Sparql_Query_Tutorial.webm)可以看看 按 ![執行](https://i.imgur.com/BQtdn5t.png =30x30) 執行查詢 按 ![](https://i.imgur.com/B74mRRB.png) 可以選擇要下載什麼格式的資料 按 ![](https://i.imgur.com/hsSH8Ga.png) 可以找到各種語言 Query 的範例 Code 滑鼠移到ID上面就可以看到名稱和說明 ![](https://i.imgur.com/UbOKTgP.png =300x) 可以到 wikidata 搜尋 item 編號 如果需要搜尋 Property 可以到 [Search Property](https://www.wikidata.org/wiki/Wikidata:List_of_properties) 另外官方說 Ctrl+Space 有自動完成,不過可能是輸入法的關係,我沒成功使用過 ### 限制 Query 有 **60秒** 的上限 如果一個 Query 花費超過 60 秒會直接被中斷 可以嘗試加上數量限制來解決 但是 ++經常是我們寫的條件有 Bug++ 才會導致數量過多跑不完 ### Display Mode 這裡有個 [範例](https://query.wikidata.org/#%23Map%20of%20hospitals%0A%23added%202017-08%0A%23defaultView%3AMap%0ASELECT%20%2a%20WHERE%20%7B%0A%20%20%3Fitem%20wdt%3AP31%2a%2Fwdt%3AP279%2a%20wd%3AQ16917%3B%0A%20%20%20%20%20%20%20%20wdt%3AP625%20%3Fgeo%20.%0A%7D) 執行後可以看到他顯示了一張地圖 紅點是醫院的位置 可以在左邊選擇顯示的模式 ![](https://i.imgur.com/UKg2V7G.png) 平常預設模式是 Table 除了 Table 以外通常要特殊條件才能選擇 例如 Image grid 要有 image Map 要有地理座標 (P625) 這個範例中用了 `#defaultView:Map` 改變預設顯示模式 但是這個用法只在這個 Query Service 有用 在下一章節用程式 query 資料下來時是沒有差的 ## 在其他 wiki 裡使用 data > ### Parser function 這是最簡單的取用方法 不過相對的也靈活度比較低 格式 1. `{{#statements:<property>}}` 2. `{{#statements:<property>|from=<item>}}` 其中 `<property>` 可以是 id 或 label 例如要顯示李梅樹(Q700797)的出生地(P19) 可以用 `{{#statements:P19|from=Q700797}}` 或 `{{#statements:出生地|from=Q700797}}` ### Lua Modules 以維基百科為例,它提供了一些用 Lua 撰寫而成的 Module 利用這些 Module 我們就能在維基百科裡調用 Wikidata 的資料 > * [Wikipedia:Lua](https://en.wikipedia.org/wiki/Wikipedia:Lua) > * [Modules using data from wikidata](https://en.wikipedia.org/wiki/Category:Modules_using_data_from_Wikidata) > * [Calling Lua module](https://en.wikipedia.org/wiki/Help:Lua_for_beginners#Calling_a_Lua_module)

    Import from clipboard

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in via Google

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub

        Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully