过滤SPARQL查询的结果

时间:2016-05-28 19:02:24

标签: sparql

我想找回所有20世纪意大利小说家和#39;名称。 我写过:

SELECT ?label WHERE{ ?novelist a yago:ItalianNovelists. ?novelist rdfs:label ?label. FILTER (langMatches(lang(?label), "EN")) } ORDER BY ?label

如何过滤结果?

2 个答案:

答案 0 :(得分:1)

有几种选择。在这里我建议两个:

  1. 如果您可以依赖该分类,请使用模式?novelist dct:subject dbc:20th-century_novelists
  2. SELECT ?label 
    WHERE{
    ?novelist a yago:ItalianNovelists;
              rdfs:label ?label;
              dct:subject dbc:20th-century_novelists. 
    FILTER (langMatches(lang(?label), "EN"))
    }   
    ORDER BY ?label
    
    1. 定义出生范围或寿命范围。出生范围示例:
    2. SELECT ?label 
      WHERE{
      ?novelist a yago:ItalianNovelists;
                rdfs:label ?label;
                dbo:birthDate ?date.     
      BIND (YEAR(?date) AS ?year) 
      FILTER (langMatches(lang(?label), "EN"))
      FILTER (?year > 1882 && ?year < 1972)
      }
      ORDER BY ?label
      

      使用选项2,您将获得更多结果,但根据范围,他们可能包括20世纪未发表任何内容的小说家。

      第三种选择是按发布年份过滤。但是,我不推荐它。首先,它仅为那些在DBpedia中可获得此类信息的人提供结果,并且该子集很可能小于第一个选项中的那个。其次,根据你如何定义一个20世纪的小说家,查询结果将省略那些写于20世纪的小说,并于21世纪出版。

答案 1 :(得分:-2)

语言标记为小写,因此只需将<?php class Form extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper(array('form','url')); $this->load->library(array('session', 'form_validation', 'email')); } function index() { //set validation rules $this->form_validation->set_rules('username', 'username', 'required|min_length[5]|max_length[12]'); $this->form_validation->set_rules('email', 'Emaid ID', 'required|valid_email'); $this->form_validation->set_rules('text', 'text', 'required'); $this->form_validation->set_rules('topic', 'topic', 'required'); //run validation on form input if ($this->form_validation->run() == FALSE) { //validation fails $this->load->view('myform'); } else { //get the form data $name = $this->input->post('username'); $from_email = $this->input->post('email'); $subject = $this->input->post('topic'); $message = $this->input->post('text'); //set to_email id to which you want to receive mails $to_email = 'email@gmail.com'; //configure email settings $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_port'] = '465'; $config['smtp_user'] = 'email@gmail.com'; $config['smtp_pass'] = 'password'; $config['mailtype'] = 'html'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $config['newline'] = "\r\n"; //use double quotes //$this->load->library('email', $config); $this->email->initialize($config); //send mail $this->email->from($from_email, $name); $this->email->to($to_email); $this->email->subject($subject); $this->email->message($message); if ($this->email->send()) { // mail sent $this->session->set_flashdata('msg','<div class="alert alert-success text-center">Your mail has been sent successfully!</div>'); redirect('form/index'); } else { //error echo $this->email->print_debugger(); } } } } ?> 替换为"EN:即可。此外,我发现以下内容与使用"en"

一样有效
langMatches