From 317be550f2706a79c457d6cac9cf8b51575e91fd Mon Sep 17 00:00:00 2001 From: Bert Chang Date: Tue, 6 May 2014 01:07:34 +0800 Subject: [PATCH] Add docs to StringFrame. --- data/string_frame.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/data/string_frame.go b/data/string_frame.go index cb7bc40..6b89a79 100644 --- a/data/string_frame.go +++ b/data/string_frame.go @@ -1,21 +1,26 @@ package data +// Used for storing matrix-like strings. For example, if you have multiple labels associated with each instance, then you probably need a matrix-like struct to store whole your labels. type StringFrame struct { labels [][]string } +// Add a row of string to StringFrame func (self *StringFrame) Add(row []string) { self.labels = append(self.labels, row) } +// Get the string at (i, j) func (self *StringFrame) At(i, j int) string { return self.labels[i][j] } +// Get the i-th row of string func (self *StringFrame) Row(i int) []string { return self.labels[i] } +// Get the j-th column of string func (self *StringFrame) Col(j int) []string { col := make([]string, 0) for i := 0; i < self.NRow(); i++ { @@ -25,10 +30,12 @@ func (self *StringFrame) Col(j int) []string { return col } +// Number of rows func (self *StringFrame) NRow() int { return len(self.labels) } +// Number of columns func (self *StringFrame) NCol() int { return len(self.labels[0]) }