public class ExternalProcessItemScorerBuilder extends Object implements javax.inject.Provider<ItemScorer>
PrecomputedItemScorer
using an external process.
This class implements Provider
, but is not itself instantiable with
dependency injection.
The external process can receive string arguments, as well as arguments derived from rating, user, and item DAOs. For DAOs, the contents of the DAO will be written to a file and that file will be provided on the command line.
The external process is expected to produce its scores on standard output in comma-separated user, item, score format.
Warning: if you use this code to build item scorers in the evaluator, be careful with the file-based caching (componentCacheDirectory). The cache will likely not rerun the external process.
Constructor and Description |
---|
ExternalProcessItemScorerBuilder() |
public ExternalProcessItemScorerBuilder setWorkingDir(File dir)
dir
- The working directory.public ExternalProcessItemScorerBuilder setWorkingDir(String dir)
dir
- The working directory.public ExternalProcessItemScorerBuilder setExecutable(String exe)
exe
- The name or path of the executable to run.public ExternalProcessItemScorerBuilder addArgument(String arg)
arg
- The argument to add.public ExternalProcessItemScorerBuilder addArguments(Collection<String> args)
args
- The arguments to add.public ExternalProcessItemScorerBuilder addArguments(String... args)
args
- The arguments to add.public ExternalProcessItemScorerBuilder addRatingFileArgument(EventDAO ratings, @Nullable String name)
ratings
- A DAO of ratings to provide to the process. Only ratings will be considered.name
- A file name (optional). If provided, the ratings will be stored in this file
name in the working directory; otherwise, a fresh name will be generated.public ExternalProcessItemScorerBuilder addRatingFileArgument(EventDAO ratings)
ratings
- A DAO of ratings to provide to the process. Only ratings will be considered.public ExternalProcessItemScorerBuilder addItemFileArgument(ItemDAO items, @Nullable String name)
items
- A DAO of items to provide to the process.name
- A file name (optional). If provided, the items will be stored in this file
name in the working directory; otherwise, a fresh name will be generated.public ExternalProcessItemScorerBuilder addItemFileArgument(ItemDAO items)
items
- A DAO of items to provide to the process.public ExternalProcessItemScorerBuilder addUserFileArgument(UserDAO users, @Nullable String name)
users
- A DAO of users to provide to the process.name
- A file name (optional). If provided, the users will be stored in this file
name in the working directory; otherwise, a fresh name will be generated.public ExternalProcessItemScorerBuilder addUserFileArgument(UserDAO users)
users
- A DAO of users to provide to the process.public ItemScorer build()
public ItemScorer get()
get
in interface javax.inject.Provider<ItemScorer>