Skip to content

Commit

Permalink
Refactor to avoid deprecated API of commons-cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-urbano committed Aug 8, 2016
1 parent 9939794 commit b62c886
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 68 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
MelodyShape 1.4, XX-Aug-2016
MelodyShape 1.4, 08-Aug-2016
============================
* Changed to MIT License.
+ Use Maven to build.

MelodyShape 1.3, 25-Oct-2015
============================
+ Added support for the MIREX 2015 submissions.
* Fixed #5: enclose erroneous arguments in single quotes.
* Fixed #4: show the name of files that fail to load.
* Fixed #2: alignment score in LocalAligner.
- Fixed #5: enclose erroneous arguments in single quotes.
- Fixed #4: show the name of files that fail to load.
- Fixed #2: alignment score in LocalAligner.

MelodyShape 1.2, 21-Oct-2014
============================
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ All these algorithms have obtained the best results in the [MIREX](http://music-

MelodyShape can be run both as a graphical user interface and as a command line tool:

$ java -jar melodyshape-1.3.jar
usage: melodyshape-1.3 -q <file/dir> -c <dir> -a <name> [-k <cutoff>] [-l] [-t <num>] [-v] [-vv] [-gui] [-h]
$ java -jar melodyshape-1.4.jar
usage: melodyshape-1.4 -q <file/dir> -c <dir> -a <name> [-k <cutoff>] [-l] [-t <num>] [-v] [-vv] [-gui] [-h]
-q <file/dir> path to the query melody or melodies.
-c <dir> path to the collection of documents.
-a <name> algorithm to run:
Expand All @@ -26,7 +26,7 @@ MelodyShape can be run both as a graphical user interface and as a command line
-gui run with graphical user interface.
-h show this help message.

MelodyShape 1.3 Copyright (C) 2013-2016 Julian Urbano <[email protected]>
MelodyShape 1.4 Copyright (C) 2013-2016 Julian Urbano <[email protected]>
This program is distributed under the terms of the MIT License.

A detailed user manual in PDF is available from the [releases page](https://github.com/julian-urbano/MelodyShape/releases).
Expand All @@ -37,7 +37,9 @@ Dependencies
* The MelodyShape library uses the [Math library](http://commons.apache.org/proper/commons-math/) from Apache Commons.
* The command line tool uses the [CLI library](http://commons.apache.org/proper/commons-cli/) from Apache Commons.

Dependencies and building can be managed directly with Maven.

Current Version
---------------

The current version is [MelodyShape 1.3](https://github.com/julian-urbano/MelodyShape/releases/tag/v1.3), and it is compiled for Java 7. It can be redistributed and/or modified under the terms of the MIT License. Javadoc documentation and a user manual are available as well.
The current version is [MelodyShape 1.4](https://github.com/julian-urbano/MelodyShape/releases/tag/v1.4), and it is compiled for Java 7. It can be redistributed and/or modified under the terms of the MIT License. Javadoc documentation and a user manual are available as well.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>jurbano</groupId>
<artifactId>melodyshape</artifactId>
<version>1.3</version>
<version>1.4</version>
<name>MelodyShape</name>
<description>A Library and Tool for Symbolic Melodic Similarity based on Shape Similarity</description>
<url>https://github.com/julian-urbano/MelodyShape</url>
Expand Down
4 changes: 2 additions & 2 deletions src/jurbano/melodyshape/MelodyShape.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MelodyShape
/**
* The release version number.
*/
public static String VERSION = "1.3";
public static String VERSION = "1.4";
/**
* The copyright notice, including date and version.
*/
Expand Down Expand Up @@ -91,7 +91,7 @@ public static ArrayList<Melody> readQueries(File path) {

/**
* Returns a melody collection found in a path.
*
*
* @param path
* the path to the directory containing all melodies.
* @return the melody collection.
Expand Down
6 changes: 3 additions & 3 deletions src/jurbano/melodyshape/ranking/UntieResultRanker.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

package jurbano.melodyshape.ranking;

import java.util.Arrays;
import java.util.Comparator;

import jurbano.melodyshape.comparison.MelodyComparer;
import jurbano.melodyshape.model.Melody;

import java.util.Arrays;
import java.util.Comparator;

/**
* A ranking function that sorts by decreasing similarity score, then by
* decreasing similarity according to a second {@link MelodyComparer}, then by
Expand Down
56 changes: 20 additions & 36 deletions src/jurbano/melodyshape/ui/ConsoleUIObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,17 @@

package jurbano.melodyshape.ui;

import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;

import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

import jurbano.melodyshape.MelodyShape;
import jurbano.melodyshape.comparison.MelodyComparer;
import jurbano.melodyshape.model.Melody;
import jurbano.melodyshape.model.MelodyCollection;
import jurbano.melodyshape.ranking.Result;
import jurbano.melodyshape.ranking.ResultRanker;
import org.apache.commons.cli.*;

import java.io.File;
import java.io.PrintWriter;
import java.util.*;

/**
* Runs an algorithm with options specified through the command line.
Expand Down Expand Up @@ -68,29 +56,25 @@ public ConsoleUIObserver(String[] args) {

this.options = new Options();
// required arguments
this.options.addOption(OptionBuilder.isRequired().hasArg().withArgName("file/dir")
.withDescription("path to the query melody or melodies.").create("q"));
this.options.addOption(OptionBuilder.isRequired().hasArg().withArgName("dir")
.withDescription("path to the collection of documents.").create("c"));
this.options.addOption(OptionBuilder.isRequired().hasArg().withArgName("name")
.withDescription(
"algorithm to run:" + "\n- 2010-domain, 2010-pitchderiv, 2010-shape"
this.options.addOption(Option.builder("q").required().hasArg().argName("file/dir")
.desc("path to the query melody or melodies.").build());
this.options.addOption(Option.builder("c").required().hasArg().argName("dir")
.desc("path to the collection of documents.").build());
this.options.addOption(Option.builder("a").required().hasArg().argName("name")
.desc("algorithm to run:" + "\n- 2010-domain, 2010-pitchderiv, 2010-shape"
+ "\n- 2011-shape, 2011-pitch, 2011-time"
+ "\n- 2012-shapeh, 2012-shapel, 2012-shapeg, 2012-time, 2012-shapetime"
+ "\n- 2013-shapeh, 2013-time, 2013-shapetime"
+ "\n- 2014-shapeh, 2014-time, 2014-shapetime"
+ "\n- 2015-shapeh, 2015-time, 2015-shapetime").create("a"));
+ "\n- 2015-shapeh, 2015-time, 2015-shapetime").build());
// optional arguments
this.options.addOption(OptionBuilder
.withDescription("show results in a single line (omits similarity scores).").create("l"));
this.options.addOption(OptionBuilder.hasArg().withArgName("num")
.withDescription("run a fixed number of threads.").create("t"));
this.options.addOption(OptionBuilder.hasArg().withArgName("cutoff")
.withDescription("number of documents to retrieve.").create("k"));
this.options.addOption(OptionBuilder.withDescription("verbose, to stderr.").create("v"));
this.options.addOption(OptionBuilder.withDescription("verbose a lot, to stderr.").create("vv"));
this.options.addOption(OptionBuilder.withDescription("show this help message.").create("h"));
this.options.addOption(OptionBuilder.withDescription("run with graphical user interface.").create("gui"));
this.options.addOption(Option.builder("l").desc("show results in a single line (omits similarity scores).").build());
this.options.addOption(Option.builder("t").hasArg().argName("num").desc("run a fixed number of threads.").build());
this.options.addOption(Option.builder("k").hasArg().argName("cutoff").desc("number of documents to retrieve.").build());
this.options.addOption(Option.builder("v").desc("verbose, to stderr.").build());
this.options.addOption(Option.builder("vv").desc("verbose a lot, to stderr.").build());
this.options.addOption(Option.builder("h").desc("show this help message.").build());
this.options.addOption(Option.builder("gui").desc("run with graphical user interface.").build());
}

/**
Expand Down Expand Up @@ -168,7 +152,7 @@ public void start() {
}

protected boolean parseArguments() {
CommandLineParser parser = new BasicParser();
CommandLineParser parser = new DefaultParser();

// help? Cannot wait to parse args because it will throw exception
// before
Expand Down
Loading

0 comments on commit b62c886

Please sign in to comment.