搜尋食譜集

  1. 文字限制
  2. 語言限制
  3. 結構定義限制
  4. 中繼結構定義限制
  5. 評分和排名
  6. 其他限制

本頁列出各種食譜,說明如何使用 Search 服務限制搜尋查詢。

文字限制

Freebase 實體的文字資料首先來自名稱和別名,接著是鍵和其他文字屬性,最後則是 Wikipedia 錨點資料 (如果已與特定語言的 Wikipedia 主題完成比對)。

文字限制會因語言而異,目前支援 18 種語言。英文的涵蓋範圍最廣,也是預設語言。

如要查看目前支援的所有語言代碼清單,請前往下列網頁:

https://www.googleapis.com/freebase/v1/search?help=langs&indent=true

文字限制條件是使用 query 參數指定。語言是透過 lang 參數指定。例如:

query: "gore"
query: "gore" lang: "fr"
query: "gore" lang: "de"

在建立索引期間,系統會以特定語言的方式將文字資料正規化。舉例來說,在英文中,文字會轉換為小寫並移除重音符號。在查詢時,系統會對查詢文字執行相同的語言專屬正規化作業。例如:

query: "beyoncé"
query: "beyonce"

多個參數會控管文字限制的相符方式。將 prefixed 參數設為 true,只會觸發名稱和別名的前置字串比對 (以及其他文字資料的一般比對)。例如:

query: "bob dy" prefixed: true

stemmed 設為 true 只會對名稱和別名觸發詞幹比對 (對其他文字資料則會觸發一般比對)。詞幹比對可用於貼上因複數或其他文法形式而產生的語言專屬字尾差異。例如:

query: "potatos" stemmed: true

在查詢文字前後加上雙引號 ("") 會觸發詞組比對。查詢中的文字符記必須出現在相符實體的文字資料中,且彼此相鄰。例如:

query: "\"to be or not to be\""

使用 namealiastype 參數,比對名稱包含您要比對字詞的人員和人員實體。例如:

filter: "(all name:gore alias:gore type:/people/person)"

同樣地,以下範例只會比對相符的 /people/person 實體和 alias不會比對 name

filter: "(all (not name:gore) alias:gore type:/people/person)"

除了指定要比對的文字欄位,您也可以在運算元和文字欄位之間插入下列其中一個修飾符,指定比對方式:

  • {word}:要求字串中的字詞與文件中對應文字欄位的字詞相符。(預設)
  • {phrase}:要求文件中的對應文字欄位必須包含這些字詞,且順序相同。
  • {full}:類似 {phrase},但要求詞組必須與文字欄位完全相符,而不只是出現在文字欄位中。也就是完全相符。

舉例來說,如要尋找 Marc Broussard 的音樂單曲「Home」,請使用下列篩選條件:

filter: "(all type:/music/single name{full}:home /music/track/artist:"Marc Broussard")"

語言限制

如文字限制所述,lang 參數用於指定要使用哪些語言正規化規則,將文字轉換為查詢權杖。查詢語言也會影響結果排名,因為 freebase-search 會從相應語言的維基百科取得特定語言的關聯性信號。

目前支援九種語言:英文 (en)、西班牙文 (es)、法文 (fr)、德文 (de)、義大利文 (it)、葡萄牙文 (pt)、中文 (zh)、日文 (ja) 和韓文 (ko)。英文的涵蓋範圍最廣,也是預設語言。

同時使用多種語言搜尋

lang 參數接受以半形逗號分隔的語言代碼清單,系統會以所有指定的語言執行搜尋,並以清單中的第一個語言排序結果,然後以清單中第一個有實體名稱的語言顯示結果。

例如:

以下是在德文和法文中搜尋德文單字「Sonnenblume」的結果。系統會根據法文查詢字詞排序並顯示結果:

query: "Sonnenblume" lang: "fr,de"

以下是韓文電影的英文搜尋結果,顯示的名稱為韓文。查詢的英文部分是 expressed_by 限制中的「korean」一字:

