test.url=https://knowledgestore2.fbk.eu/nwr/wikinews/
#test.username=NO_USERNAME_REQUIRED
#test.password=NO_PASSWORD_REQUIRED

test.data=parameters.tsv.gz
test.queries=sparql1,sparql2,sparql3,sparql4,sparql5,sparql6,sparql7,sparql8,sparql9,sparql10,sparql11,sparql12,rmlookup,download
test.out=trace.tsv.gz
test.seed=0

test.clients=16
test.warmupmixes=10000
test.warmuptime=30
test.testmixes=20000
test.testtime=180
test.timeout=30000

sparql1.type=sparql
sparql1.label=Actors of a specified type (1. actors_of_a_type)
sparql1.comment=\
  Retrieves URI, number of participated events and optional DBpedia \
  description of actors participating at least to an event and having a \
  specific ${actor_type} and whose name (from DBpedia or text) contains \
  term ${actor_term}. Results sorted by number of participated events. \
  Only first page of 20 results returned. \
    ${actor_type}  the actor type, from DBpedia (URI) \
    ${actor_term}  a term in the actor name (plain literal)
sparql1.query=\
  SELECT ?actor (COUNT(DISTINCT ?event) AS ?count) ?comment \
  WHERE { \
    ?event sem:hasActor ?actor . \
    ?g1 dct:source <http://dbpedia.org/> \
    GRAPH ?g1 { ?actor a ${actor_type} } \
    ?g2 dct:source <http://dbpedia.org/> \
    GRAPH ?g2 { \
      ?actor rdfs:label ?label . \
      ?label bif:contains ${actor_term} \
    } \
    OPTIONAL { ?actor rdfs:comment ?comment } \
  } \
  GROUP BY ?actor ?comment \
  ORDER BY desc(?count) \
  LIMIT 20

sparql2.type=sparql
sparql2.label=Get a property of actors of a type mentioned in the news (10. property_of_actors_of_a_type)
sparql2.comment=\
  Retrieves URI and value of a specified ${actor_property} for all the \
  event actors of the ${actor_type} specified and whose name (from \
  DBpedia or text) contains term ${actor_term}. Result sorted by \
  property value. Only first page of 20 results returned. \
    ${actor_type}      the actor type, from DBpedia (URI) \
    ${actor_property}  the actor property, from DBpedia (URI) \
    ${actor_term}      a term in the actor name (plain literal)
sparql2.query=\
  SELECT DISTINCT ?actor ?value \
  WHERE { \
    ?event sem:hasActor ?actor . \
    ?actor a ${actor_type} . \
    ?actor ${actor_property} ?value . \
    ?actor rdfs:label ?label . \
    ?label bif:contains ${actor_term} . \
  } \
  ORDER BY DESC(?value) \
  LIMIT 20

sparql3.type=sparql
sparql3.label=Frequency of event labels in events (4. event_label_frequency_count)
sparql3.comment=\
  Retrieves the number of events for each event label that matches the \
  ${event_term} specified. Results sorted by decreasing number of \
  events. Only first page of 20 results returned. \
    ${event_term}  a term in the event label (plain literal)
sparql3.query=\
  SELECT ?event_label (COUNT(DISTINCT ?event) AS ?count) \
  WHERE { \
    ?event a sem:Event . \
    ?event rdfs:label ?event_label . \
    ?event_label bif:contains ${event_term} \
  } \
  GROUP BY ?event_label \
  ORDER by desc(?count) \
  LIMIT 20

sparql4.type=sparql
sparql4.label=Get events mentioning a named actor (12. summary_of_events_with_actor)
sparql4.comment=\
  Returns URI, number of associated triples, date and label for each \
  event involving the ${actor} specified and occurred in the ${year} \
  given. Results sorted by event date. Only first page of 20 results \
  returned. \
    ${actor}       the actor (URI) \
    ${event_year}  the event year (xsd:int literal)
sparql4.query=\
  SELECT ?event (COUNT(*) AS ?event_size) ?datetime ?event_label \
  WHERE { \
    { \
      SELECT DISTINCT ?event ?datetime ?event_label \
      WHERE { \
        { ?event sem:hasActor ${actor} } UNION { ?event sem:hasPlace ${actor} } \
        ?event rdfs:label ?event_label . \
        ?event sem:hasTime ?t . \
        ?t owltime:inDateTime ?d . \
        ?d owltime:year ${event_year} . \
        ?d rdfs:label ?datetime . \
      } \
      ORDER BY ?datetime \
      LIMIT 20 \
    } \
    ?event ?p ?o . \
  } \
  GROUP BY ?event ?datetime ?event_label \
  ORDER BY ?datetime

