Thanks Sebastian.

Although I got the FileDataModel updating correctly after following your
advice, everything seems to point that I will need to use a database to
back my dataModel.


On Mon, Mar 3, 2014 at 3:47 PM, Sebastian Schelter <s...@apache.org> wrote:

> I think it depends on the difference between the time of the call to
> refresh() and the last modified time of the file.
>
> --sebastian
>
>
> On 03/03/2014 04:45 PM, Juan José Ramos wrote:
>
>> Thanks for the reply, Sebastian.
>>
>> I do not have concurrent updates, but they actually may happen very, very
>> close in time.
>>
>> Would the fact of adding the new preferences to new files or appending to
>> the existing one make any difference or does everything depends on the
>> time
>> elapsed between two calls to recommender.refresh(null)?
>>
>> Many thanks.
>>
>>
>> On Mon, Mar 3, 2014 at 1:18 PM, Sebastian Schelter <s...@apache.org>
>> wrote:
>>
>>  Hi Juan,
>>>
>>> IIRC then FileDataModel has a parameter that determines how much time
>>> must
>>> have been spent since the last modification of the underlying file. You
>>> can
>>> also directly append new data to the original file.
>>>
>>> If you want a to have a DataModel that can be concurrently updated, I
>>> suggest your data to a database.
>>>
>>> --sebastian
>>>
>>>
>>> On 03/02/2014 11:11 PM, Juan José Ramos wrote:
>>>
>>>  I am having issues refreshing my recommender, in particular with the
>>>> DataModel.
>>>>
>>>> I am using a FileDataModel and a GenericItemBasedRecommender that also
>>>> has
>>>> a CachingItemSimilarity wrapping a FileItemSimilarity. But for the test
>>>> I
>>>> am running I am making things even simpler.
>>>>
>>>> By the time I instantiate the recommender, these two files are in the
>>>> FileSystem:
>>>> data/datamodel.txt
>>>> 0,1,0.0
>>>>
>>>> data/datamodel.0.txt
>>>> 0,2,1.0
>>>>
>>>> And then I run the code you can find below:
>>>>
>>>> ------------------------------------------------------------
>>>> -----------------------------------------------------------
>>>>
>>>>     FileDataModel dataModel = new FileDataModel(new
>>>> File("data/dataModel.txt"
>>>> ));
>>>>
>>>>      FileItemSimilarity itemSimilarity = new FileItemSimilarity(new
>>>> File(
>>>> "data/similarities"));
>>>>
>>>>    GenericItemBasedRecommender itemRecommender =
>>>> newGenericItemBasedRecommender(dataModel, itemSimilarity);
>>>>
>>>>
>>>>      System.out.println("Number of users in the system: " +
>>>> itemRecommender.getDataModel().getNumUsers()+" and " +
>>>> itemRecommender.getDataModel().getNumItems() + "items");
>>>>
>>>>    FileWriter writer = new FileWriter(new File("data/dataModel.1.txt"));
>>>>
>>>>    writer.write("1,2,1.0\r");
>>>>
>>>>    writer.close();
>>>>
>>>>      writer = new FileWriter(new File("data/dataModel.2.txt"));
>>>>
>>>>    writer.write("2,2,1.0\r");
>>>>
>>>>    writer.close();
>>>>
>>>>      writer = new FileWriter(new File("data/dataModel.3.txt"));
>>>>
>>>>    writer.write("3,2,1.0\r");
>>>>
>>>>    writer.close();
>>>>
>>>>      writer = new FileWriter(new File("data/dataModel.4.txt"));
>>>>
>>>>    writer.write("4,2,1.0\r");
>>>>
>>>>    writer.close();
>>>>
>>>>      writer = new FileWriter(new File("data/dataModel.5.txt"));
>>>>
>>>>    writer.write("5,2,1.0\r");
>>>>
>>>>    writer.close();
>>>>
>>>>      writer = new FileWriter(new File("data/dataModel.6.txt"));
>>>>
>>>>    writer.write("6,2,1.0\r");
>>>>
>>>>    writer.close();
>>>>
>>>>    itemRecommender.refresh(null);
>>>>
>>>>    System.out.println("Number of users in the system: " +
>>>> itemRecommender.getDataModel().getNumUsers()+" and " +
>>>> itemRecommender.getDataModel().getNumItems() + "items");
>>>>
>>>> ------------------------------------------------------------
>>>> -----------------------------------------------------------
>>>>
>>>> The output is the same in both println: Number of users in the system: 2
>>>> and 2items. So, only the information from the files that were on the
>>>> system
>>>> by the time I run this test seem to get loaded on the DataModel.
>>>>
>>>> What can be causing that? Is there a maximum number of updates a
>>>> FileDataModel can take up in every refresh?
>>>>
>>>> Could it be that actually by the time I call
>>>> itemRecommender.refresh(null)
>>>> the files have not been written to the FileSystem?
>>>>
>>>> Should I be calling refresh in a different manner?
>>>>
>>>> Thank you for your help.
>>>>
>>>>
>>>>
>>>
>>
>

Reply via email to