filter: "(all expressed_by:korean type:/film/film)" lang: "ko,en"

結構定義限制

結構定義限制是透過 typedomain 參數指定。type 對應至實體的 /type/object/type 屬性值。

舉例來說,以下搜尋只會傳回使用者:

query: "gore" type: "/people/person"

domain 對應至實體所有 /type/object/type 值的 /type/type/domain 值。

舉例來說,以下程式碼會將搜尋範圍限制為 /film 網域中的法文實體:

query: "babar" domain: "/film" lang: "fr"

您也可以使用個別的 Freebase 屬性來篩選查詢。舉例來說,以下搜尋會將結果限制為來自加拿大的人:

 query "john" filter: "(all type:/people/person /people/person/nationality:"Canada")"

Metaschema 限制

Metaschema 限制會依語意述詞篩選實體。這些述詞是較高層級的概念,由描述類似語意關係的 Freebase 屬性集合建構而成。

中繼結構定義限制條件是使用 filter 參數運算元,並搭配實體名稱或 MID 限制條件指定。

支援的 Metaschema 篩選運算元

Freebase 搜尋支援下列 Metaschema 篩選器運算元。按一下表格中的連結,或使用 Freebase 搜尋範例應用程式,即可試用每個範例。

運算元名稱 範例
abstraction 「義大利寬麵」 (試試看。)
filter: "(all abstraction:fettuccine)"
abstraction_of 「class of the Western Bulwark locomotive」(試試看)
filter: "(all abstraction_of:"Western Bulwark")"
adaptation 「Works La Traviata is an adaptation of」(《茶花女》改編自) (試試看。)
filter: "(all adaptation_of:"La Traviata")"
administered_by 「坎城獎項」 (試試看。)
filter: "(all type:awards administered_by:cannes)"
administers 「誰經營 Synapse 報紙?」(試試看。)
filter: "(all administers:synapse)"
appears_in 「魔笛中的角色」 (試試看)
filter: "(all appears_in:"magic flute")"
「魔笛中的人物」試試看。
filter: "(all appears_in:"Die Zauberflöte")" lang: "de"
broader_than 「空巴 319 所屬的機型系列」 (試試看。)
filter: "(all broader_than:"Airbus A319")"
category 「french actresses」 (試試看。)
filter: "(all category:female origin:france notable:actor)"
「法國女演員」(變體) (試試看。)
filter: "(all category:female origin:france practitioner_of:actor)"
「加州或法國火山」 (試試看。)
filter: "(all category:volcano (any part_of:california part_of:france))"

「義大利麵」 (試試看。)

