diff --git a/rival-core/src/main/java/net/recommenders/rival/core/DataModelUtils.java b/rival-core/src/main/java/net/recommenders/rival/core/DataModelUtils.java index c5a1d6d3..da129db8 100644 --- a/rival-core/src/main/java/net/recommenders/rival/core/DataModelUtils.java +++ b/rival-core/src/main/java/net/recommenders/rival/core/DataModelUtils.java @@ -39,16 +39,17 @@ private DataModelUtils() { /** * Method that saves a data model to a file. * - * @param dm the data model - * @param outfile file where the model will be saved + * @param dm the data model + * @param outfile file where the model will be saved * @param overwrite flag that indicates if the file should be overwritten - * @param type of users - * @param type of items - * @throws FileNotFoundException when outfile cannot be used. + * @param delimiter field delimiter + * @param type of users + * @param type of items + * @throws FileNotFoundException when outfile cannot be used. * @throws UnsupportedEncodingException when the requested encoding (UTF-8) - * is not available. + * is not available. */ - public static void saveDataModel(final DataModelIF dm, final String outfile, final boolean overwrite) + public static void saveDataModel(final DataModelIF dm, final String outfile, final boolean overwrite, final String delimiter) throws FileNotFoundException, UnsupportedEncodingException { if (new File(outfile).exists() && !overwrite) { System.out.println("Ignoring " + outfile); @@ -59,7 +60,7 @@ public static void saveDataModel(final DataModelIF dm, final String for (Entry e : userPrefModel.entrySet()) { I item = e.getKey(); Double pref = userPrefModel.get(item); - out.println(user + "\t" + item + "\t" + pref + "\t-1"); + out.println(user + delimiter + item + delimiter + pref + delimiter); } } out.close(); @@ -69,16 +70,17 @@ public static void saveDataModel(final DataModelIF dm, final String /** * Method that saves a temporal data model to a file. * - * @param dm the data model - * @param outfile file where the model will be saved + * @param dm the data model + * @param outfile file where the model will be saved * @param overwrite flag that indicates if the file should be overwritten - * @param type of users - * @param type of items - * @throws FileNotFoundException when outfile cannot be used. + * @param delimiter field delimiter + * @param type of users + * @param type of items + * @throws FileNotFoundException when outfile cannot be used. * @throws UnsupportedEncodingException when the requested encoding (UTF-8) - * is not available. + * is not available. */ - public static void saveDataModel(final TemporalDataModelIF dm, final String outfile, final boolean overwrite) + public static void saveDataModel(final TemporalDataModelIF dm, final String outfile, final boolean overwrite, String delimiter) throws FileNotFoundException, UnsupportedEncodingException { if (new File(outfile).exists() && !overwrite) { System.out.println("Ignoring " + outfile); @@ -95,10 +97,10 @@ public static void saveDataModel(final TemporalDataModelIF dm, fina time = userTimeModel.get(item); } if (time == null) { - out.println(user + "\t" + item + "\t" + pref + "\t-1"); + out.println(user + delimiter + item + delimiter + pref + delimiter + "-1"); } else { for (Long t : time) { - out.println(user + "\t" + item + "\t" + pref + "\t" + t); + out.println(user + delimiter + item + delimiter + pref + delimiter + t); } } }