sparql5.type=sparql
sparql5.label=Get events mentioning two named actors (17. summary_of_events_with_two_actors)
sparql5.comment=\
  Returns URI, number of associated triples, date and label for each \
  event involving both ${actor} and ${actor_related} and occurred in \
  the given ${year}. Results sorted by event date. Only first page of \
  20 results returned. \
    ${actor}          the first actor (URI) \
    ${actor_related}  the second actor (URI) \
    ${event_year}     the event year (xsd:int literal)
sparql5.query=\
  SELECT ?event (COUNT(*) AS ?event_size) ?datetime ?event_label \
  WHERE { \
    { \
      SELECT DISTINCT ?event ?datetime ?event_label \
      WHERE { \
        ?event sem:hasActor ${actor} . \
        ?event sem:hasActor ${actor_related} . \
        ?event sem:hasTime ?t . \
        ?event rdfs:label ?event_label . \
        ?t owltime:inDateTime ?d . \
        ?d owltime:year ${event_year} . \
        ?d rdfs:label ?datetime . \
      } \
      ORDER BY ?datetime \
      LIMIT 20 \
    } \
    ?event ?p ?o \
  } \
  GROUP BY ?event ?datetime ?event_label \
  ORDER BY ?datetime

sparql6.type=sparql
sparql6.label=Get events mentioning a type of actor (13. summary_of_events_with_actor_type)
sparql6.comment=\
  Returns URI, number of associated triples, date and associated actor \
  URIs for each event involving actors of a specific ${actor_type} and \
  occurred in the given ${year}. Results are sorted by event date. Only \
  first page of 20 events is returned. \
    ${actor_type}     the actor type (URI) \
    ${event_year}     the event year (xsd:int literal)
sparql6.query=\
  SELECT ?event (COUNT (*) AS ?event_size) ?datetime ?actor \
  WHERE { \
    { \
      SELECT DISTINCT ?event ?datetime ?actor \
      WHERE { \
        ?event sem:hasTime ?t . \
        { ?event sem:hasActor ?actor } UNION { ?event sem:hasPlace ?actor  } \
        ?actor a ${actor_type} . \
        ?t owltime:inDateTime ?d . \
        ?d owltime:year ${event_year} . \
        ?d rdfs:label ?datetime . \
      } \
      ORDER BY ?datetime \
      LIMIT 20 \
    } \
    ?event ?p ?o . \
  } \
  GROUP BY ?event ?datetime ?actor \
  ORDER BY ?datetime

sparql7.type=sparql
sparql7.label=Search for events with a specified label (15. summary_of_events_with_event_label)
sparql7.comment=\
  Returns URI, number of associated triples, date and label of events \
  occurred in the ${event_year} given and whose label includes the \
  ${event_term} specified. Results are sorted by event date. Only first \
  page of 20 results is returned. \
    ${event_term}  a term in the event label (plain literal) \
    ${event_year}  the event year (xsd:int literal)
sparql7.query=\
  SELECT ?event (COUNT(*) AS ?event_size) ?datetime ?event_label \
  WHERE { \
    { \
      SELECT DISTINCT ?event ?datetime ?event_label \
      WHERE { \
        ?event sem:hasTime ?t . \
        ?event rdfs:label ?event_label . \
        ?event_label bif:contains ${event_term} . \
        ?t owltime:inDateTime ?d . \
        ?d owltime:year ${event_year} . \
        ?d rdfs:label ?datetime . \
      } \
      ORDER BY ?datetime \
      LIMIT 20 \
    } \
    ?event ?p ?o \
  } \
  GROUP BY ?event ?datetime ?event_label \
  ORDER BY ?datetime

sparql8.type=sparql
sparql8.label=Get events with a specific eso value (14. summary_of_events_with_eso) + Get events with a specific framenet value (16. summary_of_events_with_framenet)
sparql8.comment=\
  Returns URI, number of associated triples, date and label of events \
  having a certain ${event_type}, occurred in the ${event_year} given \
  and whose label contains the ${event_term} supplied. Results are \
  sorted by event date. Only the first page of 20 results is returned. \
    ${event_type}  the event type (URI) \
    ${event_term}  a term in the event label (plain literal) \
    ${event_year}  the event year (xsd:int literal)
sparql8.query=\
  SELECT ?event (COUNT(*) AS ?event_size) ?datetime ?event_label \
  WHERE { \
    { \
      SELECT DISTINCT ?event ?datetime ?event_label \
      WHERE { \
        ?event a sem:Event . \
        ?event rdfs:label ?event_label . \
        ?event rdf:type ${event_type} . \
        ?event_label bif:contains ${event_term} . \
        ?event sem:hasTime ?t . \
        ?t owltime:inDateTime ?d . \
        ?d owltime:year ${event_year} . \
        ?d rdfs:label ?datetime . \
      } \
      ORDER BY ?datetime \
      LIMIT 20 \
    } \
    ?event ?p ?o . \
  } \
  GROUP BY ?event ?datetime ?event_label \
  ORDER BY ?datetime

