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]
See Also:
LETOR v.4.0
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.lang.Integer counter
    The number of features.
    private Generator<U> gen
    User identifier generator.
    private org.ranksys.formats.parsing.Parser<U> parser
    Parser for obtaining the identifiers of users.
  • 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • parser

      private final org.ranksys.formats.parsing.Parser<U> parser
      Parser for obtaining the identifiers of users.
    • counter

      private final java.lang.Integer counter
      The number of features.
    • gen

      private final Generator<U> gen
      User identifier generator.
  • Constructor Details

    • LETORInstanceReader

      public LETORInstanceReader​(org.ranksys.formats.parsing.Parser<U> parser)
      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

      public InstanceSet<U> read​(java.lang.String file) throws java.io.IOException
      Description copied from interface: InstanceSetReader
      Given a file, reads an instance set.
      Specified by:
      read in interface InstanceSetReader<U>
      Parameters:
      file - the file.
      Returns:
      the instance set which has been read.
      Throws:
      java.io.IOException - if something fails while reading.
    • readHeader

      public FeatureInformation readHeader​(java.util.List<java.lang.String> header)
      Reads the header of the file into an object containing all. information about features.
      Specified by:
      readHeader in interface InstanceSetReader<U>
      Parameters:
      header - the header lines.
      Returns:
      an object containing information about features.
    • readInstance

      public Instance<U> readInstance​(java.lang.String line, int numFeats)
      Reads an individual instance.
      Specified by:
      readInstance in interface InstanceSetReader<U>
      Parameters:
      line - the line string containing the instance.
      numFeats - the number of features.
      Returns:
      the instance.