Detector class
Detector class is to detect language from specified text.
Its instance is able to be constructed via the factory class DetectorFactory. After appending a target text to the Detector instance with append(string), the detector provides the language detection results for target text via detect() or getProbabilities(). detect() method returns a single language name which has the highest probability. getProbabilities() methods returns a list of multiple languages and their probabilities. The detector has some parameters for language detection. See setAlpha(double), setMaxTextLength(int) setPriorMap(dict).
Example:
import 'package:flutter_langdetect/flutter_langdetect.dart';
import 'package:flutter/widgets.dart';
import 'package:logger/logger.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
DetectorFactory.profileBasePath = "assets/profiles/";
await initLangDetect();
final s = "Hello, world!";
final langs = detect(s);
logger.d("langs: ${langs}");
}
Constructors
- Detector(DetectorFactory factory)
- Construct Detector instance.
Properties
- alpha ↔ double
-
getter/setter pair
- factory → DetectorFactory
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
langList
↔ List<
String> -
getter/setter pair
-
langProb
↔ List<
double> ? -
getter/setter pair
- logger → Logger
-
final
- maxTextLength ↔ int
-
getter/setter pair
- nTrial ↔ int
-
getter/setter pair
-
priorMap
↔ List<
double> ? -
getter/setter pair
- random ↔ Random
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seed ↔ int
-
getter/setter pair
- text ↔ String
-
getter/setter pair
- verbose ↔ bool
-
getter/setter pair
-
wordLangProbMap
↔ Map<
String, List< double> > -
getter/setter pair
Methods
-
append(
String text) → void - Append the target text for language detection.
-
cleaningText(
) → void - Cleaning text to detect
-
detect(
) → String - Detect language of the target text and return the language name which has the highest probability.
-
getProbabilities(
) → List< Language> -
getRandomElement(
Random random, List< String> list) → String -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setAlpha(
double alpha) → void -
setMaxTextLength(
int maxTextLength) → void - Specify max size of target text to use for language detection.
-
setPriorMap(
Map< String, double> priorMap) → void - Set prior information about language probabilities.
-
setVerbose(
) → void -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- alphaDefault → const double
- alphaWidth → const double
- baseFreq → const int
- convThreshold → const double
- iterationLimit → const int
- probThreshold → const double
- unknownLang → const String