@staticmethod
def read(filename, format='json'):
    """ return an Automaton build with attributes read from a file

        - Input:

        :param str filename: the name of the input file.
        :param str format: 'json' or yaml'

        - Output:

        :returns: the output automaton
        :rtype: Automaton
        """
    from splearn.serializer import Serializer
    with open(filename) as infile:
        datastr = infile.read()
    if format == 'json':
        return Serializer.json_to_data(datastr)
    if format == 'yaml':
        return Serializer.yaml_to_data(datastr)
    raise ValueError('Invalid input format. Should be "json" or "yaml"')
