import logging


def load_sentences(path, name="source"):
    """Loads sentences from a plain (indexed) text file.

    Args:
        path (string): Path to the text file
        name (string): Name for error messages.
    """
    if not path:
        logging.fatal("Please specify the path to the %s sentences."
                      % name)
    else:
        try:
            with open(path) as f:
                return [list(map(int, line.strip().split())) for line in f]
        except ValueError:
            logging.fatal("Non-numeric characters in %s sentence file %s"
                          % (name, path))
        except IOError:
            logging.fatal("Could not read %s sentence file %s"
                          % (name, path))