filter: "(all category:pasta)"
center 「在舊金山設有樞紐的航空公司」 (試試看。)
filter: "(all type:airline center:"San Francisco")"
"airlines with hubs in San Francisco and Atlanta" (Try it.)
filter: "(all type:airline center:"San Francisco" center:atlanta)"
「舊金山為中心的報紙」 (試試看。)
filter: "(all type:/book/newspaper center:/m/0d6lp)"
center_for 「舊金山 49 人隊的體育設施」 (試試看。)
filter: "(all center_for:"san francisco 49ers")"
certification 「文溫德斯執導的 R 級電影」 (試試看。)
filter: "(all type:/film/film contributor:wenders certification:r)"
character 「works which have Papageno as character」(以帕帕基諾為角色的作品) (試試看。)
filter: "(all character:papageno)"
child 「比爾柯林頓的父母」 (試試看。)
filter: "(all child:"bill clinton")"
contributed_to 「銀翼殺手的幕後工作人員有哪些?」 (試試看。)
filter: "(all contributed_to:"Blade Runner")"
contributor 「史蒂芬史匹柏的電影」 (試試看)
filter: "(all type:/film/film contributor:"Steven Spielberg")"
「史蒂芬史匹柏的電影」,使用 MID 而非貢獻者姓名。(試試看。)
filter: "(all type:/film/film contributor:/m/06pj8)"
「哈里遜福特演出的電影」 (試試看)
filter: "(all type:/film/film contributor:"Harrison Ford")"
created 「誰創作了《戰地鐘聲》」 (試試看。)
filter: "(all created:"for whom the bell tolls")"
created_by 「Google 軟體」 (試試看。)
filter: "(all notable:software created_by:google)"
discovered 「發現鐳的人」 (試試看。)
filter: "(all discovered:radium)"
discovered_by 「居禮的發現」 (試試看。)
filter: "(all discovered_by:curie)"
distributed_by 「NPR 節目」 (試試看。)
filter: "(all type:show distributed_by:npr)"
exhibited 「『不法之徒』是在哪裡上映的?」 (試試看。)
filter: "(all exhibited:"down by law")"
exhibited_at 「2010 年坎城影展入圍作品」 (試試看。)
filter: "(all type:"nominated work" exhibited_at:"2010 Cannes Film festival")"
expressed_by 「世界語書籍」 (試試看。)
filter: "(all type:book expressed_by:esperanto)"
fictional_link 「與米奇相關的虛構角色」 (試試看。)
filter: "(all type:/fictional_universe/fictional_character fiction_link:"mickey mouse")"
genre 「哥德式教堂」 (試試看。)
filter: "(all category:cathedral genre:gothic)"
「由維奧雷勒杜克設計的哥德式大教堂」 (試試看。)
filter: "(all category:cathedral genre:gothic created_by:viollet)"
identifies 「西南航空的識別代碼是什麼?」 (試試看。)
filter: "(all identifies:"Southwest Airlines")"
leader 「Mitch Kapor companies」(試試看。)
filter: "(all type:company leader:kapor)"
leader_of 「巴黎市長」 (試試看。)
filter: "(all title:mayor leader_of:paris)"
made_of 「蠟畫」 (試試看。)
filter: "(all type:painting made_of:wax)"
means_of_demise 「executed politicians」(遭處決的政治人物) (試試看。)
filter: "(all type:politician means_of_demise:"capital punishment")"
member_of 「african monarchs」(非洲君主) (試試看。)
filter: "(all type:monarch member_of:africa)"
「民主黨政治人物和知名演員」 (試試看。)
filter: "(all type:politician member_of:democratic notable:actor)"
narrower_than 「examples of v8 engines」(V8 引擎範例) (試試看。)
filter: "(all type:engine narrower_than:"v8 engine")"
occurs_in 「羅馬尼亞使用的語言」 (試試看。)
filter: "(all type:language occurs_in:romania)"
origin 「奧地利共和黨籍州長」 (試試看。)
filter: "(all title:governor member_of:republican origin:austria)"
owner 「makes owned by Ford」 (試試看。)
filter: "(all type:make owner:ford)"
owns 「誰是獨行俠隊的老闆?」 (試試看。)
filter: "(all owns:mavericks)"
parent 「Al Gore 的孩子」 (試試看。)
filter: "(all parent:"al gore")"
「Lisp 程式設計語言的後代」 (試試看。)
filter: "(all type:/computer/programming_language parent:lisp)"
part_of "swedish lakes" (試試看。)
filter: "(all type:lake part_of:sweden)"
「2008 年夏季奧運的賽事」 (試試看。)
filter: "(all type:competition part_of:"2008 summer olympics")"
participant 「Bowie 演唱會」 (試試看。)
filter: "(all participant:bowie type:concert)" 
participated_in 「參加奧運的知名奧地利滑雪選手」 (試試看。)
filter: "(all notable:skier member_of:austria participated_in:olympics)"'
peer_of "politicians peers of Al Gore" (Try it.)
filter: "(all notable:politician peer_of:gore)"
permits_use_of 「柴油引擎」 (試試看。)
filter: "(all permits_use_of:diesel)"
portrayed 「飾演約翰藍儂的演員」 (試試看。)
filter: "(all notable:actor portrayed:"john lennon")"
portrayed_by 「哈里遜福特飾演的角色」 (試試看。)
filter: "(all portrayed_by:"Harrison Ford")"
practitioner_of 「非裔美國女性律師」 (試試看。)
filter: "(all category:female category:"african american" practitioner_of:lawyer)"
preceeding 「魔戒雙城續集」 (試試看。)
filter: "(all type:/film/film preceeding:"The Lord of the Rings, the two Towers")"
produced_by 「Apple 電腦」 (試試看。)
filter: "(all type:computers produced_by:apple)"
publication 「which book has /m/0clw238 as first edition ?」(試試看。)
filter: "(all publication:/m/0clw238)"
publication_of 「La Traviata 的發行版本」 (試試看。)
filter: "(all publication_of:"La Traviata")"
service_area 「加州廣播公司」 (試試看。)
filter: "(all type:broadcaster service_area:california)"
status 「瑞士冰川退縮」 (試試看。)
filter: "(all type:glacier status:retreating part_of:switzerland)"
subclass_of 「kinds of swimwear」(泳衣種類) (試試看。)
filter: "(all subclass_of:swimwear)"
subject 「有關納粹大屠殺的電影」 (試試看。)
filter: "(all type:film subject:holocaust)"
「數學相關書籍」 (試試看。)
filter: "(all type:book subject:mathematics)"
subsequent 「魔戒雙城前傳」 (試試看。)
filter: "(all type:/film/film subsequent:"The Lord of the Rings, the two Towers")"
succeeded_by 「Which automotive platform was succeeded by the Ford B3 platform ?」(福特 B3 平台取代了哪個汽車平台?) (試試看。)
filter: "(all succeeded_by:"ford b3 platform")"
succeeds 「誰是斯圖亞特王朝的繼承者?」 (試試看。)
filter: "(all succeeds:stuart)"
superclass_of 「Classes coronary heart disease belongs to」(冠狀動脈心臟病所屬的類別) (試試看。)
filter: "(all superclass_of:"coronary heart disease")"
title 「Google 工程師」 (試試看。)
filter: "(all title:engineer member_of:google)"
tookplace_at 「在馬倫戈發生的戰役」 (試試看。)
filter: "(all type:battles tookplace_at:marengo)"
use_permitted_by 「iPhone 支援的檔案格式」 (試試看。)
filter: "(all type:"file format" use_permitted_by:iphone)"

