<commit_before>"""
Print messages as they arrive on the input port.

Input.receive() blocks until there is a message available. Input.poll()
will return how many messages you can safely read without blocking, so
you can implement nonblocking read with:

    while 1:
        for _ in range(port.poll()):
            message = port.receive()
            print(message)

        # ... do something else
"""

from __future__ import print_function
import sys
import mido
from mido.portmidi import Input

if sys.argv[1:]:
    portname = sys.argv[1]
else:
    portname = None  # Use default port

try:
    for message in Input(portname):
        print('{}  {}'.format(message.hex(), message))
except KeyboardInterrupt:
    pass
<commit_msg>Updated example.<commit_after>"""
Print messages as they arrive on the input port.

Input.receive() blocks until there is a message available. Input.poll()
will return how many messages you can safely read without blocking, so
you can implement nonblocking read with:

    while 1:
        for _ in range(port.poll()):
            message = port.receive()
            print(message)

        # ... do something else for a while
"""

from __future__ import print_function
import sys
import mido
from mido.portmidi import Input

if sys.argv[1:]:
    portname = sys.argv[1]
else:
    portname = None  # Use default port

try:
    for message in Input(portname):
        print('{}  {}'.format(message.hex(), message))
except KeyboardInterrupt:
    pass

{'fraction_non_alphanumeric': 0.09372892784895483, 'fraction_numerical': 0.004045853000674309, 'mean_word_length': 3.076923076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2707617', 'n_tokens_mistral': 425, 'n_tokens_neox': 412, 'n_words': 166}