public static < U , I > void saveDataModel ( final TemporalDataModelIF < U , I > dm , final String outfile , final boolean overwrite , String delimiter ) throws FileNotFoundException , UnsupportedEncodingException { if ( new File ( outfile ) . exists ( ) && ! overwrite ) { System . out . println ( "Ignoring " + outfile ) ; } else { PrintStream out = new PrintStream ( outfile , "UTF-8" ) ; for ( U user : dm . getUsers ( ) ) { for ( I item : dm . getUserItems ( user ) ) { Double pref = dm . getUserItemPreference ( user , item ) ; Iterable < Long > time = dm . getUserItemTimestamps ( user , item ) ; if ( time == null ) { out . println ( user + delimiter + item + delimiter + pref + delimiter + "-1" ) ; } else { for ( Long t : time ) { out . println ( user + delimiter + item + delimiter + pref + delimiter + t ) ; } } } } out . close ( ) ; } }
Method that saves a temporal data model to a file .