How to use the questionary.prompts.common.Choice function in questionary

To help you get started, we’ve selected a few questionary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmbo / questionary / questionary / prompts / common.py View on Github external
def _init_choices(self, choices):
        # helper to convert from question format to internal format
        self.choices = []

        for i, c in enumerate(choices):
            choice = Choice.build(c)

            if self._is_selected(choice):
                self.selected_options.append(choice.value)

            if self.pointed_at is None and not choice.disabled:
                # find the first (available) choice
                self.pointed_at = i

            self.choices.append(choice)
github abhinavkashyap / sciwing / sciwing / commands / file_gen_utils.py View on Github external
def _get_word_embedding_type():
        embedding_type = questionary.select(
            message="Chose one of the embeddings available: ",
            choices=[
                Choice(title="random", value="random"),
                Choice(title="parscit", value="parscit"),
                Choice(title="glove_6B_100", value="glove_6B_100"),
                Choice(title="glove_6B_200", value="glove_6B_200"),
                Choice(title="glove_6B_300", value="glove_6B_300"),
            ],
        ).ask()
        return embedding_type
github abhinavkashyap / sciwing / sciwing / commands / new_dataset.py View on Github external
def create_new_dataset_interactive():
    """ Interactively creates new dataset files loaded with all the functionality.
    """
    msg_printer = wasabi.Printer()

    dataset_name = questionary.text(
        "Name of Dataset? [Please provide a valid python ClassName]",
        qmark="?",
        validate=is_valid_python_classname,
    ).ask()

    dataset_type = questionary.select(
        "Chose the type of dataset you are creating?",
        choices=[
            Choice(title="Classification", value="classification"),
            Choice(title="Sequence Labeling", value="seq_labeling"),
        ],
        default="classification",
    ).ask()

    if dataset_type == "classification":
        dataset_generator = ClassificationDatasetGenerator(dataset_name=dataset_name)
        dataset_generator.generate()
github tmbo / questionary / questionary / prompts / common.py View on Github external
def build(c: Union[Text, "Choice", Dict[Text, Any]]) -> "Choice":
        """Create a choice object from different representations."""

        if isinstance(c, Choice):
            return c
        elif isinstance(c, str):
            return Choice(c, c)
        else:
            return Choice(
                c.get("name"),
                c.get("value"),
                c.get("disabled", None),
                c.get("checked"),
                c.get("key"),
            )
github tmbo / questionary / questionary / prompts / common.py View on Github external
if isinstance(c, Choice):
            return c
        elif isinstance(c, str):
            return Choice(c, c)
        else:
            return Choice(
                c.get("name"),
                c.get("value"),
                c.get("disabled", None),
                c.get("checked"),
                c.get("key"),
            )


class Separator(Choice):
    """Used to space/separate choices group."""

    default_separator = "-" * 15

    def __init__(self, line: Optional[Text] = None):
        """Create a separator in a list.

        Args:
            line: Text to be displayed in the list, by default uses `---`.
        """

        self.line = line or self.default_separator
        super(Separator, self).__init__(self.line, None, "-")


class InquirerControl(FormattedTextControl):
github abhinavkashyap / sciwing / sciwing / commands / file_gen_utils.py View on Github external
def _get_vocab_pipes():
        vocab_pipe = questionary.checkbox(
            message="What batteries do you want with the dataset?",
            choices=[
                Choice(
                    title="word_vocab [Default] will always be included",
                    checked=True,
                    disabled=True,
                    value="word_vocab",
                ),
                Choice(
                    title="char_vocab - Usually included if character embeddings are needed",
                    value="char_vocab",
                ),
            ],
        ).ask()
        vocab_pipe.append("word_vocab")
        return vocab_pipe
github abhinavkashyap / sciwing / sciwing / commands / file_gen_utils.py View on Github external
def _get_tokenizer_type():
        tokenizer_type = questionary.select(
            message="What is the default tokenization that you would want to use?: ",
            choices=[
                Choice(
                    title="Vanilla (sentences are separated by space to form words)",
                    value="vanilla",
                ),
                Choice(title="Spacy tokenizer", value="spacy"),
            ],
            default="vanilla",
        ).ask()
        return tokenizer_type
github abhinavkashyap / sciwing / sciwing / commands / file_gen_utils.py View on Github external
def _get_word_embedding_type():
        embedding_type = questionary.select(
            message="Chose one of the embeddings available: ",
            choices=[
                Choice(title="random", value="random"),
                Choice(title="parscit", value="parscit"),
                Choice(title="glove_6B_100", value="glove_6B_100"),
                Choice(title="glove_6B_200", value="glove_6B_200"),
                Choice(title="glove_6B_300", value="glove_6B_300"),
            ],
        ).ask()
        return embedding_type
github tmbo / questionary / questionary / prompts / common.py View on Github external
def build(c: Union[Text, "Choice", Dict[Text, Any]]) -> "Choice":
        """Create a choice object from different representations."""

        if isinstance(c, Choice):
            return c
        elif isinstance(c, str):
            return Choice(c, c)
        else:
            return Choice(
                c.get("name"),
                c.get("value"),
                c.get("disabled", None),
                c.get("checked"),
                c.get("key"),
            )