Freebase MQL查询问题

时间:2013-05-14 20:19:08

标签: freebase

下面是我的查询代码..我正在尝试将几种类型放在一起以获得一个查询来构建一组数据...但查询不能从php工作,它确实在查询编辑器内工作freebase.com

    <?php

function getQuery($type,$id=null){
    //leaves off closing so you can return and append to the end of everything following...
    $query = "[{
        \"type\":\"$type\",
        \"limit\":10,
        \"id\":null,
        \"name\":null,";

    return $query;
}

function getSportsTeamsStructure(){

    $query = "\"/sports/sports_team/sport\":null,";
    $query .="\"/sports/sports_team/league\":[{\"team\":null,\"league\":null,\"from\":null,\"to\":null}],";
    $query .="\"/sports/sports_team/location\":[{".getLocationStructure()."}],";
    $query .="\"/sports/sports_team/founded\":null,";
    $query .="\"/sports/sports_team/arena_stadium\":[{".getArchitectureStructure()."}],";
    $query .="\"/sports/sports_team/colors\":[{}],";
    $query .="\"/sports/sports_team/team_mascot\":[{}],";
    $query .="\"/sports/sports_team/championships\":[{}],";
    $query .="\"/sports/sports_team/fight_song\":[{}],";
    $query .="\"/sports/sports_team/roster\":[{\"position\":[{}],\"team\":[{}],\"number\":[],\"from\":null,\"to\":null}],";
    $query .="\"/sports/sports_team/coaches\":[{\"position\":[{}],\"from\":null,\"to\":null,\"team\":[{}],\"coach\":[{}]}]";
    return $query;
}
function getPeoplePersonStructure(){
    $query = '';
    $query .= "\"/people/person/date_of_birth\":null,";
    $query .="\"/people/person/place_of_birth\":null,";
    $query .="\"/people/person/nationality\":null,";
    $query .="\"/people/person/gender\":null,";
    $query .="\"/people/person/profession\":[{}],";
    $query .="\"/people/person/religion\":[{}],";
    $query .="\"/people/person/ethnicity\":[{}],";
    $query .="\"/people/person/parents\":[{}],";
    $query .="\"/people/person/children\":[{}],";
    $query .="\"/people/person/sibling_s\":[{}],";
    $query .="\"/people/person/spouse_s\":[{}],";
    $query .="\"/people/person/height_meters\":null,";
    $query .="\"/people/person/weight_kg\":null,";
    $query .="\"/people/person/education\":[{}],";
    $query .="\"/people/person/age\":[{}],";
    $query .="\"/people/person/notable_professions\":[{}],";
    $query .="\"/people/person/languages\":[{}]";

    return $query;

}
function getCommonTopicStructure(){

    $query = '';
    $query .="\"/common/topic/image\":[{}],";
    $query .="\"/common/topic/article\":[{}],";
    $query .="\"/common/topic/notable_for\":[],";
    $query .="\"/common/topic/notable_types\":[],";
    $query .="\"/common/topic/alias\":[],";
    $query .="\"/common/topic/description\":[],";
    $query .="\"/common/topic/official_website\":[],";
    $query .="\"/common/topic/topic_equivalent_webpage\":[],";
    $query .="\"/common/topic/subjects\":[],";
    $query .="\"/common/topic/subject_of\":[],";
    $query .="\"/common/topic/weblink\":[],";
    $query .="\"/common/topic/social_media_presence\":[{}]";
    return $query;
}
function getArchitectureStructure(){
    $query = '';
    $query = "\"/architecture/structure/architect\":[{".getPeoplePersonStructure()."}],";
    $query = "\"/architecture/structure/architectural_style\":[],";
    $query .="\"/architecture/structure/owner\":[{}],";
    $query .="\"/architecture/structure/architecture_firm\":[{}],";
    $query .="\"/architecture/structure/height_meters\":null,";
    $query .="\"/architecture/structure/construction_cost\":null,";
    $query .="\"/architecture/structure/destruction_date\":null,";
    $query .="\"/architecture/structure/destroyed_by\":null,";
    $query = "\"/architecture/structure/address\":[{".getMailingAddressStructure()."}],";
    $query .="\"/architecture/venue/capacity\":null";

    return $query;

}
function getLocationStructure(){
    $query = '';
    $query .= "\"/location/location/geolocation\":[{\"id\":null,\"longitude\":null,\"latitude\":null,\"daturn\":null,\"elevation\":null}],";
    $query .= "\"/location/location/contains\":[{}],";
    $query .="\"/location/location/containedby\":[{}],";
    $query .="\"/location/location/adjoin_s\":[{}],";
    $query .= "\"/location/location/area\":null,";
    $query .="\"/location/location/time_zones\":[{}],";
    $query .= "\"/location/location/people_born_here\":[{}],";
    $query .= "\"/location/location/events\":[{}],";
    $query .="\"/location/location/nearby_airports\":[{}],";
    $query .="\"/location/location/near\":[{}],";
    $query .="\"/location/location/street_address\":{{".getMailingAddressStructure()."}],";
    return $query;

}
function getMailingAddressStructure(){
    $query = '';
    $query = "\"street_address\":null,\"street_address_2\":null,\"citytown\":null,\"state_province_region\":null,\"postal_code\":null,\"country\":null";
    return $query;

}
?>

0 个答案:

没有答案