Class LETORInstanceReader<U>
java.lang.Object
es.uam.eps.ir.relison.links.data.letor.io.LETORInstanceReader<U>
- Type Parameters:
U
- Type of the users.
- All Implemented Interfaces:
InstanceSetReader<U>
public class LETORInstanceReader<U> extends java.lang.Object implements InstanceSetReader<U>
Class for reading the different patterns for ML algorithms as contact
recommendation / link prediction algorithms, using the LETOR
format.
Format:
#featId1: description1 stats1
#featId2: description2 stats2
...
#featIdN: descriptionN statsN
[relevance(u,v) or class1(u,v)] qid:[user u] [featId1]:[value1(u,v)] [featId2]:[value2(u,v)] ... [featIdN]:[valueN(u,v)] #docId=[user v]
...
[relevance(u,v) or class1(u,v)] qid:[user u] [featId1]:[value1(u,v)] [featId2]:[value2(u,v)] ... [featIdN]:[valueN(u,v)] #docId=[user v]
Format:
#featId1: description1 stats1
#featId2: description2 stats2
...
#featIdN: descriptionN statsN
[relevance(u,v) or class1(u,v)] qid:[user u] [featId1]:[value1(u,v)] [featId2]:[value2(u,v)] ... [featIdN]:[valueN(u,v)] #docId=[user v]
...
[relevance(u,v) or class1(u,v)] qid:[user u] [featId1]:[value1(u,v)] [featId2]:[value2(u,v)] ... [featIdN]:[valueN(u,v)] #docId=[user v]
- See Also:
- LETOR v.4.0
-
Field Summary
-
Constructor Summary
Constructors Constructor Description LETORInstanceReader(org.ranksys.formats.parsing.Parser<U> parser)
Constructor.LETORInstanceReader(org.ranksys.formats.parsing.Parser<U> parser, int counter, Generator<U> gen)
Constructor. -
Method Summary
Modifier and Type Method Description InstanceSet<U>
read(java.lang.String file)
Given a file, reads an instance set.FeatureInformation
readHeader(java.util.List<java.lang.String> header)
Reads the header of the file into an object containing all.Instance<U>
readInstance(java.lang.String line, int numFeats)
Reads an individual instance.
-
Field Details
-
Constructor Details
-
LETORInstanceReader
Constructor.- Parameters:
parser
- parser for the users.
-
LETORInstanceReader
public LETORInstanceReader(org.ranksys.formats.parsing.Parser<U> parser, int counter, Generator<U> gen)Constructor.- Parameters:
parser
- user parser.counter
- number of features.gen
- user identifier generator.
-
-
Method Details
-
read
Description copied from interface:InstanceSetReader
Given a file, reads an instance set.- Specified by:
read
in interfaceInstanceSetReader<U>
- Parameters:
file
- the file.- Returns:
- the instance set which has been read.
- Throws:
java.io.IOException
- if something fails while reading.
-
readHeader
Reads the header of the file into an object containing all. information about features.- Specified by:
readHeader
in interfaceInstanceSetReader<U>
- Parameters:
header
- the header lines.- Returns:
- an object containing information about features.
-
readInstance
Reads an individual instance.- Specified by:
readInstance
in interfaceInstanceSetReader<U>
- Parameters:
line
- the line string containing the instance.numFeats
- the number of features.- Returns:
- the instance.
-