Class LETORInstanceWriter<U>
java.lang.Object
es.uam.eps.ir.relison.links.data.letor.io.LETORInstanceWriter<U>
- Type Parameters:
U
- type of the users.
- All Implemented Interfaces:
InstanceSetWriter<U>
public class LETORInstanceWriter<U> extends java.lang.Object implements InstanceSetWriter<U>
Class for writing patterns in the LETOR format (for Learning TO Rank task).
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]
#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 boolean
comments
True if comments are allowed, false otherwise. -
Constructor Summary
Constructors Constructor Description LETORInstanceWriter()
Constructor.LETORInstanceWriter(boolean comments)
Constructor. -
Method Summary
Modifier and Type Method Description java.lang.String
write(Instance<U> instance)
Obtains an string containing the information for a single instance.void
write(java.io.Writer writer, FeatureInformation featInfo)
Writes the feature information of a file.void
write(java.io.Writer writer, Instance<U> instance)
Writes an individual instance into a file.void
write(java.lang.String file, InstanceSet<U> instanceSet)
Writes a dataset into a file.java.lang.String
writeFeatureInfo(FeatureInformation featInfo)
Obtains an string with all the information about the features of a dataset.private java.lang.String
writeFeatureInfo(FeatureInformation featInfo, int i)
-
Field Details
-
comments
private final boolean commentsTrue if comments are allowed, false otherwise.
-
-
Constructor Details
-
LETORInstanceWriter
public LETORInstanceWriter()Constructor. Adds comments. -
LETORInstanceWriter
public LETORInstanceWriter(boolean comments)Constructor.- Parameters:
comments
- true to add comments, false otherwise.
-
-
Method Details
-
write
Description copied from interface:InstanceSetWriter
Writes a dataset into a file.- Specified by:
write
in interfaceInstanceSetWriter<U>
- Parameters:
file
- the name of the file.instanceSet
- the instance set to store.- Throws:
java.io.IOException
- if something fails while writing.
-
writeFeatureInfo
Description copied from interface:InstanceSetWriter
Obtains an string with all the information about the features of a dataset.- Specified by:
writeFeatureInfo
in interfaceInstanceSetWriter<U>
- Parameters:
featInfo
- the feature information.- Returns:
- a String containing the information about the features.
-
write
Description copied from interface:InstanceSetWriter
Writes the feature information of a file.- Specified by:
write
in interfaceInstanceSetWriter<U>
- Parameters:
writer
- the writer.featInfo
- feature information to write.- Throws:
java.io.IOException
- if something fails while writing.
-
write
Description copied from interface:InstanceSetWriter
Writes an individual instance into a file.- Specified by:
write
in interfaceInstanceSetWriter<U>
- Parameters:
writer
- the writer.instance
- the instance to write.- Throws:
java.io.IOException
- if something fails while writing.
-
writeFeatureInfo
-
write
Description copied from interface:InstanceSetWriter
Obtains an string containing the information for a single instance.- Specified by:
write
in interfaceInstanceSetWriter<U>
- Parameters:
instance
- the instance.- Returns:
- an string containing all the necessary information.
-