public class ExternalProcessItemScorerBuilder extends java.lang.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() |
Modifier and Type | Method and Description |
---|---|
ExternalProcessItemScorerBuilder |
addArgument(java.lang.String arg)
Add a command line argument.
|
ExternalProcessItemScorerBuilder |
addArguments(java.util.Collection<java.lang.String> args)
Add some command line arguments.
|
ExternalProcessItemScorerBuilder |
addArguments(java.lang.String... args)
Add some command line arguments.
|
ExternalProcessItemScorerBuilder |
addItemFileArgument(ItemDAO items)
Add a list of items as a command-line argument.
|
ExternalProcessItemScorerBuilder |
addItemFileArgument(ItemDAO items,
java.lang.String name)
Add a list of items as a command-line argument.
|
ExternalProcessItemScorerBuilder |
addRatingFileArgument(EventDAO ratings)
Add a list of ratings as a command-line argument.
|
ExternalProcessItemScorerBuilder |
addRatingFileArgument(EventDAO ratings,
java.lang.String name)
Add a list of ratings as a command-line argument.
|
ExternalProcessItemScorerBuilder |
addUserFileArgument(UserDAO users)
Add a list of users as a command-line argument.
|
ExternalProcessItemScorerBuilder |
addUserFileArgument(UserDAO users,
java.lang.String name)
Add a list of users as a command-line argument.
|
ItemScorer |
build()
Build the item scorer.
|
ItemScorer |
get() |
ExternalProcessItemScorerBuilder |
setExecutable(java.lang.String exe)
Set the executable to use.
|
ExternalProcessItemScorerBuilder |
setWorkingDir(java.io.File dir)
Set the working directory to use.
|
ExternalProcessItemScorerBuilder |
setWorkingDir(java.lang.String dir)
Set the working directory to use.
|
public ExternalProcessItemScorerBuilder setWorkingDir(java.io.File dir)
dir
- The working directory.public ExternalProcessItemScorerBuilder setWorkingDir(java.lang.String dir)
dir
- The working directory.public ExternalProcessItemScorerBuilder setExecutable(java.lang.String exe)
exe
- The name or path of the executable to run.public ExternalProcessItemScorerBuilder addArgument(java.lang.String arg)
arg
- The argument to add.public ExternalProcessItemScorerBuilder addArguments(java.util.Collection<java.lang.String> args)
args
- The arguments to add.public ExternalProcessItemScorerBuilder addArguments(java.lang.String... args)
args
- The arguments to add.public ExternalProcessItemScorerBuilder addRatingFileArgument(EventDAO ratings, @Nullable java.lang.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 java.lang.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 java.lang.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>