How to use the duden.search.get function in duden

To help you get started, we’ve selected a few duden 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 radomirbosak / duden / tests / test_online_attributes.py View on Github external
def generate_word_data():
    """
    Download actual words from duden corresponding to test words from `TEST_DATA_DIR`
    """
    data = []
    for filename in os.listdir(TEST_DATA_DIR):
        full_path = os.path.join(TEST_DATA_DIR, filename)

        # read only yaml files
        if not filename.endswith('.yaml'):
            continue

        # store real and expected result
        with open(full_path, 'r') as f:
            expected_dict = yaml.load(f, Loader=yaml.SafeLoader)
        parsed_word = get(expected_dict['urlname'])

        record = WordTestRecord(parsed_word, expected_dict)
        data.append(record)
    return data
github radomirbosak / duden / duden / cli.py View on Github external
for i, word in enumerate(words, 1):
            print('{} {}'.format(blue('{})'.format(i)), word))
        sys.exit(1)

    result_index = args.result if args.result is not None else 1

    # choose the correct result
    try:
        word_url_suffix = words[result_index - 1]
    except IndexError:
        print(red(_("No result with number {}.")).format(result_index))
        sys.exit(1)

    # fetch and parse the word
    try:
        word = get(word_url_suffix, cache=args.cache)
    except Exception as exception:  # pylint: disable=broad-except
        print(red(exception))
        sys.exit(1)

    display_word(word, args)