Skip to content

Commit

Permalink
add an interface of prior language information
Browse files Browse the repository at this point in the history
update javadoc


git-svn-id: http://language-detection.googlecode.com/svn/trunk@24 5bf80810-9c81-6ef6-3109-74533bb38634
  • Loading branch information
[email protected] committed Sep 29, 2010
1 parent 6126150 commit b17525e
Show file tree
Hide file tree
Showing 62 changed files with 587 additions and 278 deletions.
4 changes: 2 additions & 2 deletions doc/allclasses-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_21) on Tue Sep 28 17:25:34 JST 2010 -->
<!-- Generated by javadoc (build 1.6.0_21) on Wed Sep 29 19:24:42 JST 2010 -->
<TITLE>
All Classes
</TITLE>

<META NAME="date" CONTENT="2010-09-28">
<META NAME="date" CONTENT="2010-09-29">

<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

Expand Down
4 changes: 2 additions & 2 deletions doc/allclasses-noframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_21) on Tue Sep 28 17:25:34 JST 2010 -->
<!-- Generated by javadoc (build 1.6.0_21) on Wed Sep 29 19:24:42 JST 2010 -->
<TITLE>
All Classes
</TITLE>

<META NAME="date" CONTENT="2010-09-28">
<META NAME="date" CONTENT="2010-09-29">

<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

Expand Down
4 changes: 2 additions & 2 deletions doc/com/cybozu/labs/langdetect/Command.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_21) on Tue Sep 28 17:25:33 JST 2010 -->
<!-- Generated by javadoc (build 1.6.0_21) on Wed Sep 29 19:24:41 JST 2010 -->
<TITLE>
Command
</TITLE>

<META NAME="date" CONTENT="2010-09-28">
<META NAME="date" CONTENT="2010-09-29">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

Expand Down
122 changes: 94 additions & 28 deletions doc/com/cybozu/labs/langdetect/Detector.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_21) on Tue Sep 28 17:25:34 JST 2010 -->
<!-- Generated by javadoc (build 1.6.0_21) on Wed Sep 29 19:24:41 JST 2010 -->
<TITLE>
Detector
</TITLE>

<META NAME="date" CONTENT="2010-09-28">
<META NAME="date" CONTENT="2010-09-29">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

Expand Down Expand Up @@ -101,10 +101,16 @@ <H2>
</PRE>

<P>
Language Detector Class
<A HREF="../../../../com/cybozu/labs/langdetect/Detector.html" title="class in com.cybozu.labs.langdetect"><CODE>Detector</CODE></A> class is to detect language from specified text.
Its instance is able to be constructed via the factory class <A HREF="../../../../com/cybozu/labs/langdetect/DetectorFactory.html" title="class in com.cybozu.labs.langdetect"><CODE>DetectorFactory</CODE></A>.
<p>

This class is able to be constructed via the factory class <A HREF="../../../../com/cybozu/labs/langdetect/DetectorFactory.html" title="class in com.cybozu.labs.langdetect"><CODE>DetectorFactory</CODE></A>.
After appending a target text to the <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html" title="class in com.cybozu.labs.langdetect"><CODE>Detector</CODE></A> instance with <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#append(java.io.Reader)"><CODE>append(Reader)</CODE></A> or <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#append(java.lang.String)"><CODE>append(String)</CODE></A>,
the detector provides the language detection results for target text via <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#detect()"><CODE>detect()</CODE></A> or <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#getProbabilities()"><CODE>getProbabilities()</CODE></A>.
<A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#detect()"><CODE>detect()</CODE></A> method returns a single language name which has the highest probability.
<A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#getProbabilities()"><CODE>getProbabilities()</CODE></A> methods returns a list of multiple languages and their probabilities.
<p>
The detector has some parameters for language detection.
See <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setAlpha(double)"><CODE>setAlpha(double)</CODE></A>, <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setMax_text_length(int)"><CODE>setMax_text_length(int)</CODE></A> and <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setPriorMap(java.util.HashMap)"><CODE>setPriorMap(HashMap)</CODE></A>.

