|
|
@@ -1,172 +1,314 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<!-- EN-Revision: 18739 -->
|
|
|
+<!-- Reviewed: no -->
|
|
|
<sect1 id="zend.search.lucene.extending">
|
|
|
- <title>Extensibilidade</title>
|
|
|
-
|
|
|
- <sect2 id="zend.search.lucene.extending.analysis">
|
|
|
- <title>Análise de Texto</title>
|
|
|
-
|
|
|
- <para>A classe <code>Zend_Search_Lucene_Analysis_Analyzer</code> class é
|
|
|
- usada pelo indexador para "tokenizar" campos de documentos de
|
|
|
- texto.</para>
|
|
|
-
|
|
|
- <para>Os métodos
|
|
|
- <code>Zend_Search_Lucene_Analysis_Analyzer::getDefault()</code> e
|
|
|
- <code>Zend_Search_Lucene_Analysis_Analyzer::setDefault()</code> são usados
|
|
|
- para obter e setar, respectivamente, o analisador padrão.</para>
|
|
|
-
|
|
|
- <para>Dessa forma você pode estipular o seu próprio analisador de textos
|
|
|
- ou selecioná-lo dentre uma lista de analisadores prédefinidos:
|
|
|
- <code>Zend_Search_Lucene_Analysis_Analyzer_Common_Text</code> e
|
|
|
- <code>Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive</code>
|
|
|
- (default). Ambos interpretam um "token" como uma sequencia de letras.
|
|
|
- <code>Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive</code>
|
|
|
- converte os "tokens" para caixa baixa.</para>
|
|
|
-
|
|
|
- <para>Para selecionar um analisador utilize o código:</para>
|
|
|
-
|
|
|
- <programlisting role="php"><?php
|
|
|
-
|
|
|
+ <title>Extensibilidade</title>
|
|
|
+
|
|
|
+ <sect2 id="zend.search.lucene.extending.analysis">
|
|
|
+ <title>Análise de Texto</title>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ A classe <classname>Zend_Search_Lucene_Analysis_Analyzer</classname> é usada pelo
|
|
|
+ indexador para "tokenizar" campos de documentos de texto.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Os métodos <methodname>Zend_Search_Lucene_Analysis_Analyzer::getDefault()</methodname> e
|
|
|
+ <code>Zend_Search_Lucene_Analysis_Analyzer::setDefault()</code> são usados para obter e
|
|
|
+ setar, respectivamente, o analisador padrão.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Você pode estipular o seu próprio analisador de textos ou selecioná-lo dentre uma lista
|
|
|
+ de analisadores prédefinidos:
|
|
|
+ <classname>Zend_Search_Lucene_Analysis_Analyzer_Common_Text</classname> e
|
|
|
+ <classname>Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive</classname>
|
|
|
+ (padrão). Ambos interpretam os "tokens" como sequencias de letras.
|
|
|
+ <classname>Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive</classname>
|
|
|
+ converte todos os "tokens" para caixa baixa.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Para selecionar um analisador:
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
Zend_Search_Lucene_Analysis_Analyzer::setDefault(
|
|
|
new Zend_Search_Lucene_Analysis_Analyzer_Common_Text());
|
|
|
...
|
|
|
-$index->addDocument($doc);
|
|
|
-
|
|
|
-?></programlisting>
|
|
|
-
|
|
|
- <para><code>Zend_Search_Lucene_Analysis_Analyzer_Common</code> foi
|
|
|
- projetado ser o pai de todos os analisadores definidos pelo usuário. O
|
|
|
- usuário só precisa definir o método <code>tokenize()</code>, que receberá
|
|
|
- os dados de entrada como uma string e retornará um array de
|
|
|
- "tokens".</para>
|
|
|
-
|
|
|
- <para>O método <code>tokenize()</code> deve aplicar o método
|
|
|
- <code>normalize()</code> a todos os "tokens". Ele permite o uso de filtros
|
|
|
- de "token" junto com o seu analisador.</para>
|
|
|
-
|
|
|
- <para>Aqui está um exemplo de um analisador customizado, que aceita tanto
|
|
|
- palavras contendo digitos tratando-as como um único termo: <example>
|
|
|
- <title>Analisador de texto customizado.</title>
|
|
|
-
|
|
|
- <programlisting role="php"><?php
|
|
|
-/** Here is a custome text analyser, which treats words with digits as one term */
|
|
|
-
|
|
|
-
|
|
|
-/** Zend_Search_Lucene_Analysis_Analyzer_Common */
|
|
|
-require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php';
|
|
|
+$index->addDocument($doc);
|
|
|
+]]></programlisting>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ A classe <classname>Zend_Search_Lucene_Analysis_Analyzer_Common</classname> foi
|
|
|
+ projetada para ser um antepassado de todos os analisadores definidos pelo usuário. O
|
|
|
+ usuário só precisa definir os métodos <methodname>reset()</methodname> e
|
|
|
+ <methodname>nextToken()</methodname>, que receberá a string do membro $_input e
|
|
|
+ retornará os "tokens" um por um (um valor <constant>NULL</constant> indica o fim do
|
|
|
+ fluxo).
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ O método <methodname>nextToken()</methodname> deve chamar o método
|
|
|
+ <methodname>normalize()</methodname> em cada "token". Isso te permite usar filtros de
|
|
|
+ "token" junto com o seu analisador.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Aqui está um exemplo de um analisador customizado, que aceita palavras contendo dígitos
|
|
|
+ como termos:
|
|
|
+
|
|
|
+ <example id="zend.search.lucene.extending.analysis.example-1">
|
|
|
+ <title>Analisador de Texto Customizado</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+/**
|
|
|
+ * Here is a custom text analyser, which treats words with digits as
|
|
|
+ * one term
|
|
|
+ */
|
|
|
|
|
|
class My_Analyzer extends Zend_Search_Lucene_Analysis_Analyzer_Common
|
|
|
{
|
|
|
+ private $_position;
|
|
|
+
|
|
|
/**
|
|
|
- * Tokenize text to a terms
|
|
|
- * Returns array of Zend_Search_Lucene_Analysis_Token objects
|
|
|
+ * Reset token stream
|
|
|
+ */
|
|
|
+ public function reset()
|
|
|
+ {
|
|
|
+ $this->_position = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Tokenization stream API
|
|
|
+ * Get next token
|
|
|
+ * Returns null at the end of stream
|
|
|
*
|
|
|
- * @param string $data
|
|
|
- * @return array
|
|
|
+ * @return Zend_Search_Lucene_Analysis_Token|null
|
|
|
*/
|
|
|
- public function tokenize($data)
|
|
|
+ public function nextToken()
|
|
|
{
|
|
|
- $tokenStream = array();
|
|
|
+ if ($this->_input === null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- $position = 0;
|
|
|
- while ($position < strlen($data)) {
|
|
|
+ while ($this->_position < strlen($this->_input)) {
|
|
|
// skip white space
|
|
|
- while ($position < strlen($data) && !ctype_alpha($data{$position}) && !ctype_digit($data{$position})) {
|
|
|
- $position++;
|
|
|
+ while ($this->_position < strlen($this->_input) &&
|
|
|
+ !ctype_alnum( $this->_input[$this->_position] )) {
|
|
|
+ $this->_position++;
|
|
|
}
|
|
|
|
|
|
- $termStartPosition = $position;
|
|
|
+ $termStartPosition = $this->_position;
|
|
|
|
|
|
// read token
|
|
|
- while ($position < strlen($data) && (ctype_alpha($data{$position}) || ctype_digit($data{$position}))) {
|
|
|
- $position++;
|
|
|
+ while ($this->_position < strlen($this->_input) &&
|
|
|
+ ctype_alnum( $this->_input[$this->_position] )) {
|
|
|
+ $this->_position++;
|
|
|
}
|
|
|
|
|
|
// Empty token, end of stream.
|
|
|
- if ($position == $termStartPosition) {
|
|
|
- break;
|
|
|
+ if ($this->_position == $termStartPosition) {
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
- $token = new Zend_Search_Lucene_Analysis_Token(substr($data,
|
|
|
+ $token = new Zend_Search_Lucene_Analysis_Token(
|
|
|
+ substr($this->_input,
|
|
|
$termStartPosition,
|
|
|
- $position-$termStartPosition),
|
|
|
+ $this->_position -
|
|
|
+ $termStartPosition),
|
|
|
$termStartPosition,
|
|
|
- $position);
|
|
|
- $tokenStream[] = $this->normalize($token);
|
|
|
+ $this->_position);
|
|
|
+ $token = $this->normalize($token);
|
|
|
+ if ($token !== null) {
|
|
|
+ return $token;
|
|
|
+ }
|
|
|
+ // Continue if token is skipped
|
|
|
}
|
|
|
|
|
|
- return $tokenStream;
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Zend_Search_Lucene_Analysis_Analyzer::setDefault(
|
|
|
new My_Analyzer());
|
|
|
-
|
|
|
-?></programlisting>
|
|
|
- </example></para>
|
|
|
- </sect2>
|
|
|
-
|
|
|
- <sect2 id="zend.search.lucene.extending.scoring">
|
|
|
- <title>Algoritmos de Pontuação</title>
|
|
|
-
|
|
|
- <para>A pontuação da consulta <code>q</code> para o documento
|
|
|
- <code>d</code> é definida como segue:</para>
|
|
|
-
|
|
|
- <para><code>score(q,d) = sum( tf(t in d) * idf(t) * getBoost(t.field in d)
|
|
|
- * lengthNorm(t.field in d) ) * coord(q,d) * queryNorm(q)</code></para>
|
|
|
-
|
|
|
- <para>tf(t in d) -
|
|
|
- <code>Zend_Search_Lucene_Search_Similarity::tf($freq)</code> - um fator de
|
|
|
- pontuação baseado na frequência de um termo ou frase em um
|
|
|
- documento.</para>
|
|
|
-
|
|
|
- <para>idf(t) -
|
|
|
- <code>Zend_Search_Lucene_Search_SimilaritySimilarity::tf($term,
|
|
|
- $reader)</code> - um fator de pontuação para um termo simples para o
|
|
|
- índice especificado.</para>
|
|
|
-
|
|
|
- <para>getBoost(t.field in d) - fator de reforço para o campo.</para>
|
|
|
-
|
|
|
- <para>lengthNorm($term) - O valor de normalização para um campo, dado o
|
|
|
- número total de termos contido nele. Este valor é armazenado junto com o
|
|
|
- índice. Estes valores, juntamente com os campos de reforço, são
|
|
|
- armazenados em um índice e multiplicados nas pontuações de acerto em cada
|
|
|
- campo, pelo código de busca.</para>
|
|
|
-
|
|
|
- <para>Comparações em campos longos são menos precisas, e implementações
|
|
|
- deste método usualmente retornam valores pequenos quando o número de
|
|
|
- "tokens" é grande, e valores gradnes quando o número de "tokens" for
|
|
|
- pequeno.</para>
|
|
|
-
|
|
|
- <para>coord(q,d) -
|
|
|
- <code>Zend_Search_Lucene_Search_Similarity::coord($overlap,
|
|
|
- $maxOverlap)</code> - um fator de pontuação baseado no quociente de todos
|
|
|
- os termos de busca que um documento contém.</para>
|
|
|
-
|
|
|
- <para>The presence of a large portion of the query terms indicates a
|
|
|
- better match with the query, so implementations of this method usually
|
|
|
- return larger values when the ratio between these parameters is large and
|
|
|
- smaller values when the ratio between them is small.</para>
|
|
|
-
|
|
|
- <para>A existência de uma grande quantidade de termos de busca indica um
|
|
|
- grau maior de comparação. As implementações deste método usualmente
|
|
|
- retornam valores significativos quando a razão entre estes parâmetros é
|
|
|
- grande e vice versa. </para>
|
|
|
-
|
|
|
- <para>queryNorm(q) - o valor de normalização para uma consulta dado a soma
|
|
|
- dos (squared weights) de cada termo da consulta. Este valor é então
|
|
|
- multiplicado pelo (weight) de cada ítem da consulta.</para>
|
|
|
-
|
|
|
- <para>Isto não afeta a pontuação, mas a quantidade de tentativas para
|
|
|
- gerar pontuações em comparações entre consultas.</para>
|
|
|
-
|
|
|
- <para>O algoritmo de pontuação pode ser customizado pela implementação da
|
|
|
- sua própria classe de similaridade. Para isso crie uma classe descendente
|
|
|
- de Zend_Search_Lucene_Search_Similarity como mostrado abaixo, então use o
|
|
|
- método
|
|
|
- <code>Zend_Search_Lucene_Search_Similarity::setDefault($similarity);</code>
|
|
|
- para defini-la como padrão.</para>
|
|
|
-
|
|
|
- <programlisting role="php"><?php
|
|
|
-
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+ </para>
|
|
|
+ </sect2>
|
|
|
+
|
|
|
+ <sect2 id="zend.search.lucene.extending.filters">
|
|
|
+ <title>Tokens Filtering</title>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ The <classname>Zend_Search_Lucene_Analysis_Analyzer_Common</classname> analyzer also offers a token filtering
|
|
|
+ mechanism.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ The <classname>Zend_Search_Lucene_Analysis_TokenFilter</classname> class provides an abstract interface for such filters.
|
|
|
+ Your own filters should extend this class either directly or indirectly.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Any custom filter must implement the <methodname>normalize()</methodname> method which may transform input token or signal that
|
|
|
+ the current token should be skipped.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ There are three filters already defined in the analysis subpackage:
|
|
|
+ <itemizedlist>
|
|
|
+ <listitem>
|
|
|
+ <para>
|
|
|
+ <classname>Zend_Search_Lucene_Analysis_TokenFilter_LowerCase</classname>
|
|
|
+ </para>
|
|
|
+ </listitem>
|
|
|
+
|
|
|
+ <listitem>
|
|
|
+ <para>
|
|
|
+ <classname>Zend_Search_Lucene_Analysis_TokenFilter_ShortWords</classname>
|
|
|
+ </para>
|
|
|
+ </listitem>
|
|
|
+
|
|
|
+ <listitem>
|
|
|
+ <para>
|
|
|
+ <classname>Zend_Search_Lucene_Analysis_TokenFilter_StopWords</classname>
|
|
|
+ </para>
|
|
|
+ </listitem>
|
|
|
+ </itemizedlist>
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ The <code>LowerCase</code> filter is already used for
|
|
|
+ <classname>Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive</classname> analyzer
|
|
|
+ by default.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ The <code>ShortWords</code> and <code>StopWords</code> filters may be used with pre-defined or custom
|
|
|
+ analyzers like this:
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$stopWords = array('a', 'an', 'at', 'the', 'and', 'or', 'is', 'am');
|
|
|
+$stopWordsFilter =
|
|
|
+ new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords);
|
|
|
+
|
|
|
+$analyzer =
|
|
|
+ new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive();
|
|
|
+$analyzer->addFilter($stopWordsFilter);
|
|
|
+
|
|
|
+Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
|
|
|
+]]></programlisting>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$shortWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords();
|
|
|
+
|
|
|
+$analyzer =
|
|
|
+ new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive();
|
|
|
+$analyzer->addFilter($shortWordsFilter);
|
|
|
+
|
|
|
+Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
|
|
|
+]]></programlisting>
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ The <classname>Zend_Search_Lucene_Analysis_TokenFilter_StopWords</classname> constructor takes an array of stop-words
|
|
|
+ as an input. But stop-words may be also loaded from a file:
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_StopWords();
|
|
|
+$stopWordsFilter->loadFromFile($my_stopwords_file);
|
|
|
+
|
|
|
+$analyzer =
|
|
|
+ new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive();
|
|
|
+$analyzer->addFilter($stopWordsFilter);
|
|
|
+
|
|
|
+Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
|
|
|
+]]></programlisting>
|
|
|
+
|
|
|
+ This file should be a common text file with one word in each line. The '#' character marks a line as a comment.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ The <classname>Zend_Search_Lucene_Analysis_TokenFilter_ShortWords</classname> constructor has one optional argument.
|
|
|
+ This is the word length limit, set by default to 2.
|
|
|
+ </para>
|
|
|
+ </sect2>
|
|
|
+
|
|
|
+ <sect2 id="zend.search.lucene.extending.scoring">
|
|
|
+ <title>Algoritmos de Pontuação</title>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ A pontuação de um documento <literal>d</literal> para uma consulta <literal>q</literal>
|
|
|
+ é definida como segue:
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ <code>score(q,d) = sum( tf(t in d) * idf(t) * getBoost(t.field in d) * lengthNorm(t.field in d) ) *
|
|
|
+ coord(q,d) * queryNorm(q)</code>
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ tf(t in d) - <methodname>Zend_Search_Lucene_Search_Similarity::tf($freq)</methodname> -
|
|
|
+ um fator de pontuação baseado na frequência de um termo ou frase em um documento.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ idf(t) -
|
|
|
+ <methodname>Zend_Search_Lucene_Search_Similarity::idf($input, $reader)</methodname> -
|
|
|
+ um fator de pontuação para um termo simples com o índice especificado.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ getBoost(t.field in d) - o fator de reforço para o campo.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ lengthNorm($term) - O valor de normalização para um campo, dado o número total de termos
|
|
|
+ contido nele. Este valor é armazenado junto com o índice. Estes valores, juntamente com
|
|
|
+ os campos de reforço, são armazenados em um índice e multiplicados nas pontuações de
|
|
|
+ acerto em cada campo, pelo código de busca.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Comparações em campos longos são menos precisas, e implementações deste método
|
|
|
+ usualmente retornam valores pequenos quando o número de "tokens" é grande, e valores
|
|
|
+ grandes quando o número de "tokens" for pequeno.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ coord(q,d) - <methodname>Zend_Search_Lucene_Search_Similarity::coord($overlap,
|
|
|
+ $maxOverlap)</methodname> - um fator de pontuação baseado no quociente de todos os
|
|
|
+ termos de busca que um documento contém.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ A existência de uma grande quantidade de termos de busca indica um grau maior de
|
|
|
+ comparação. As implementações deste método usualmente retornam valores significativos
|
|
|
+ quando a razão entre estes parâmetros é grande e vice versa.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ queryNorm(q) - o valor de normalização para uma consulta dado a soma das relevâncias ao
|
|
|
+ quadrado de cada termo da consulta. Este valor é então multiplicado pela relevância de
|
|
|
+ cada ítem da consulta.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Isto não afeta a pontuação, mas a quantidade de tentativas para gerar pontuações em
|
|
|
+ comparações entre consultas.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ O algoritmo de pontuação pode ser customizado pela implementação da sua própria classe
|
|
|
+ de similaridade. Para isso crie uma classe descendente de
|
|
|
+ <classname>Zend_Search_Lucene_Search_Similarity</classname> como mostrado abaixo, então
|
|
|
+ use o método
|
|
|
+ <classname>Zend_Search_Lucene_Search_Similarity::setDefault($similarity);</classname>
|
|
|
+ para defini-la como padrão.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
class MySimilarity extends Zend_Search_Lucene_Search_Similarity {
|
|
|
public function lengthNorm($fieldName, $numTerms) {
|
|
|
return 1.0/sqrt($numTerms);
|
|
|
@@ -199,39 +341,45 @@ class MySimilarity extends Zend_Search_Lucene_Search_Similarity {
|
|
|
|
|
|
$mySimilarity = new MySimilarity();
|
|
|
Zend_Search_Lucene_Search_Similarity::setDefault($mySimilarity);
|
|
|
-
|
|
|
-?></programlisting>
|
|
|
- </sect2>
|
|
|
-
|
|
|
- <sect2 id="zend.search.lucene.extending.storage">
|
|
|
- <title>Recipientes de Armazenagem</title>
|
|
|
-
|
|
|
- <para>A classe abstrata Zend_Search_Lucene_Storage_Directory define a
|
|
|
- funcionalidade de diretório.</para>
|
|
|
-
|
|
|
- <para>O construtor do Zend_Search_Lucene usa como entrada uma string ou um
|
|
|
- objeto da classe Zend_Search_Lucene_Storage_Directory.</para>
|
|
|
-
|
|
|
- <para>A classe Zend_Search_Lucene_Storage_Directory_Filesystem implementa
|
|
|
- a funcionalidade de diretório para o sistema de arquivos.</para>
|
|
|
-
|
|
|
- <para>If string is used as an input for the Zend_Search_Lucene
|
|
|
- constructor, then the index reader (Zend_Search_Lucene object) treats it
|
|
|
- as a file system path and instantiates
|
|
|
- Zend_Search_Lucene_Storage_Directory_Filesystem object by
|
|
|
- themselves.</para>
|
|
|
-
|
|
|
- <para>Se uma string for usada como entrada para o construtor do
|
|
|
- Zend_Search_Lucene, então o leitor do índice (um objeto
|
|
|
- Zend_Search_Lucene) a tratará como um caminho para o sistema de arquivos e
|
|
|
- instanciará um objeto da classe
|
|
|
- Zend_Search_Lucene_Storage_Directory_Filesystem.</para>
|
|
|
-
|
|
|
- <para>Voce pode definir a sua própria implementação de diretório
|
|
|
- extendendo a classe Zend_Search_Lucene_Storage_Directory.</para>
|
|
|
-
|
|
|
- <para>Métodos de Zend_Search_Lucene_Storage_Directory: <programlisting><?php
|
|
|
-
|
|
|
+]]></programlisting>
|
|
|
+ </sect2>
|
|
|
+
|
|
|
+ <sect2 id="zend.search.lucene.extending.storage">
|
|
|
+ <title>Recipientes de Armazenagem</title>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ A classe abstrata <classname>Zend_Search_Lucene_Storage_Directory</classname> define a
|
|
|
+ funcionalidade de diretório.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ O construtor do <classname>Zend_Search_Lucene</classname> usa como entrada uma string ou
|
|
|
+ um objeto da classe <classname>Zend_Search_Lucene_Storage_Directory</classname>.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ A classe <classname>Zend_Search_Lucene_Storage_Directory_Filesystem</classname>
|
|
|
+ implementa a funcionalidade de diretório para o sistema de arquivos.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Se uma string for usada como entrada para o construtor do
|
|
|
+ <classname>Zend_Search_Lucene</classname>, então o leitor do índice (um objeto
|
|
|
+ <classname>Zend_Search_Lucene</classname>) a tratará como um caminho para o sistema de
|
|
|
+ arquivos e instanciará um objeto
|
|
|
+ <classname>Zend_Search_Lucene_Storage_Directory_Filesystem</classname>.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Você pode definir a sua própria implementação de diretório extendendo a classe
|
|
|
+ <classname>Zend_Search_Lucene_Storage_Directory</classname>.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Métodos de <classname>Zend_Search_Lucene_Storage_Directory</classname>:
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
abstract class Zend_Search_Lucene_Storage_Directory {
|
|
|
/**
|
|
|
* Closes the store.
|
|
|
@@ -240,7 +388,6 @@ abstract class Zend_Search_Lucene_Storage_Directory {
|
|
|
*/
|
|
|
abstract function close();
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Creates a new, empty file in the directory with the given $filename.
|
|
|
*
|
|
|
@@ -249,7 +396,6 @@ abstract function close();
|
|
|
*/
|
|
|
abstract function createFile($filename);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Removes an existing $filename in the directory.
|
|
|
*
|
|
|
@@ -258,7 +404,6 @@ abstract function createFile($filename);
|
|
|
*/
|
|
|
abstract function deleteFile($filename);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Returns true if a file with the given $filename exists.
|
|
|
*
|
|
|
@@ -267,7 +412,6 @@ abstract function deleteFile($filename);
|
|
|
*/
|
|
|
abstract function fileExists($filename);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Returns the length of a $filename in the directory.
|
|
|
*
|
|
|
@@ -276,7 +420,6 @@ abstract function fileExists($filename);
|
|
|
*/
|
|
|
abstract function fileLength($filename);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Returns the UNIX timestamp $filename was last modified.
|
|
|
*
|
|
|
@@ -285,7 +428,6 @@ abstract function fileLength($filename);
|
|
|
*/
|
|
|
abstract function fileModified($filename);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Renames an existing file in the directory.
|
|
|
*
|
|
|
@@ -295,7 +437,6 @@ abstract function fileModified($filename);
|
|
|
*/
|
|
|
abstract function renameFile($from, $to);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Sets the modified time of $filename to now.
|
|
|
*
|
|
|
@@ -304,9 +445,9 @@ abstract function renameFile($from, $to);
|
|
|
*/
|
|
|
abstract function touchFile($filename);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * Returns a Zend_Search_Lucene_Storage_File object for a given $filename in the directory.
|
|
|
+ * Returns a Zend_Search_Lucene_Storage_File object for a given
|
|
|
+ * $filename in the directory.
|
|
|
*
|
|
|
* @param string $filename
|
|
|
* @return Zend_Search_Lucene_Storage_File
|
|
|
@@ -314,24 +455,31 @@ abstract function touchFile($filename);
|
|
|
abstract function getFileObject($filename);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-?></programlisting></para>
|
|
|
-
|
|
|
- <para>O método <code>getFileObject($filename)</code> da classe
|
|
|
- Zend_Search_Lucene_Storage_Directory retorna um objeto
|
|
|
- Zend_Search_Lucene_Storage_File.</para>
|
|
|
-
|
|
|
- <para>A classe abstrata Zend_Search_Lucene_Storage_File implementa a
|
|
|
- abstração de arquivo e as primitivas de leitura de arquivos de
|
|
|
- índice.</para>
|
|
|
-
|
|
|
- <para>Se fizer isso, você também terá que extender a classe
|
|
|
- Zend_Search_Lucene_Storage_File para a sua implementação de
|
|
|
- diretório.</para>
|
|
|
-
|
|
|
- <para>Somente dois métodos da classe Zend_Search_Lucene_Storage_File devem
|
|
|
- ser sobrecarregados em sua implementação: <programlisting><?php
|
|
|
-
|
|
|
+]]></programlisting>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ O método <methodname>getFileObject($filename)</methodname> de uma instância
|
|
|
+ <classname>Zend_Search_Lucene_Storage_Directory</classname> retorna um objeto
|
|
|
+ <classname>Zend_Search_Lucene_Storage_File</classname>.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ A classe abstrata <classname>Zend_Search_Lucene_Storage_File</classname> implementa a
|
|
|
+ abstração de arquivo e as primitivas de leitura de arquivos de índice.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Se fizer isso, você também terá que extender
|
|
|
+ <classname>Zend_Search_Lucene_Storage_File</classname> para a sua implementação de
|
|
|
+ diretório.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ Somente dois métodos de <classname>Zend_Search_Lucene_Storage_File</classname> devem ser
|
|
|
+ substituídos em sua implementação:
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
class MyFile extends Zend_Search_Lucene_Storage_File {
|
|
|
/**
|
|
|
* Sets the file position indicator and advances the file pointer.
|
|
|
@@ -363,10 +511,11 @@ class MyFile extends Zend_Search_Lucene_Storage_File {
|
|
|
...
|
|
|
}
|
|
|
}
|
|
|
+]]></programlisting>
|
|
|
|
|
|
-?></programlisting></para>
|
|
|
- </sect2>
|
|
|
+ </sect2>
|
|
|
</sect1>
|
|
|
+
|
|
|
<!--
|
|
|
vim:se ts=4 sw=4 et:
|
|
|
-->
|