<commit_before>#! /usr/bin/python
# -*- coding: utf-8 -*-

from __future__ import division
import sys
import math
import pygena
import copy
import random
import pickle


class ItemType(object):
    def __init__(self, height, length, text="", rotatable=False):
        self.h = height
        self.w = length
        self.rotatable = rotatable
        self.text = text

    def __repr__(self):
        return "ItemType(%d,%d,'%s')" % (self.w,self.h,self.text)

    # do not make deep copies of the types
    def __deepcopy__(self,memo):
        memo[id(self)] = self
        return self

class Item(object):
    def __init__(self,type_,rotated=False):
        self.type = type_
        self.rotated = rotated
        # create a unique identifier for later matching of duplicates
        self.id = id(self)
        self.x = -1
        self.y = -1

    def dump(self,indent=""):
        print indent+str(self)

    def rotate(self):
        self.rotated = not self.rotated

    w = property(lambda self: (self.type.w,self.type.h)[self.rotated])
    h = property(lambda self: (self.type.h,self.type.w)[self.rotated])
    text = property(lambda self: self.type.text)
    rotatable = property(lambda self: self.type.rotatable)

    def area(self):
        return self.h*self.w

    def covered_area(self):
        return self.area()

    def update_strip_space(self,H,W):
        """
        Nothing to update for an Item
        """
        return H,W

    def overlaps(self,other):
        """
        Return true if the items overlap
        """

        x_min = max(self.x,other.x)
        y_min = max(self.y,other.y)
        x_max = min(self.x+self.w,other.x+other.w)
        y_max = min(self.y+self.h,other.y+other.h)

        return x_min<x_max and y_min<y_max

    def __repr__(self):
        return "Item(id=%d,x=%d,y=%d,type_=%r,rotated=%s)" % \
                (self.id,self.x,self.y,self.type,('False','True')[self.rotated])
    
    def __str__(self):
        return "Item (%d,%d,%s,%s,%s) of type %r" % \
                (self.w,self.h,self.x,self.y,('F','T')[self.rotated],self.type)



class Strip(list):
    """
    Strip is a horizontal or vertical line of items and other strips.
    """

    min_item_height = 0
    min_item_width = 0
<commit_msg>clarified item str output<commit_after>#! /usr/bin/python
# -*- coding: utf-8 -*-

from __future__ import division
import sys
import math
import pygena
import copy
import random
import pickle


class ItemType(object):
    def __init__(self, height, length, text="", rotatable=False):
        self.h = height
        self.w = length
        self.rotatable = rotatable
        self.text = text

    def __repr__(self):
        return "ItemType(%d,%d,'%s')" % (self.w,self.h,self.text)

    # do not make deep copies of the types
    def __deepcopy__(self,memo):
        memo[id(self)] = self
        return self

class Item(object):
    def __init__(self,type_,rotated=False):
        self.type = type_
        self.rotated = rotated
        # create a unique identifier for later matching of duplicates
        self.id = id(self)
        self.x = -1
        self.y = -1

    def dump(self,indent=""):
        print indent+str(self)

    def rotate(self):
        self.rotated = not self.rotated

    w = property(lambda self: (self.type.w,self.type.h)[self.rotated])
    h = property(lambda self: (self.type.h,self.type.w)[self.rotated])
    text = property(lambda self: self.type.text)
    rotatable = property(lambda self: self.type.rotatable)

    def area(self):
        return self.h*self.w

    def covered_area(self):
        return self.area()

    def update_strip_space(self,H,W):
        """
        Nothing to update for an Item
        """
        return H,W

    def overlaps(self,other):
        """
        Return true if the items overlap
        """

        x_min = max(self.x,other.x)
        y_min = max(self.y,other.y)
        x_max = min(self.x+self.w,other.x+other.w)
        y_max = min(self.y+self.h,other.y+other.h)

        return x_min<x_max and y_min<y_max

    def __str__(self):
        return "I(id%d,w%s,h%s,x%s,y%s,r%s,t%s,txt'%s')" % \
                (self.id,self.w,self.h,self.x,self.y,('F','T')[self.rotated],id(self.type),self.text)



class Strip(list):
    """
    Strip is a horizontal or vertical line of items and other strips.
    """

    min_item_height = 0
    min_item_width = 0

{'fraction_non_alphanumeric': 0.1366742596810934, 'fraction_numerical': 0.002277904328018223, 'mean_word_length': 2.388117283950617, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1401461', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1485, 'n_words': 340}