IntentContainer¶
-
class
padatious.
IntentContainer
(cache_dir)[source]¶ Creates an IntentContainer object used to load and match intents
Parameters: cache_dir (str) – Place to put all saved neural networks -
add_intent
(name, lines, reload_cache=False)[source]¶ Creates a new intent, optionally checking the cache first
Parameters: - name (str) – The associated name of the intent
- lines (list<str>) – All the sentences that should activate the intent
- reload_cache – Whether to ignore cached intent if exists
-
calc_intent
(query)[source]¶ Tests all the intents against the query and returns match data of the best intent
Parameters: query (str) – Input sentence to test against intents Returns: Best intent match Return type: MatchData
-
calc_intents
(query)[source]¶ Tests all the intents against the query and returns data on how well each one matched against the query
Parameters: query (str) – Input sentence to test against intents Returns: List of intent matches Return type: list<MatchData> See calc_intent() for a description of the returned MatchData
-
load_file
(name, file_name, reload_cache=False)[source]¶ Loads an intent, optionally checking the cache first
Parameters: - name (str) – The associated name of the intent
- file_name (str) – The location of the intent file
- reload_cache (bool) – Whether to ignore cached intent if exists
-
train
(print_updates=True, single_thread=False)[source]¶ Trains all the loaded intents that need to be updated If a cache file exists with the same hash as the intent file, the intent will not be trained and just loaded from file
Parameters: - print_updates (bool) – Whether to print a message to stdout each time a new intent is trained
- single_thread (bool) – Whether to force running in a single thread
-
MatchData¶
-
class
padatious.
MatchData
(name, sent, matches=None, conf=0.0)[source]¶ A set of data describing how a query fits into an intent
-
name
¶ str – Name of matched intent
-
sent
¶ str – The query after entity extraction
-
conf
¶ float – Confidence (from 0.0 to 1.0)
-
matches
¶ dict of str -> str – Key is the name of the entity and value is the extracted part of the sentence
-