Help:数据类型

From Wikidata
Jump to navigation Jump to search
This page is a translated version of the page Help:Data type and the translation is 62% complete.
Outdated translations are marked like this.

数据类型(Data types)定义声明表现形式,以及他们所处理数据的类型。不同的声明类型使用不同的属性类型,并且他们也使用不同的数据类型。在属性创建时,其中一个选项便是设置数据类型,并且一旦设置,属性就被锁定为这种数据类型。这暗示他们可以用于何种情形,以及必须在实用属性可以定义前有数个计划。

Wikidata:Property proposal协调属性方面的工作。

Built-in data types
Data typeNumber of
properties
External identifier8,826
Item1,650
Quantity658
String333
URL110
Commons media file80
Point in time67
Monolingual text62
Property21
Geographic coordinates11
Tabular data6
Geographic shape3
Extra data types
Data typeNumber of
properties
Mathematical expression36
Sense19
Lexeme15
Form10
Musical Notation6


按类型排序的属性

For a list of the properties that currently require each type of data type, see either:

用于链接实体的数据类型

Wikidata has 5 types of entities (Item, Property, Lexeme, Sense and Form). For each entity type there exists a same-named data type that can be used to link entities of that type.

Item
链接到(list of properties)
Property
指向屬性的內部鏈接。 (list of properties)

The following data types are primarily meant for statements on Lexemes, which make up the lexicographical data of Wikidata.

Lexeme
链接到词位(list of properties)
Form
For statements on lexemes that reference forms on other lexemes in order to indicate their relation. (list of properties)
Sense
For statements on lexemes that reference senses on other lexemes. (list of properties)

基于字符串的数据类型

String

type: string (String)
list of properties: Category:Properties with string-datatype -- Special:ListProperties/string

不需要翻譯成不同語言或數字格式的字符鏈,數字和符號。 字符串不用於計算。

Examples:
  • B123
  • 90928390-XLE
  • u29238

维基数据中最长长度是1500字符,在InitialiseSettings.php中的wmgWikibaseStringLimits定义。

Monolingual text

type: monolingualtext (Monolingual text)
list of properties: Category:Properties with monolingualtext-datatype -- Special:ListProperties/monolingualtext

