// Path: src/jurbano/melodyshape/model/Melody.java
// @SuppressWarnings("serial")
// public class Melody extends ArrayList<Note>
// {
// 	protected String id;
// 	
// 	/**
// 	 * Gets the unique ID of the melody.
// 	 * 
// 	 * @return the ID of the melody.
// 	 */
// 	public String getId() {
// 		return this.id;
// 	}
// 	
// 	/**
// 	 * Constructs a new and empty {@code Melody} object.
// 	 * 
// 	 * @param id
// 	 *            the unique ID of the melody.
// 	 */
// 	public Melody(String id) {
// 		this.id = id;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return "Melody [id=" + id + ", size=" + this.size() + "]";
// 	}
// }
// 
// Path: src/jurbano/melodyshape/model/Note.java
// public class Note
// {
// 	protected long duration;
// 	protected long onset;
// 	protected byte pitch;
// 	protected double restFraction;
// 	
// 	/**
// 	 * Constructs a new {@code Note}.
// 	 * 
// 	 * @param pitch
// 	 *            the pitch of the note.
// 	 * @param onset
// 	 *            the onset time of the note.
// 	 * @param duration
// 	 *            the duration of the note.
// 	 * @param restFraction
// 	 *            the fraction of the note's duration that corresponds do rests.
// 	 */
// 	public Note(byte pitch, long onset, long duration, double restFraction) {
// 		this.pitch = pitch;
// 		this.onset = onset;
// 		this.duration = duration;
// 		this.restFraction = restFraction;
// 	}
// 	
// 	/**
// 	 * Gets the duration of the note.
// 	 * 
// 	 * @return the duration of the note.
// 	 */
// 	public long getDuration() {
// 		return this.duration;
// 	}
// 	
// 	/**
// 	 * Gets the onset time of the note.
// 	 * 
// 	 * @return the onset time of the note.
// 	 */
// 	public long getOnset() {
// 		return this.onset;
// 	}
// 	
// 	/**
// 	 * Gets the pitch of the note.
// 	 * 
// 	 * @return the pitch of the note.
// 	 */
// 	public byte getPitch() {
// 		return this.pitch;
// 	}
// 	
// 	/**
// 	 * Gets the fraction of the note's duration that corresponds to rests.
// 	 * 
// 	 * @return the rest fraction.
// 	 */
// 	public double getRestFraction() {
// 		return this.restFraction;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return "Note [@" + this.onset + ": pitch=" + this.pitch + ", duration=" + this.duration + ", rest=" + this.restFraction + "]";
// 	}
// 	
// }


import java.util.ArrayList;
import jurbano.melodyshape.model.Melody;
import jurbano.melodyshape.model.Note;

// Copyright (C) 2013, 2016  Julián Urbano <urbano.julian@gmail.com>
// Distributed under the terms of the MIT License.

package jurbano.melodyshape.comparison;



/**
 * An n-gram of notes, that is, a sequence of n consecutive {@link Note}
 * objects.
 * 
 * @author Julián Urbano
 * @see Note
 */
@SuppressWarnings("serial")
public class NGram extends ArrayList<Note>
{
	/**
	 * Gets a null n-gram of this object. A null n-gram contains the same notes
	 * but with all notes set to the pitch of this n-gram's first note.
	 * 
	 * @return the null n-gram.
	 */
	public NGram getNullSpan() {
		NGram s = new NGram();
		for (Note n : this)
			s.add(new Note(this.get(0).getPitch(), n.getOnset(), n.getDuration(), n.getRestFraction()));
		return s;
	}
	
