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 booleancommentsTrue 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.Stringwrite(Instance<U> instance)Obtains an string containing the information for a single instance.voidwrite(java.io.Writer writer, FeatureInformation featInfo)Writes the feature information of a file.voidwrite(java.io.Writer writer, Instance<U> instance)Writes an individual instance into a file.voidwrite(java.lang.String file, InstanceSet<U> instanceSet)Writes a dataset into a file.java.lang.StringwriteFeatureInfo(FeatureInformation featInfo)Obtains an string with all the information about the features of a dataset.private java.lang.StringwriteFeatureInfo(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:InstanceSetWriterWrites a dataset into a file.- Specified by:
writein 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:InstanceSetWriterObtains an string with all the information about the features of a dataset.- Specified by:
writeFeatureInfoin interfaceInstanceSetWriter<U>- Parameters:
featInfo- the feature information.- Returns:
- a String containing the information about the features.
-
write
Description copied from interface:InstanceSetWriterWrites the feature information of a file.- Specified by:
writein 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:InstanceSetWriterWrites an individual instance into a file.- Specified by:
writein 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:InstanceSetWriterObtains an string containing the information for a single instance.- Specified by:
writein interfaceInstanceSetWriter<U>- Parameters:
instance- the instance.- Returns:
- an string containing all the necessary information.
-