summaryrefslogtreecommitdiffstats
path: root/linguistics
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2017-01-20 13:37:49 +0100
committerJon Bratseth <bratseth@yahoo-inc.com>2017-01-20 13:37:49 +0100
commit262d072c1ac996b34f6c70efc95853be699ca935 (patch)
tree925e107e3024bc5ab4e1045a6625c3e4d17bf543 /linguistics
parent80b7024763933d95edf39e726d1d78018672d050 (diff)
Nonfunctional changes only
Diffstat (limited to 'linguistics')
-rw-r--r--linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java3
-rw-r--r--linguistics/src/main/java/com/yahoo/language/detect/Detector.java9
-rw-r--r--linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java11
3 files changed, 16 insertions, 7 deletions
diff --git a/linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java b/linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java
index f80f876d248..d457f83c9fd 100644
--- a/linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java
+++ b/linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java
@@ -6,7 +6,7 @@ import com.yahoo.text.Utf8;
import java.nio.ByteBuffer;
/**
- * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a>
+ * @author Simon Thoresen
*/
public abstract class AbstractDetector implements Detector {
@@ -22,4 +22,5 @@ public abstract class AbstractDetector implements Detector {
input.get(buf, 0, buf.length);
return detect(buf, 0, buf.length, hint);
}
+
}
diff --git a/linguistics/src/main/java/com/yahoo/language/detect/Detector.java b/linguistics/src/main/java/com/yahoo/language/detect/Detector.java
index 4962d761a5a..c18b41bc890 100644
--- a/linguistics/src/main/java/com/yahoo/language/detect/Detector.java
+++ b/linguistics/src/main/java/com/yahoo/language/detect/Detector.java
@@ -6,7 +6,7 @@ import java.nio.ByteBuffer;
/**
* Abstract superclass of all Detectors used for language and encoding detection.
*
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ * @author Einar M R Rosenvinge
*/
public interface Detector {
@@ -20,7 +20,7 @@ public interface Detector {
* @return an array of possible language/encoding pairs, sorted by decreasing confidence (possibly empty, but never null)
* @throws DetectionException if detection fails
*/
- public abstract Detection detect(byte[] input, int offset, int length, Hint hint);
+ Detection detect(byte[] input, int offset, int length, Hint hint);
/**
* Detects language and encoding of the supplied ByteBuffer, possibly using a language/encoding hint.
@@ -30,7 +30,7 @@ public interface Detector {
* @return an array of possible language/encoding pairs, sorted by decreasing confidence (possibly empty, but never null)
* @throws DetectionException if detection fails
*/
- public abstract Detection detect(ByteBuffer input, Hint hint);
+ Detection detect(ByteBuffer input, Hint hint);
/**
* Detects language of the supplied String, possibly using a language hint.
@@ -40,5 +40,6 @@ public interface Detector {
* @return an array of possible language/encoding pairs, sorted by decreasing confidence (possibly empty, but never null)
* @throws DetectionException if detection fails
*/
- public abstract Detection detect(String input, Hint hint);
+ Detection detect(String input, Hint hint);
+
}
diff --git a/linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java b/linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java
index eca35772296..24e1684d065 100644
--- a/linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java
+++ b/linguistics/src/main/java/com/yahoo/language/simple/SimpleDetector.java
@@ -19,8 +19,8 @@ import java.nio.ByteBuffer;
* Japanese or Chinese characters, so their presence is a good indication of Korean. If a string contains phonetic
* japanese, this is a good indication of Japanese. However, Japanese and Chinese characters occupy many of the same
* character blocks, so if there are no definitive signs of Japanese then it is assumed that the String is Chinese.</p>
-
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ *
+ * @author Rich Pito
*/
public class SimpleDetector implements Detector {
@@ -46,6 +46,12 @@ public class SimpleDetector implements Detector {
}
public static Language guessLanguage(String input) {
+ Language language = guessLanguage2(input);
+ System.out.println("Detecting language of '" + input + "' as " + language);
+ return language;
+ }
+
+ public static Language guessLanguage2(String input) {
if (input == null || input.length() == 0) {
return Language.UNKNOWN;
}
@@ -176,4 +182,5 @@ public class SimpleDetector implements Detector {
return "ISO-8859-1";
}
}
+
}