sparql9.type=sparql
sparql9.label=Get event precis (5. event_precis)
sparql9.comment=\
  Returns an RDF description (made of subject, predicate, object, graph \
  quads) of a certain ${event}. The description includes the event \
  actors, place, time and number of mentioning documents. \
    ${event}  the event (URI)
sparql9.query=\
  SELECT DISTINCT ?subject ?predicate ?object ?graph \
  WHERE { \
    { \
      ${event} eso:hasPreSituation|eso:hasPostSituation|eso:hasDuringSituation ?graph . \
      GRAPH ?graph { ?subject ?predicate  ?object . } \
    } UNION { \
      BIND (${event} as ?subject) \
      { \
        GRAPH ?graph { ${event} ?predicate ?object } \
        FILTER (?predicate = sem:hasActor || \
                ?predicate = sem:hasPlace || \
                ?predicate = rdf:type && EXISTS { ?object rdfs:isDefinedBy eso: } || \
                EXISTS { ?predicate rdfs:isDefinedBy eso: } ) \
      } UNION { \
        GRAPH ?graph { ${event} sem:hasTime ?t } \
        ?t owltime:inDateTime ?object . \
        BIND (nwr:cleanedTime as ?predicate) \
      } UNION { \
        SELECT (<ex:numDocuments> AS ?predicate) (COUNT(DISTINCT STRBEFORE(STR(?mention), "#")) AS ?object) \
        WHERE { ${event} gaf:denotedBy ?mention } \
      } \
    } \
  }

sparql10.type=sparql
sparql10.label=Details of a URI returned by the DESCRIBE query (2. describe)
sparql10.comment=\
  Returns an RDF description of an event ${actor} (obtained using a \
  SPARQL DESCRIBE). \
    ${actor}  the actor (URI)
sparql10.query=\
  DESCRIBE ${actor}

sparql11.type=sparql
sparql11.label=People who share an event with a named person (8. people_sharing_event_with_a_person)
sparql11.comment=\
  Returns URI, number of events in common and optional DBpedia comment \
  of other actors that share an event with a specified ${actor}. \
  Results are sorted by number of events in common. Only the first page \
  of 20 results is returned. \
    ${actor}  the actor (URI)
sparql11.query=\
  SELECT (${actor} AS ?actor) ?actor2 (COUNT(DISTINCT ?event) as ?numEvent) ?comment \
  WHERE { \
    ?event sem:hasActor ${actor} , ?actor2 . \
    ?actor2 a dbo:Person . \
    FILTER(?actor2 != ${actor}) \
    OPTIONAL { ?actor2 rdfs:comment ?comment } \
  } \
  GROUP BY ?actor2 ?comment \
  ORDER BY DESC(?numEvent) \
  LIMIT 20

sparql12.type=sparql
sparql12.label=Event details for events involving a specified actor (3. event_details_filtered_by_actor)
sparql12.comment=\
  Return predicate/object/object type properties of events participated \
  by a certain ${actor}. Results are sorted by event URI. Only results \
  for the first 20 events participated by the actor are returned. \
    ${actor}  the actor (URI)
sparql12.query=\
  SELECT ?event ?predicate ?object (SAMPLE(?type) AS ?object_type) \
  WHERE { \
    { \
      SELECT DISTINCT ?event \
      WHERE { \
        ?event sem:hasActor ${actor} . \
      } \
      ORDER BY DESC(?event) \
      LIMIT 20 \
    } \
    ?event ?predicate ?object . \
    OPTIONAL { \
      ?object a ?type . \
      FILTER ( ?type = sem:Actor || ?type = sem:Place || \
               ?type = sem:Time  || ?type = sem:Event ) \
    } \
  } \
  GROUP BY ?event ?predicate ?object \
  ORDER BY DESC(?event) ?predicate ?object

rmlookup.type=lookupall
rmlookup.label=Get document metadata (6. get_document_metadata) + Get mention metadata (7. get_mention_metadata)
rmlookup.comment=\
  Returns the RDF description of a certain ${resource} with all its \
  mentions) \
    ${resource}  the resource (URI)
rmlookup.layer=ks:Mention
rmlookup.id=${resource}

download.type=download
download.label=Download news article (not in the Simple API due to copyright restrictions)
download.comment=\
  Downloads the raw text of a specific ${resource}. \
    ${resource}  the resource (URI)
download.id=${resource}

rlookup.type=lookup
rlookup.label=get_document_metadata
rlookup.comment=\
  Returns the RDF description of a certain ${resource} (e.g., title, \
  author, date and recognized entity/event mentions). \
    ${resource}  the resource (URI)
rlookup.layer=ks:Resource
rlookup.id=${resource}

mlookup.type=lookup
mlookup.label=get_mention_metadata
mlookup.comment=\
  Returns the RDF description of a certain ${mention} (e.g., extent, \
  position in the text, NLP attributes) \
    ${mention}  the mention (URI)
mlookup.layer=ks:Mention
mlookup.id=${mention}