	/**
	 * Gets the sequence of {@code n}-grams, each containing {@code n}
	 * {@link Note} objects, from the {@link Melody} specified.
	 * 
	 * @param m
	 *            the melody.
	 * @param n
	 *            the length of the n-grams.
	 * @return the sequence of {@code n}-grams.
	 */
	public static ArrayList<NGram> getNGrams(Melody m, int n) {
		ArrayList<NGram> list = new ArrayList<NGram>();

		for (int i = 0; i <= m.size() - n; i++) {
			NGram gram = new NGram();
			for (int j = 0; j < n; j++)
				gram.add(m.get(i + j));
			list.add(gram);
		}

		return list;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString() {
		String res = "";

// Path: src/jurbano/melodyshape/model/Melody.java
// @SuppressWarnings("serial")
// public class Melody extends ArrayList<Note>
// {
// 	protected String id;
// 	
// 	/**
// 	 * Gets the unique ID of the melody.
// 	 * 
// 	 * @return the ID of the melody.
// 	 */
// 	public String getId() {
// 		return this.id;
// 	}
// 	
// 	/**
// 	 * Constructs a new and empty {@code Melody} object.
// 	 * 
// 	 * @param id
// 	 *            the unique ID of the melody.
// 	 */
// 	public Melody(String id) {
// 		this.id = id;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return "Melody [id=" + id + ", size=" + this.size() + "]";
// 	}
// }
// 
// Path: src/jurbano/melodyshape/model/Note.java
// public class Note
// {
// 	protected long duration;
// 	protected long onset;
// 	protected byte pitch;
// 	protected double restFraction;
// 	
// 	/**
// 	 * Constructs a new {@code Note}.
// 	 * 
// 	 * @param pitch
// 	 *            the pitch of the note.
// 	 * @param onset
// 	 *            the onset time of the note.
// 	 * @param duration
// 	 *            the duration of the note.
// 	 * @param restFraction
// 	 *            the fraction of the note's duration that corresponds do rests.
// 	 */
// 	public Note(byte pitch, long onset, long duration, double restFraction) {
// 		this.pitch = pitch;
// 		this.onset = onset;
// 		this.duration = duration;
// 		this.restFraction = restFraction;
// 	}
// 	
// 	/**
// 	 * Gets the duration of the note.
// 	 * 
// 	 * @return the duration of the note.
// 	 */
// 	public long getDuration() {
// 		return this.duration;
// 	}
// 	
// 	/**
// 	 * Gets the onset time of the note.
// 	 * 
// 	 * @return the onset time of the note.
// 	 */
// 	public long getOnset() {
// 		return this.onset;
// 	}
// 	
// 	/**
// 	 * Gets the pitch of the note.
// 	 * 
// 	 * @return the pitch of the note.
// 	 */
// 	public byte getPitch() {
// 		return this.pitch;
// 	}
// 	
// 	/**
// 	 * Gets the fraction of the note's duration that corresponds to rests.
// 	 * 
// 	 * @return the rest fraction.
// 	 */
// 	public double getRestFraction() {
// 		return this.restFraction;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return "Note [@" + this.onset + ": pitch=" + this.pitch + ", duration=" + this.duration + ", rest=" + this.restFraction + "]";
// 	}
// 	
// }


// Path: src/jurbano/melodyshape/comparison/NGram.java
import java.util.ArrayList;
import jurbano.melodyshape.model.Melody;
import jurbano.melodyshape.model.Note;

// Copyright (C) 2013, 2016  Julián Urbano <urbano.julian@gmail.com>
// Distributed under the terms of the MIT License.

package jurbano.melodyshape.comparison;



/**
 * An n-gram of notes, that is, a sequence of n consecutive {@link Note}
 * objects.
 * 
 * @author Julián Urbano
 * @see Note
 */
@SuppressWarnings("serial")
public class NGram extends ArrayList<Note>
{
	/**
	 * Gets a null n-gram of this object. A null n-gram contains the same notes
	 * but with all notes set to the pitch of this n-gram's first note.
	 * 
	 * @return the null n-gram.
	 */
	public NGram getNullSpan() {
		NGram s = new NGram();
		for (Note n : this)
			s.add(new Note(this.get(0).getPitch(), n.getOnset(), n.getDuration(), n.getRestFraction()));
		return s;
	}
	
	/**
	 * Gets the sequence of {@code n}-grams, each containing {@code n}
	 * {@link Note} objects, from the {@link Melody} specified.
	 * 
	 * @param m
	 *            the melody.
	 * @param n
	 *            the length of the n-grams.
	 * @return the sequence of {@code n}-grams.
	 */
	public static ArrayList<NGram> getNGrams(Melody m, int n) {
		ArrayList<NGram> list = new ArrayList<NGram>();

		for (int i = 0; i <= m.size() - n; i++) {
			NGram gram = new NGram();
			for (int j = 0; j < n; j++)
				gram.add(m.get(i + j));
			list.add(gram);
		}

		return list;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString() {
		String res = "";

		for (Note n : this)
