1 | <?php |
||
14 | class JenaTextSparql extends GenericSparql |
||
15 | { |
||
16 | /** |
||
17 | * How many results to ask from the jena-text index. jena-text defaults to |
||
18 | * 10000, but that is too little in some cases. |
||
19 | * See issue reports: |
||
20 | * https://code.google.com/p/onki-light/issues/detail?id=109 (original, set to 1000000000) |
||
21 | * https://github.com/NatLibFi/Skosmos/issues/41 (reduced to 100000 because of bad performance) |
||
22 | */ |
||
23 | private $MAX_N = 100000; |
||
24 | |||
25 | /* |
||
26 | * Characters that need to be quoted for the Lucene query parser. |
||
27 | * See http://lucene.apache.org/core/4_10_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters |
||
28 | */ |
||
29 | private $LUCENE_ESCAPE_CHARS = ' +-&|!(){}[]^"~?:\\/'; /* note: don't include * because we want wildcard expansion |
||
30 | |||
31 | /** |
||
32 | * Make a jena-text query condition that narrows the amount of search |
||
33 | * results in term searches |
||
34 | * |
||
35 | * @param string $term search term |
||
36 | * @param string $property property to search (e.g. 'skos:prefLabel'), or '' for default |
||
37 | * @return string SPARQL text search clause |
||
38 | */ |
||
39 | |||
40 | private function createTextQueryCondition($term, $property = '', $lang = '') |
||
61 | |||
62 | /** |
||
63 | * Generate jena-text search condition for matching labels in SPARQL |
||
64 | * @param string $term search term |
||
65 | * @param string $search_lang language code used for matching labels (null means any language) |
||
66 | * @return string sparql query snippet |
||
67 | */ |
||
68 | protected function generateConceptSearchQueryCondition($term, $search_lang) |
||
80 | |||
81 | /** |
||
82 | * Generates the jena-text-specific sparql query used for rendering the alphabetical index. |
||
83 | * @param string $letter the letter (or special class) to search for |
||
84 | * @param string $lang language of labels |
||
85 | * @param integer $limit limits the amount of results |
||
86 | * @param integer $offset offsets the result set |
||
87 | * @param array $classes |
||
88 | * @return string sparql query |
||
89 | */ |
||
90 | |||
91 | public function generateAlphabeticalListQuery($letter, $lang, $limit = null, $offset = null, $classes = null) |
||
135 | |||
136 | } |
||
137 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.