評分和排名

Freebase 實體在建立索引時,會根據其在 Freebase 和維基百科中的連入和連出連結數量,計算出固有的關聯分數 (排名)。Google 也會計算部分熱門 Freebase 實體的熱門程度分數。根據預設,查詢時會合併這兩項分數。

如有文字限制,系統會根據搜尋索引傳回的命中次數計算文字相符分數,並與關聯性分數合併。

Freebase 搜尋結果一律會依最終分數排序,分數最高者優先顯示。

您可以透過評分參數,控管系統用來計算最終分數的關聯性分數元件:

freebase:僅使用 Freebase 關聯性分數。

query: "beyoncé" scoring: freebase

實體:使用兩個關聯性分數,將所有缺少的 Google 分數替換為 1.0。此為預設值。

query: "beyoncé" scoring: entity

結構定義:用於尋找結構定義實體,例如類型、屬性或網域。結構定義實體的連結計數計算方式不同。

query: "performance" scoring: schema

其他限制

您可以使用 with 或 without 參數,依索引標記篩選實體。實體會在建立索引時加上標記,每個標記對應一或多個 Freebase 查詢,這些查詢在搜尋期間執行會過於昂貴:

commons 標記可用於限制結構定義搜尋,只傳回 Freebase Commons 結構定義。舉例來說,與「顏色」一詞相符的 Freebase Commons 類型

query: "color" type: "/type/type" with: "commons"

gg 標記可用於將搜尋範圍限制在有或沒有 Google 熱門度分數的實體。

query: "1923" type: "/people/person" with: "gg"
query: "1923" type: "/people/person" without: "gg"

without 參數相當於篩選器運算式中以否定詞開頭的參數。

query: "color" limit: 5 type: "/type/type" without: "commons"
query: "color" limit: 5 type: "/type/type" filter: "(not with:commons)"