analyzerutil.html

来自「 Lucene是apache软件基金会[4] jakarta项目组的一个子项目」· HTML 代码 · 共 479 行 · 第 1/2 页

HTML
479
字号
getLoggingAnalyzer</H3>
<PRE>
public static <A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A> <B>getLoggingAnalyzer</B>(<A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A>&nbsp;child,                                          <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/PrintStream.html" title="class or interface in java.io">PrintStream</A>&nbsp;log,                                          <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;logName)</PRE>
<DL>
<DD>Returns a simple analyzer wrapper that logs all tokens produced by the underlying child analyzer to the given log stream (typically System.err); Otherwise behaves exactly like the child analyzer, delivering the very same tokens; useful for debugging purposes on custom indexing and/or querying.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>child</CODE> - the underlying child analyzer<DD><CODE>log</CODE> - the print stream to log to (typically System.err)<DD><CODE>logName</CODE> - a name for this logger (typically "log" or similar)<DT><B>Returns:</B><DD>a logging analyzer</DL>
</DD>
</DL>
<HR>

<A NAME="getMaxTokenAnalyzer(org.apache.lucene.analysis.Analyzer, int)"><!-- --></A><H3>
getMaxTokenAnalyzer</H3>
<PRE>
public static <A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A> <B>getMaxTokenAnalyzer</B>(<A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A>&nbsp;child,                                           int&nbsp;maxTokens)</PRE>
<DL>
<DD>Returns an analyzer wrapper that returns at most the first <code>maxTokens</code> tokens from the underlying child analyzer, ignoring all remaining tokens.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>child</CODE> - the underlying child analyzer<DD><CODE>maxTokens</CODE> - the maximum number of tokens to return from the underlying            analyzer (a value of Integer.MAX_VALUE indicates unlimited)<DT><B>Returns:</B><DD>an analyzer wrapper</DL>
</DD>
</DL>
<HR>

<A NAME="getPorterStemmerAnalyzer(org.apache.lucene.analysis.Analyzer)"><!-- --></A><H3>
getPorterStemmerAnalyzer</H3>
<PRE>
public static <A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A> <B>getPorterStemmerAnalyzer</B>(<A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A>&nbsp;child)</PRE>
<DL>
<DD>Returns an English stemming analyzer that stems tokens from the underlying child analyzer according to the Porter stemming algorithm. The child analyzer must deliver tokens in lower case for the stemmer to work properly. <p> Background: Stemming reduces token terms to their linguistic root form e.g. reduces "fishing" and "fishes" to "fish", "family" and "families" to "famili", as well as "complete" and "completion" to "complet". Note that the root form is not necessarily a meaningful word in itself, and that this is not a bug but rather a feature, if you lean back and think about fuzzy word matching for a bit. <p> See the Lucene contrib packages for stemmers (and stop words) for German, Russian and many more languages.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>child</CODE> - the underlying child analyzer<DT><B>Returns:</B><DD>an analyzer wrapper</DL>
</DD>
</DL>
<HR>

<A NAME="getSynonymAnalyzer(org.apache.lucene.analysis.Analyzer, org.apache.lucene.index.memory.SynonymMap, int)"><!-- --></A><H3>
getSynonymAnalyzer</H3>
<PRE>
public static <A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A> <B>getSynonymAnalyzer</B>(<A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A>&nbsp;child,                                          <A HREF="../../../../../org/apache/lucene/index/memory/SynonymMap.html" title="class in org.apache.lucene.index.memory">SynonymMap</A>&nbsp;synonyms,                                          int&nbsp;maxSynonyms)</PRE>
<DL>
<DD>Returns an analyzer wrapper that wraps the underlying child analyzer's token stream into a <A HREF="../../../../../org/apache/lucene/index/memory/SynonymTokenFilter.html" title="class in org.apache.lucene.index.memory"><CODE>SynonymTokenFilter</CODE></A>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>child</CODE> - the underlying child analyzer<DD><CODE>synonyms</CODE> - the map used to extract synonyms for terms<DD><CODE>maxSynonyms</CODE> - the maximum number of synonym tokens to return per underlying            token word (a value of Integer.MAX_VALUE indicates unlimited)<DT><B>Returns:</B><DD>a new analyzer</DL>
</DD>
</DL>
<HR>

<A NAME="getTokenCachingAnalyzer(org.apache.lucene.analysis.Analyzer)"><!-- --></A><H3>
getTokenCachingAnalyzer</H3>
<PRE>
public static <A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A> <B>getTokenCachingAnalyzer</B>(<A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A>&nbsp;child)</PRE>
<DL>
<DD>Returns an analyzer wrapper that caches all tokens generated by the underlying child analyzer's token streams, and delivers those cached tokens on subsequent calls to  <code>tokenStream(String fieldName, Reader reader)</code>  if the fieldName has been seen before, altogether ignoring the Reader parameter on cache lookup. <p> If Analyzer / TokenFilter chains are expensive in terms of I/O or CPU, such caching can  help improve performance if the same document is added to multiple Lucene indexes,  because the text analysis phase need not be performed more than once. <p> Caveats:  <ul> <li>Caching the tokens of large Lucene documents can lead to out of memory exceptions.</li>  <li>The Token instances delivered by the underlying child analyzer must be immutable.</li> <li>The same caching analyzer instance must not be used for more than one document because the cache is not keyed on the Reader parameter.</li> </ul>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>child</CODE> - the underlying child analyzer<DT><B>Returns:</B><DD>a new analyzer</DL>
</DD>
</DL>
<HR>

<A NAME="getMostFrequentTerms(org.apache.lucene.analysis.Analyzer, java.lang.String, int)"><!-- --></A><H3>
getMostFrequentTerms</H3>
<PRE>
public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>[] <B>getMostFrequentTerms</B>(<A HREF="../../../../../org/apache/lucene/analysis/Analyzer.html" title="class in org.apache.lucene.analysis">Analyzer</A>&nbsp;analyzer,                                            <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;text,                                            int&nbsp;limit)</PRE>
<DL>
<DD>Returns (frequency:term) pairs for the top N distinct terms (aka words), sorted descending by frequency (and ascending by term, if tied). <p> Example XQuery: <pre> declare namespace util = "java:org.apache.lucene.index.memory.AnalyzerUtil"; declare namespace analyzer = "java:org.apache.lucene.index.memory.PatternAnalyzer";  for $pair in util:get-most-frequent-terms(    analyzer:EXTENDED_ANALYZER(), doc("samples/shakespeare/othello.xml"), 10) return &lt;word word="{substring-after($pair, ':')}" frequency="{substring-before($pair, ':')}"/> </pre>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>analyzer</CODE> - the analyzer to use for splitting text into terms (aka words)<DD><CODE>text</CODE> - the text to analyze<DD><CODE>limit</CODE> - the maximum number of pairs to return; zero indicates             "as many as possible".<DT><B>Returns:</B><DD>an array of (frequency:term) pairs in the form of (freq0:term0,         freq1:term1, ..., freqN:termN). Each pair is a single string         separated by a ':' delimiter.</DL>
</DD>
</DL>
<HR>

<A NAME="getParagraphs(java.lang.String, int)"><!-- --></A><H3>
getParagraphs</H3>
<PRE>
public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>[] <B>getParagraphs</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;text,                                     int&nbsp;limit)</PRE>
<DL>
<DD>Returns at most the first N paragraphs of the given text. Delimiting characters are excluded from the results. Each returned paragraph is whitespace-trimmed via String.trim(), potentially an empty string.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the text to tokenize into paragraphs<DD><CODE>limit</CODE> - the maximum number of paragraphs to return; zero indicates "as            many as possible".<DT><B>Returns:</B><DD>the first N paragraphs</DL>
</DD>
</DL>
<HR>

<A NAME="getSentences(java.lang.String, int)"><!-- --></A><H3>
getSentences</H3>
<PRE>
public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>[] <B>getSentences</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>&nbsp;text,                                    int&nbsp;limit)</PRE>
<DL>
<DD>Returns at most the first N sentences of the given text. Delimiting characters are excluded from the results. Each returned sentence is whitespace-trimmed via String.trim(), potentially an empty string.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the text to tokenize into sentences<DD><CODE>limit</CODE> - the maximum number of sentences to return; zero indicates "as            many as possible".<DT><B>Returns:</B><DD>the first N sentences</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>

<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/AnalyzerUtil.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV CLASS&nbsp;
&nbsp;<A HREF="../../../../../org/apache/lucene/index/memory/MemoryIndex.html" title="class in org.apache.lucene.index.memory"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="AnalyzerUtil.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>
Copyright &copy; 2000-2007 Apache Software Foundation.  All Rights Reserved.
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?