<commit_before>from functools import reduce
from collections import namedtuple
from itertools import chain
from graphics import save_svg

Point = namedtuple("Point", ["x", "y"])

class Map():
    """
    Representing a map which contains walls, a starting point and a target.
    """

    def __init__(self, filename=""):
        """
        Creates a map.

        filename: if given loads the map directly
        """
        self.map = list()
        self.start = Point(0, 0)
        self.target = Point(0, 0)
        if filename:
            self.load(filename)

    def __repr__(self):
        return str(self.map)

    def add_line(self, p, q):
        """
        Adds a line from p to q.

        p: line point
        q: line point
        """
        self.map.append((p, q))

    def load(self, filename):
        """
        Loads a map from a file.

        filename: the filename of the map file
        """
        for line in open(filename):
            split_line = line.split()
            if split_line[0].lower() == "w":
                p = Point(int(split_line[1]), int(split_line[2]))
                q = Point(int(split_line[3]), int(split_line[4]))
                self.add_line(p, q)
            elif split_line[0].lower() == "s":
                    self.start = Point(int(split_line[1]), int(split_line[2]))
            elif split_line[0].lower() == "t":
                    self.target = Point(int(split_line[1]), int(split_line[2]))
            else:
                raise Exception("Unsupported character at the beginning of line: " + line)
<commit_msg>Support for comments in maps.<commit_after>from functools import reduce
from collections import namedtuple
from itertools import chain
from graphics import save_svg

Point = namedtuple("Point", ["x", "y"])

class Map():
    """
    Representing a map which contains walls, a starting point and a target.
    """

    def __init__(self, filename=""):
        """
        Creates a map.

        filename: if given loads the map directly
        """
        self.map = list()
        self.start = Point(0, 0)
        self.target = Point(0, 0)
        if filename:
            self.load(filename)

    def __repr__(self):
        return str(self.map)

    def add_line(self, p, q):
        """
        Adds a line from p to q.

        p: line point
        q: line point
        """
        self.map.append((p, q))

    def load(self, filename):
        """
        Loads a map from a file.

        filename: the filename of the map file
        """
        for line in open(filename):
            split_line = line.split()
            if line[0] == "#":
                pass
            elif split_line[0].lower() == "w":
                p = Point(int(split_line[1]), int(split_line[2]))
                q = Point(int(split_line[3]), int(split_line[4]))
                self.add_line(p, q)
            elif split_line[0].lower() == "s":
                    self.start = Point(int(split_line[1]), int(split_line[2]))
            elif split_line[0].lower() == "t":
                    self.target = Point(int(split_line[1]), int(split_line[2]))
            else:
                raise Exception("Unsupported character at the beginning of line: " + line)

{'fraction_non_alphanumeric': 0.12461348175633889, 'fraction_numerical': 0.0095856524427953, 'mean_word_length': 1.8452066842568162, 'pattern_counts': {'":': 7, '<': 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': '4896024', 'n_tokens_mistral': 953, 'n_tokens_neox': 927, 'n_words': 279}