<commit_before>package com.cowlark.sake.parser.core;

public class Location implements Comparable<Location>
{
	protected String _data;
	protected String _filename;
	protected int _offset;
	protected int _lineNumber;
	protected int _lineOffset;
	
	public Location(String data, String filename)
	{
		_data = data;
		_filename = filename;
		_offset = 0;
		_lineOffset = 0;
		_lineNumber = 1;
	}
	
	public Location(Location l)
	{
		_data = l._data;
		_filename = l._filename;
		_offset = l._offset;
		_lineOffset = l._lineOffset;
		_lineNumber = l._lineNumber;
	}
	
	@Override
	public int hashCode()
	{
		return _filename.hashCode() ^ (_offset << 16);
	}
	
	@Override
	public int compareTo(Location o)
	{
		// FIXME: need to compare more than just offsets
		
		if (_offset < o._offset)
			return -1;
		if (_offset > o._offset)
			return 1;
		return 0;
	}
	
	public String locationAsString()
	{
		return _filename + ":" + _lineNumber + "." +
			(_offset - _lineOffset);
	}
	
	public int codepointAtOffset(int offset)
	{
		int d = _offset + offset;
		
		if (d >= _data.length())
			return -1;
		<commit_msg>Added equals() operator for locations (just calls compareTo()).<commit_after>package com.cowlark.sake.parser.core;

public class Location implements Comparable<Location>
{
	protected String _data;
	protected String _filename;
	protected int _offset;
	protected int _lineNumber;
	protected int _lineOffset;
	
	public Location(String data, String filename)
	{
		_data = data;
		_filename = filename;
		_offset = 0;
		_lineOffset = 0;
		_lineNumber = 1;
	}
	
	public Location(Location l)
	{
		_data = l._data;
		_filename = l._filename;
		_offset = l._offset;
		_lineOffset = l._lineOffset;
		_lineNumber = l._lineNumber;
	}
	
	@Override
	public int hashCode()
	{
		return _filename.hashCode() ^ (_offset << 16);
	}
	
	@Override
	public int compareTo(Location o)
	{
		// FIXME: need to compare more than just offsets
		
		if (_offset < o._offset)
			return -1;
		if (_offset > o._offset)
			return 1;
		return 0;
	}
	
	@Override
	public boolean equals(Object obj)
	{
		return (compareTo((Location)obj) == 0);
	}
	
	public String locationAsString()
	{
		return _filename + ":" + _lineNumber + "." +
			(_offset - _lineOffset);
	}
	
	public int codepointAtOffset(int offset)
	{
		int d = _offset + offset;
		
		if (d >= _data.length())
			return -1;
		
{'fraction_non_alphanumeric': 0.108603066439523, 'fraction_numerical': 0.008091993185689948, 'mean_word_length': 3.398876404494382, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 9, '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': '4034493', 'n_tokens_mistral': 899, 'n_tokens_neox': 789, 'n_words': 223}