public static final class LanguageIdentifier.Session
- Object
- LanguageIdentifier.Session
ImplementsAutoCloseable
Reusable owner of a native language-identification backend.
A session accepts multiple asynchronous requests. Calling
close() prevents new requests immediately and defers native
release until requests already in progress have completed.
Methods
public AsyncResource<LanguageCandidate[]> identify(String text) | Identifies languages without recreating the native backend. |
public void close() | Closes the session. |
Inherited methods
Method details
identify
public AsyncResource<LanguageCandidate[]> identify(String text)Identifies languages without recreating the native backend.
Cancelling the returned resource suppresses late callbacks without
closing this reusable session.
Parameters
textString- text to classify;
nullis treated as empty
Returns
asynchronous ranked candidates, possibly empty
Throws
IllegalStateException- if this session is closed
close
public void close()Closes the session. This method is idempotent; native release is
deferred until pending identifications finish.