Nasty.Operations.Classification behaviour (Nasty v0.3.0)
View SourceBehaviour for language-agnostic text classification.
This behaviour defines the interface for training and using text classifiers that can work with any language.
Summary
Callbacks
Returns supported classification algorithms.
Classifies text or document using trained model.
Trains a classifier on labeled training data.
Types
@type model() :: term()
@type options() :: keyword()
@type training_data() :: [ {text :: String.t() | Nasty.AST.Document.t(), category :: atom()} ]
Callbacks
@callback algorithms() :: [atom()]
Returns supported classification algorithms.
@callback classify( model :: model(), input :: String.t() | Nasty.AST.Document.t(), opts :: options() ) :: {:ok, Nasty.AST.Classification.t()} | {:error, term()}
Classifies text or document using trained model.
Parameters
model- Trained classifier modelinput- Text string or Document AST to classifyopts- Classification options
Returns
{:ok, classification}- Classification result with confidence{:error, reason}- Classification error
@callback train(training_data :: training_data(), opts :: options()) :: {:ok, model()} | {:error, term()}
Trains a classifier on labeled training data.
Parameters
training_data- List of {text, category} tuplesopts- Training options
Returns
{:ok, model}- Trained model{:error, reason}- Training error