Class DataReader<U extends java.io.Serializable,I extends java.io.Serializable,F>
java.lang.Object
es.uam.eps.ir.relison.diffusion.io.DataReader<U,I,F>
- Type Parameters:
U
- type of the users.I
- type of the information pieces.F
- type of the user and information pieces features.
public class DataReader<U extends java.io.Serializable,I extends java.io.Serializable,F>
extends java.lang.Object
Class for reading the data.
-
Constructor Summary
Constructors Constructor Description DataReader()
-
Method Summary
Modifier and Type Method Description protected Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, java.lang.String realPropagatedFile, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser)
Read the data from files.Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, java.lang.String realPropagatedFile, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser)
Read the data from files.Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser)
Read the data from files.Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String realPropagatedFile, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser)
Read the data from files.Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser)
Read the data from files.Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser)
Read the data from files.Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, java.lang.String realPropagatedFile, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser)
Read the data from files.Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser)
Read the data from files.Data<U,I,F>
readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String realPropagatedFile, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser)
Read the data from files.private <T> Triplet<java.lang.String,Index<F>,Relation<java.lang.Double>>
readFeaturesFile(java.lang.String paramFile, Index<T> index, org.ranksys.formats.parsing.Parser<T> parser, org.ranksys.formats.parsing.Parser<F> pParser)
Reads a parameter file.private <T> Index<T>
readIndex(java.lang.String indexFile, org.ranksys.formats.parsing.Parser<T> parser)
Reads an indexprivate Relation<java.lang.Long>
readRealPropagatedFile(java.lang.String realPropagatedFile, Index<U> userIndex, Index<I> itemIndex, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser)
Reads information about what information pieces were truly repropagated in the real world scenario.private Tuple2oo<java.util.Map<java.lang.Integer,Information<I>>,Relation<java.lang.Integer>>
readUserInformation(java.lang.String infoFile, Index<U> userIndex, Index<I> itemIndex, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser)
Reads detailed data about the information.
-
Constructor Details
-
DataReader
public DataReader()
-
-
Method Details
-
readData
public Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser) throws java.io.IOExceptionRead the data from files. Only the basic information is available.- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.readtypes
- true if we must read the types of the edges, false otherwise.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.infoFile
- file containing information about the information pieces (creator and timestamps).uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.- Returns:
- the data object.
- Throws:
java.io.IOException
- if something fails while reading.
-
readData
public Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser) throws java.io.IOExceptionRead the data from files. We have information about the features of users or items.- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.readtypes
- true if we have to read the types of the edges, false otherwise.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.infoFile
- file containing information about the information pieces (creator and timestamps).userFeatureFiles
- an array containing the routes of files user features (might be null).infoFeatureFiles
- an array containing the routes of files with information pieces features (might be null).uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.pParser
- parser for the features.- Returns:
- the data object.
- Throws:
java.io.IOException
- if something fails while reading.
-
readData
public Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String realPropagatedFile, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser) throws java.io.IOExceptionRead the data from files. We have information about which users propagated which information (and when)- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.readtypes
- true if the graph has types that we should read. NOTE: if we use recommendations, this parameter will be considered as false.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.infoFile
- file containing information about the information pieces (creator and timestamps).realPropagatedFile
- route to a file containing information about which information pieces were repropagated by each user in the real diffusion (might be null).uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.- Returns:
- a data object to use in a diffusion simulation procedure.
- Throws:
java.io.IOException
- if something fails while reading.
-
readData
public Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, java.lang.String realPropagatedFile, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser) throws java.io.IOExceptionRead the data from files. We have information about which users propagated which information (and when) as well as information about the features of users or items.- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.readtypes
- true if the graph has types that we should read. NOTE: if we use recommendations, this parameter will be considered as false.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.userFeatureFiles
- an array containing the routes of files user features (might be null).infoFeatureFiles
- an array containing the routes of files with information pieces features (might be null).infoFile
- file containing information about the information pieces (creator and timestamps).realPropagatedFile
- route to a file containing information about which information pieces were repropagated by each user in the real diffusion (might be null).uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.pParser
- parser for the features.- Returns:
- a data object to use in a diffusion simulation procedure.
- Throws:
java.io.IOException
- if something fails while reading.
-
readData
public Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser) throws java.io.IOExceptionRead the data from files. Only the basic information is available, in addition to a contact recommendation.- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.infoFile
- file containing information about the information pieces (creator and timestamps).recFile
- file containing the results of applying a contact recommendation algorithm over the network (might be null).topN
- number of links (per user) to add from the recommendations.uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.- Returns:
- the data object.
- Throws:
java.io.IOException
- if something fails while reading.
-
readData
public Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser) throws java.io.IOExceptionRead the data from files. We have information about the features of users or items, in addition to a contact recommendation.- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.infoFile
- file containing information about the information pieces (creator and timestamps).userFeatureFiles
- an array containing the routes of files user features (might be null).infoFeatureFiles
- an array containing the routes of files with information pieces features (might be null).recFile
- file containing the results of applying a contact recommendation algorithm over the network (might be null).topN
- number of links (per user) to add from the recommendations.uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.pParser
- parser for the features.- Returns:
- the data object.
- Throws:
java.io.IOException
- if something fails while reading.
-
readData
public Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String realPropagatedFile, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser) throws java.io.IOExceptionRead the data from files. We have information about which users propagated which information (and when), in addition to a contact recommendation.- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.infoFile
- file containing information about the information pieces (creator and timestamps).realPropagatedFile
- route to a file containing information about which information pieces were repropagated by each user in the real diffusion (might be null).recFile
- file containing the results of applying a contact recommendation algorithm over the network (might be null).topN
- number of links (per user) to add from the recommendations.uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.- Returns:
- a data object to use in a diffusion simulation procedure.
- Throws:
java.io.IOException
- if something fails while reading.
-
readData
public Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, java.lang.String realPropagatedFile, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser) throws java.io.IOExceptionRead the data from files. We have information about which users propagated which information (and when) as well as information about the features of users or items, as well as a contact recommendation.- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.userFeatureFiles
- an array containing the routes of files user features (might be null).infoFeatureFiles
- an array containing the routes of files with information pieces features (might be null).infoFile
- file containing information about the information pieces (creator and timestamps).realPropagatedFile
- route to a file containing information about which information pieces were repropagated by each user in the real diffusion (might be null).recFile
- file containing the results of applying a contact recommendation algorithm over the network (might be null).topN
- number of links (per user) to add from the recommendations.uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.pParser
- parser for the features.- Returns:
- a data object to use in a diffusion simulation procedure.
- Throws:
java.io.IOException
- if something fails while reading.
-
readData
protected Data<U,I,F> readData(java.lang.String graphFile, boolean multigraph, boolean directed, boolean weighted, boolean selfloops, boolean readtypes, java.lang.String uIndex, java.lang.String iIndex, java.lang.String infoFile, java.lang.String[] userFeatureFiles, java.lang.String[] infoFeatureFiles, java.lang.String realPropagatedFile, java.lang.String recFile, int topN, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser, org.ranksys.formats.parsing.Parser<F> pParser) throws java.io.IOExceptionRead the data from files.- Parameters:
graphFile
- route of a file containing the network graph.multigraph
- true if the graph is a multigraph, false otherwise.directed
- true if the graph is directed, false otherwise.weighted
- true if the graph is weighted, false otherwise.selfloops
- true if the graph allows self loops, false otherwise.readtypes
- true if the graph has types that we should read. NOTE: if we use recommendations, this parameter will be considered as false.uIndex
- route to a file containing a list of user identifiers.iIndex
- route to a file containing a list of user identifiers.infoFile
- file containing information about the information pieces (creator and timestamps).userFeatureFiles
- an array containing the routes of files user features (might be null).infoFeatureFiles
- an array containing the routes of files with information pieces features (might be null).realPropagatedFile
- route to a file containing information about which information pieces were repropagated by each user in the real diffusion (might be null).recFile
- file containing the results of applying a contact recommendation algorithm over the network (might be null).topN
- number of links (per user) to add from the recommendations.uParser
- parser for the user identifiers.iParser
- parser for the information piece identifiers.pParser
- parser for the feature values.- Returns:
- a data object to use in a diffusion simulation procedure.
- Throws:
java.io.IOException
- if something fails while reading.
-
readIndex
private <T> Index<T> readIndex(java.lang.String indexFile, org.ranksys.formats.parsing.Parser<T> parser) throws java.io.IOExceptionReads an index- Type Parameters:
T
- type of the parser.- Parameters:
indexFile
- the file containing the user indexparser
- the parser- Returns:
- the index.
- Throws:
java.io.IOException
- if something fails while reading the file.
-
readUserInformation
private Tuple2oo<java.util.Map<java.lang.Integer,Information<I>>,Relation<java.lang.Integer>> readUserInformation(java.lang.String infoFile, Index<U> userIndex, Index<I> itemIndex, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser) throws java.io.IOExceptionReads detailed data about the information.- Parameters:
infoFile
- information fileuserIndex
- user indexitemIndex
- information pieces index.uParser
- parser for the users.iParser
- parser for the information pieces.- Returns:
- a pair containing the the map of extended information, and a relation between users and information pieces.
- Throws:
java.io.IOException
- if something fails while reading the information file.
-
readFeaturesFile
private <T> Triplet<java.lang.String,Index<F>,Relation<java.lang.Double>> readFeaturesFile(java.lang.String paramFile, Index<T> index, org.ranksys.formats.parsing.Parser<T> parser, org.ranksys.formats.parsing.Parser<F> pParser) throws java.io.IOExceptionReads a parameter file.- Type Parameters:
T
- Type of the object the parameters belong to.- Parameters:
paramFile
- the file containing the information about the parameters.index
- a index of T objects.parser
- a parser for the T objects.pParser
- a parser for the parameter values.- Returns:
- a triplet containing the name of the feature, the feature index and the relation between T objects and features.
- Throws:
java.io.IOException
- if something fails while reading the feature file.
-
readRealPropagatedFile
private Relation<java.lang.Long> readRealPropagatedFile(java.lang.String realPropagatedFile, Index<U> userIndex, Index<I> itemIndex, org.ranksys.formats.parsing.Parser<U> uParser, org.ranksys.formats.parsing.Parser<I> iParser) throws java.io.IOExceptionReads information about what information pieces were truly repropagated in the real world scenario.- Parameters:
realPropagatedFile
- a file containing the information.userIndex
- user indexitemIndex
- information pieces indexuParser
- parser for usersiParser
- parser for information pieces- Returns:
- a relation between users and information pieces.
- Throws:
java.io.IOException
- if something fails while reading the file.
-