<pre>
import java.util.ArrayList;
Expand All @@ -113,15 +119,15 @@ <H2>
import com.cybozu.labs.langdetect.Language;

class LangDetectSample {
public void init(String profileDirectory) {
public void init(String profileDirectory) throws LangDetectException {
DetectorFactory.loadProfile(profileDirectory);
}
public String detect(String text) {
public String detect(String text) throws LangDetectException {
Detector detector = DetectorFactory.create();
detector.append(text);
return detector.detect();
}
public ArrayList<Language> detectLangs(String text) {
public ArrayList<Language> detectLangs(String text) throws LangDetectException {
Detector detector = DetectorFactory.create();
detector.append(text);
return detector.getProbabilities();
Expand All @@ -148,11 +154,10 @@ <H2>
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#Detector(java.util.HashMap, java.util.ArrayList)">Detector</A></B>(java.util.HashMap&lt;java.lang.String,java.util.HashMap&lt;java.lang.String,java.lang.Double&gt;&gt;&nbsp;p_ik,
java.util.ArrayList&lt;java.lang.String&gt;&nbsp;langlist)</CODE>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#Detector(com.cybozu.labs.langdetect.DetectorFactory)">Detector</A></B>(<A HREF="../../../../com/cybozu/labs/langdetect/DetectorFactory.html" title="class in com.cybozu.labs.langdetect">DetectorFactory</A>&nbsp;factory)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructor.</TD>
</TR>
</TABLE>
&nbsp;
Expand All @@ -167,26 +172,26 @@ <H2>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#append(java.io.Reader)">append</A></B>(java.io.Reader&nbsp;is)</CODE>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#append(java.io.Reader)">append</A></B>(java.io.Reader&nbsp;reader)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append the target text for language detection.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#append(java.lang.String)">append</A></B>(java.lang.String&nbsp;buf)</CODE>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#append(java.lang.String)">append</A></B>(java.lang.String&nbsp;text)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append the target text for language detection.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#detect()">detect</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Detect language of the target text and return the language name which has the highest probability.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
Expand All @@ -202,15 +207,31 @@ <H2>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setAlpha(double)">setAlpha</A></B>(double&nbsp;alpha)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set smoothing parameter.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setMax_text_length(int)">setMax_text_length</A></B>(int&nbsp;max_text_length)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specify max size of target text to use for language detection.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setPriorMap(java.util.HashMap)">setPriorMap</A></B>(java.util.HashMap&lt;java.lang.String,java.lang.Double&gt;&nbsp;priorMap)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set prior information about language probabilities.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setVerbose()">setVerbose</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set Verbose Mode(use for debug).</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
Expand All @@ -235,14 +256,16 @@ <H2>
</TR>
</TABLE>

<A NAME="Detector(java.util.HashMap, java.util.ArrayList)"><!-- --></A><H3>
<A NAME="Detector(com.cybozu.labs.langdetect.DetectorFactory)"><!-- --></A><H3>
Detector</H3>
<PRE>
public <B>Detector</B>(java.util.HashMap&lt;java.lang.String,java.util.HashMap&lt;java.lang.String,java.lang.Double&gt;&gt;&nbsp;p_ik,
java.util.ArrayList&lt;java.lang.String&gt;&nbsp;langlist)</PRE>
public <B>Detector</B>(<A HREF="../../../../com/cybozu/labs/langdetect/DetectorFactory.html" title="class in com.cybozu.labs.langdetect">DetectorFactory</A>&nbsp;factory)</PRE>
<DL>
<DD>Constructor.
Detector instance can be constructed via <A HREF="../../../../com/cybozu/labs/langdetect/DetectorFactory.html#create()"><CODE>DetectorFactory.create()</CODE></A>.
<P>
<DL>
<DT><B>Parameters:</B><DD><CODE>p_ik</CODE> - <DD><CODE>langlist</CODE> - </DL>
<DT><B>Parameters:</B><DD><CODE>factory</CODE> - <A HREF="../../../../com/cybozu/labs/langdetect/DetectorFactory.html" title="class in com.cybozu.labs.langdetect"><CODE>DetectorFactory</CODE></A> instance (only DetectorFactory inside)</DL>
</DL>

<!-- ============ METHOD DETAIL ========== -->
Expand All @@ -260,6 +283,8 @@ <H2>
<PRE>
public void <B>setVerbose</B>()</PRE>
<DL>
<DD>Set Verbose Mode(use for debug).
<P>
<DD><DL>
</DL>
</DD>
Expand All @@ -271,33 +296,72 @@ <H2>
<PRE>
public void <B>setAlpha</B>(double&nbsp;alpha)</PRE>
<DL>
<DD>Set smoothing parameter.
The default value is 0.5(i.e. Expected Likelihood Estimate).
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>alpha</CODE> - </DL>
<DT><B>Parameters:</B><DD><CODE>alpha</CODE> - the smoothing parameter</DL>
</DD>
</DL>
<HR>

<A NAME="setPriorMap(java.util.HashMap)"><!-- --></A><H3>
setPriorMap</H3>
<PRE>
public void <B>setPriorMap</B>(java.util.HashMap&lt;java.lang.String,java.lang.Double&gt;&nbsp;priorMap)</PRE>
<DL>
<DD>Set prior information about language probabilities.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>priorMap</CODE> - the priorMap to set</DL>
</DD>
</DL>
<HR>

<A NAME="setMax_text_length(int)"><!-- --></A><H3>
setMax_text_length</H3>
<PRE>
public void <B>setMax_text_length</B>(int&nbsp;max_text_length)</PRE>
<DL>
<DD>Specify max size of target text to use for language detection.
The default value is 10000(10KB).
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>max_text_length</CODE> - the max_text_length to set</DL>
</DD>
</DL>
<HR>

<A NAME="append(java.io.Reader)"><!-- --></A><H3>
append</H3>
<PRE>
public void <B>append</B>(java.io.Reader&nbsp;is)
public void <B>append</B>(java.io.Reader&nbsp;reader)
throws java.io.IOException</PRE>
<DL>
<DD>Append the target text for language detection.
This method read the text from specified input reader.
If the total size of target text exceeds the limit size specified by <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setMax_text_length(int)"><CODE>setMax_text_length(int)</CODE></A>,
the rest is cut down.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>is</CODE> -
<DT><B>Parameters:</B><DD><CODE>reader</CODE> - the input reader (BufferedReader as usual)
<DT><B>Throws:</B>
<DD><CODE>java.io.IOException</CODE></DL>
<DD><CODE>java.io.IOException</CODE> - Can't read the reader.</DL>
</DD>
</DL>
<HR>

<A NAME="append(java.lang.String)"><!-- --></A><H3>
append</H3>
<PRE>
public void <B>append</B>(java.lang.String&nbsp;buf)</PRE>
public void <B>append</B>(java.lang.String&nbsp;text)</PRE>
<DL>
<DD>Append the target text for language detection.
If the total size of target text exceeds the limit size specified by <A HREF="../../../../com/cybozu/labs/langdetect/Detector.html#setMax_text_length(int)"><CODE>setMax_text_length(int)</CODE></A>,
the rest is cut down.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>buf</CODE> - </DL>
<DT><B>Parameters:</B><DD><CODE>text</CODE> - the target text to append</DL>
</DD>
</DL>
<HR>
Expand All @@ -308,6 +372,8 @@ <H2>
public java.lang.String <B>detect</B>()
throws <A HREF="../../../../com/cybozu/labs/langdetect/LangDetectException.html" title="class in com.cybozu.labs.langdetect">LangDetectException</A></PRE>
<DL>
<DD>Detect language of the target text and return the language name which has the highest probability.
<P>
<DD><DL>

<DT><B>Returns:</B><DD>detected language name which has most probability.
Expand Down
Loading

0 comments on commit b17525e

Please sign in to comment.