未翻譯為其他語言的字符串。 這種類型的字符串定義一次,並在所有語言中重複使用。 典型用途是使用當地語言編寫的地理位置實體名稱,某種標識符,化學式或拉丁學名。 有關可用於單語文本值的語言代碼以及如何請求支持其他語言代碼的信息,請參閱幫助:單語文本語言。(請注意,單語文本也意味著單個腳本系統,這可能會使字符串有些問題。

维基数据中最长长度是1500字符,在InitialiseSettings.php中的wmgWikibaseStringLimits定义。

External identifier

type: external-id (External identifier)
list of properties: Category:Properties with external-id-datatype -- Special:ListProperties/external-id

String that represents an identifier used in an external system. Will display as external link if a formatter URL (P1630) is defined. See: External identifiers.

维基数据中最长长度是1500字符,在InitialiseSettings.php中的wmgWikibaseStringLimits定义。

URL

type: url (URL)
list of properties: Category:Properties with url-datatype -- Special:ListProperties/url

一種通用的“網址”,用於標識某種外部資源,可能是某種外部網站的鏈接,或者是用於在某種專用資源中查找的標識符。

维基数据中最长长度是1500字符,在InitialiseSettings.php中的wmgWikibaseStringLimits定义。

引用維基共享資源檔案的數據類型

Commons media

type: commonsMedia (Commons media file)
list of properties: Category:Properties with commonsMedia-datatype -- Special:ListProperties/commonsMedia

參考維基共享資源上的文件。 在文本字段中輸入期間,將搜索共享上的“文件”命名空間以查找匹配的條目。 這些文件既可用於說明維基數據中的概念,也可用作包含在維基百科上的實際屬性值。

Examples:
  • Wikidata-logo.svg

Geographic shape

type: geo-shape (Geographic shape)
list of properties: Category:Properties with geo-shape-datatype -- Special:ListProperties/geo-shape

Reference to map data file on Wikimedia Commons. During entry in the textfield the "Data" namespace on Wikimedia Commons will be searched for matching entries.

Tabular data

type: tabular-data (Tabular data)
list of properties: Category:Properties with tabular-data-datatype -- Special:ListProperties/tabular-data

Reference to tabular data file on Wikimedia Commons. During entry in the textfield the "Data" namespace on Commons will be searched for matching entries.

特定表示法的數據類型

Mathematical expression

type: math (Mathematical expression)
list of properties: Category:Properties with math-datatype -- Special:ListProperties/math

显示为数学公式的格式化字符串。

Example:

\sqrt{1-e^2} produces:

See w:Help:Displaying a formula for applicable format.

Current limitation: input text can't be queried on Query Service.

Musical Notation

type: musical-notation (Musical Notation)
list of properties: Category:Properties with musical-notation-datatype -- Special:ListProperties/musical-notation

Generated image in .png format that displays a musical score. Values for that data type are strings describing music following LilyPond syntax.

示例:

\relative c' { c d e f | g2 g | a4 a a a | g1 |}, 产生
\relative c' { c d e f | g2 g | a4 a a a | g1 |}


其他数据类型

Quantity

type: quantity (Quantity)
list of properties: Category:Properties with quantity-datatype -- Special:ListProperties/quantity

A Quantity value represents a decimal number, together with information about the uncertainty interval of this number, and a unit of measurement. The attributes are:

  • 个:數量的主要價值
  • 下限:數量的下限(可選)
  • 上限:數量的上限(可選)
  • 單位:度量單位項(無量綱值為空)

Internally, amount, lower bound and upper bound are strings; positive numbers are stored with a plus sign, though this will not be displayed. The representation of a quantity may not be longer than 127 characters; therefore, the maximal value of a quantity is 10^126-1.

单位转换基于conversion to SI unit (P2370)实现。具有该属性的大多数单位在RDF导出的查询服务中已标准化(2019年10月)。

The normalisation table is readable as a JSON file in the WMF Mediawiki repository.

Examples:

:* 762(無量綱) :* 2500 km(未設置上限和下限,單位) :* 1.03±0.02 g(下限和上限,單位)

Time

type: time (Point in time)
list of properties: Category:Properties with time-datatype -- Special:ListProperties/time

此數據類型以格里高利或朱利安日曆存儲日期。查看詳細結構。

Examples:
  • 2012
  • 1780-05 (=1780年5月)
  • 1833-11-01 (=1833年11月1日)

请参阅Help:Dates了解更多。

Globe coordinate

type: globe-coordinate (Geographic coordinates)
list of properties: Category:Properties with globe-coordinate-datatype -- Special:ListProperties/globe-coordinate

一個地理位置(以給定星體的gms或十進制度的緯度 - 經度對給出)。星體默認為“地球”(globe: http://www.wikidata.org/entity/Q2)。“精度”參數描述了地理位置的分辨率。注意坐標系默認為“WGS84”(World Geodetic System 1984 (Q11902211)),它可能对地球以外的星體不適用,并且這不可更改。

Currently, the Web UI of Wikidata doesn't expose all parameters of this data type. The value is visualized only as the coordinate, plus an embedded map if the globe is Earth (Q2). The precision can be modified in the edit mode. The globe is not visible, nor editable, in the item view. The full configuration is however visible in the history diff view (example).

When using the Web UI, the value saved will be an exact multiple of the precision chosen.

It is possible to edit the data in full via API. The CLI tool is one way to access the API. In this example Olympus Mons (Q520) is given a coordinate on Mars (Q111) using the globe parameter (used in coordinate location (P625)):

wd ac Q520 P625 '{ "latitude": 18.4, "longitude": 226, "precision": 0.016666666666667, "globe": "http://www.wikidata.org/entity/Q111" }'

globe.js腳本增加了設置coordinate location (P625)的星體參數的用戶介面。

機器人,如LocatorBot等可能會發現coordinate location (P625)的星體參數未根据located on astronomical body (P376)設置。增加located on astronomical body (P376)并等待一個機器人來改正星體參數的作法可被接受。

技术细节

In the Wikibase JSON format each value is represented by "datatype": <datatype>, "datavalue": {"type": <type>, "value": ...}, where the representation of the value depends on the type.

In the RDF format data types are represented by the RDF name in the following table prefixed with http://wikiba.se/ontology# (or the wikibase: prefix in case of the RDF dumps). Note that this prefix is also available in the Wikidata query service, so for example ?prop wikibase:propertyType wikibase:String will return all properties of data type String.

NameJSON datatypeRDF nameJSON typeImplemented byLinks
wikibase-itemWikibaseItemwikibase-entityidbuilt-inlist, query
属性wikibase-propertyWikibasePropertywikibase-entityidbuilt-inlist, query
词位wikibase-lexemeWikibaseLexemewikibase-entityidWikibaseLexeme (Q28925815)list, query
义项wikibase-senseWikibaseSensewikibase-entityidWikibaseLexeme (Q28925815)list, query
词形wikibase-formWikibaseFormwikibase-entityidWikibaseLexeme (Q28925815)list, query
单语文本monolingualtextMonolingualtextmonolingualtextbuilt-inlist, query
字符串stringStringstringbuilt-inlist, query
外部标识符external-idExternalIdstringbuilt-inlist, query
URLurlUrlstringbuilt-inlist, query
共享资源媒体文件commonsMediaCommonsMediastringbuilt-inlist, query
地理形状geo-shapeGeoShapestringbuilt-inlist, query
表格数据tabular-dataTabularDatastringbuilt-inlist, query
数学表达式mathMathstringMath (Q21677559)list, query
音乐记谱法musical-notationMusicalNotationstringScore (Q21678392)list, query
数量quantityQuantityquantitybuilt-inlist, query
时间点timeTimetimebuilt-inlist, query
地理坐标globe-coordinateGlobecoordinateglobecoordinatebuilt-inlist, query

限制

  • Point in time doesn't support time of day. phab:T57755
  • Quantity 不支持 infinity (Q205),也就是你不能陈述 prime number (Q49008)quantity (P1114)无穷大

等待中的数据类型

For none of the following dates of implementation are likely to be available. Existing datatypes may solve it in the meantime.

参见:维基数据:开发计划

待完成

持续时间

HH:MM:SS格式的时间。

待计划

计算属性

A property calculated by Wikibase and added directly to items. Not in development plan.

可能的用途:项的声称数量。

天空坐标

A coordinate format for specifying positions of celestial objects. Not in development plan.

整数数据类型

正整數的數量類型。

单一字符串项

A datatype allowing descriptions in any language, but a single label. Not in development plan.

Current alternatives: lexemes

Alternative that is being evaluated: multilingual label replacing repeated labels

多语文本

A string that must be translated into other languages. Use might be an entity name on non-local form, that is translated into various languages and script systems. (Note that multilingual text also imply a lot of manual work during translation.). Actual purpose to be determined.

多行文本

可包含换行的字符串。

远程属性

Properties in remote repositories are likely to be identified through a special field on existing entities, not a separate datatype.

值序列

A simplified way to store series of values for different points in time. Not in development plan.

國際象棋

Display strings in FEN notation as in position in Forsyth-Edwards Notation (P6648) directly as chessboards.

Hiero

Strings for display with WikiHiero. Strings in WikiHiero syntax are embedded in <hiero></hiero> to display. Samples on Talk:Q68101340 and Property_talk:P7383.

Phab request to do.

Combined human-readable and numeric id

Datatype to add numeric id and page title, e.g. of a MediaWiki page. Qualifier MediaWiki page ID (P9675) is sometimes added to property value with page titles. Some properties use the numeric value directly.

Wikibase 声明

用于引用一个特定维基数据声明的数据类型。

正则表达式

Datatype to store regular expressions (regex). These are currently stored as strings or monolingual text, e.g. format as a regular expression (P1793), format as language specific regular expression (P8770).

IP地址范围

Datatype to store address ranges and simplify querying them.

永遠不會被實行的資料型態

布尔值

已拒绝。建议的替代方案:项-数据类型。

改变数据类型

A property in "string" datatype may be converted to "external identifier" datatype by a system administrator. To propose such a change, you may start a discussion at the talk page of the property or Project chat. After a consensus, a request may be made in Contact the development team. You should read previous discussion if you want to convert a property created before 2016.

Other changes of data type requires creating a new property and deleting the old one. You should use Properties for deletion for such requests.

参见