domain_classification_doc

Contents:

  • Getting Started with Domain Classifier
  • Menu Navigator
  • Base Task Manager
  • Task Manager
  • Data Manager
  • Query Manager
  • Classifier
  • Custom Model
  • Custom Model MLP
  • Inference
  • Preprocessor
  • Metrics
  • Plotter
  • Main Window
  • Analyze Keywords Window
  • Constants
  • Get Keywords Window
  • Get Topics List Window
  • Messages
  • Output Wrapper
  • Util
  • Worker Signals
  • Worker
domain_classification_doc
  • Menu Navigator
  • View page source

Menu Navigator

A generic class to manage the user navigation through a multilevel options menu.

Created on March. 04, 2019

@author: Jesús Cid Sueiro

Based on former menu manager scripts by Jerónimo Arenas.

class src.menu_navigator.menu_navigator.MenuNavigator(tm, path2menu, paths2data=None)

Bases: object

A class to manage the user navigation through a multilevel options menu.

The structure of multilevel menu options with their associated actions and parameters should be defined in a yaml file.

A taskmanager class is required to take the selected actions with the given parameters.

__init__(tm, path2menu, paths2data=None)

Initializes a menu navigator.

Parameters
  • tm (object) – A task manager object, that will be in charge of executing all actions selected by the user through the menu interaction. Thus, it must contain: (1) One action method per method specified in the menu structure (2) Data collection methods, required for some menus with dynamic options.

  • path2menu (str) – The route to the yaml file containing the menu structure

  • paths2data (dict or None, optional (default=None)) – A dictionary of paths to data repositories. The key is a name of the path, and the value is the path.

__weakref__

list of weak references to the object (if defined)

clear()

Cleans terminal window

front_page(title)

Prints a simple title heading the application user screen

Parameters

title (str) – Title message to be printed

get_options(tasks_only=False)

Returns a list of all possible actions.

Parameters

tasks_only (boolean, optional (default=True)) – If true, only options that correspond to task names (methods from the task_manager class) are returned

Returns

options – A list of possible action. Is action is a tuple (name_of_the_action, title), where title is the description of the action taken from the options_menu file.

Return type

list of tuple (str, str)

navigate(option=None, active_options=None, iterate=True)

Manages the menu navigation loop

Parameters
  • option (str, optional (default=None)) – Initial selection from the menu of options. If None, the initial selection will be requested to the user

  • active_options (list or None, optional (default=None)) – List of option keys indicating the available options to print. If None, all options are shown.

  • iterate (boolean, optional (default=True)) – If true, a sequence of menu options is shown to the user until the zero (exit) menu option is selected by the user If false, the

query_options(options, active_options=None, msg=None, zero_option='exit')

Prints a heading and the subset of options indicated in the list of active_options, ask the user and returns the user selection

Parameters
  • options (dict) – A dictionary of options

  • active_options (list or None, optional (default=None)) – List of option keys indicating the available options to print. If None, all options are shown.

  • msg (str or None, optional (default=None)) – Heading message to be printed before the list of available options

  • zero_option (str {‘exit’, ‘up’}, optional (default=’exit’)) – If ‘exit’, an exit option is shown If ‘up’, an option to go back to the main menu

Returns

option – Selected option

Return type

str

request_confirmation(msg='     Are you sure?')

Request confirmation from user

Parameters

msg (str, optional (default=” Are you sure?”)) – Message printed to request confirmation

Returns

r – User respones

Return type

str {‘yes’, ‘no’}

Previous Next

© Copyright 2022, J. Cid-Sueiro, L. Calvo, J.A. Espinosa, T. Ahlers, M. A. Vázquez.

Built with Sphinx using a theme provided by Read the Docs.