id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
139,300 | hypebeast/go-osc | osc/osc.go | getRegEx | func getRegEx(pattern string) *regexp.Regexp {
for _, trs := range []struct {
old, new string
}{
{".", `\.`}, // Escape all '.' in the pattern
{"(", `\(`}, // Escape all '(' in the pattern
{")", `\)`}, // Escape all ')' in the pattern
{"*", ".*"}, // Replace a '*' with '.*' that matches zero or more chars
... | go | func getRegEx(pattern string) *regexp.Regexp {
for _, trs := range []struct {
old, new string
}{
{".", `\.`}, // Escape all '.' in the pattern
{"(", `\(`}, // Escape all '(' in the pattern
{")", `\)`}, // Escape all ')' in the pattern
{"*", ".*"}, // Replace a '*' with '.*' that matches zero or more chars
... | [
"func",
"getRegEx",
"(",
"pattern",
"string",
")",
"*",
"regexp",
".",
"Regexp",
"{",
"for",
"_",
",",
"trs",
":=",
"range",
"[",
"]",
"struct",
"{",
"old",
",",
"new",
"string",
"\n",
"}",
"{",
"{",
"\"",
"\"",
",",
"`\\.`",
"}",
",",
"// Escape... | // getRegEx compiles and returns a regular expression object for the given
// address `pattern`. | [
"getRegEx",
"compiles",
"and",
"returns",
"a",
"regular",
"expression",
"object",
"for",
"the",
"given",
"address",
"pattern",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L1031-L1048 |
139,301 | hypebeast/go-osc | osc/osc.go | getTypeTag | func getTypeTag(arg interface{}) (string, error) {
switch t := arg.(type) {
case bool:
if arg.(bool) {
return "T", nil
}
return "F", nil
case nil:
return "N", nil
case int32:
return "i", nil
case float32:
return "f", nil
case string:
return "s", nil
case []byte:
return "b", nil
case int64:
... | go | func getTypeTag(arg interface{}) (string, error) {
switch t := arg.(type) {
case bool:
if arg.(bool) {
return "T", nil
}
return "F", nil
case nil:
return "N", nil
case int32:
return "i", nil
case float32:
return "f", nil
case string:
return "s", nil
case []byte:
return "b", nil
case int64:
... | [
"func",
"getTypeTag",
"(",
"arg",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"switch",
"t",
":=",
"arg",
".",
"(",
"type",
")",
"{",
"case",
"bool",
":",
"if",
"arg",
".",
"(",
"bool",
")",
"{",
"return",
"\"",
"\"",
","... | // getTypeTag returns the OSC type tag for the given argument. | [
"getTypeTag",
"returns",
"the",
"OSC",
"type",
"tag",
"for",
"the",
"given",
"argument",
"."
] | adefe22206c1207064748f0ab922a6a5f2135e7f | https://github.com/hypebeast/go-osc/blob/adefe22206c1207064748f0ab922a6a5f2135e7f/osc/osc.go#L1051-L1077 |
139,302 | mdlayher/waveform | options.go | Error | func (e *OptionsError) Error() string {
return fmt.Sprintf("%s: %s", e.Option, e.Reason)
} | go | func (e *OptionsError) Error() string {
return fmt.Sprintf("%s: %s", e.Option, e.Reason)
} | [
"func",
"(",
"e",
"*",
"OptionsError",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Option",
",",
"e",
".",
"Reason",
")",
"\n",
"}"
] | // Error returns the string representation of an OptionsError. | [
"Error",
"returns",
"the",
"string",
"representation",
"of",
"an",
"OptionsError",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L57-L59 |
139,303 | mdlayher/waveform | options.go | SetOptions | func (w *Waveform) SetOptions(options ...OptionsFunc) error {
for _, o := range options {
// Do not apply nil function arguments
if o == nil {
continue
}
if err := o(w); err != nil {
return err
}
}
return nil
} | go | func (w *Waveform) SetOptions(options ...OptionsFunc) error {
for _, o := range options {
// Do not apply nil function arguments
if o == nil {
continue
}
if err := o(w); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"SetOptions",
"(",
"options",
"...",
"OptionsFunc",
")",
"error",
"{",
"for",
"_",
",",
"o",
":=",
"range",
"options",
"{",
"// Do not apply nil function arguments",
"if",
"o",
"==",
"nil",
"{",
"continue",
"\n",
"}"... | // SetOptions applies zero or more OptionsFunc to the receiving Waveform
// struct, manipulating its properties. | [
"SetOptions",
"applies",
"zero",
"or",
"more",
"OptionsFunc",
"to",
"the",
"receiving",
"Waveform",
"struct",
"manipulating",
"its",
"properties",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L67-L80 |
139,304 | mdlayher/waveform | options.go | BGColorFunction | func BGColorFunction(function ColorFunc) OptionsFunc {
return func(w *Waveform) error {
return w.setBGColorFunction(function)
}
} | go | func BGColorFunction(function ColorFunc) OptionsFunc {
return func(w *Waveform) error {
return w.setBGColorFunction(function)
}
} | [
"func",
"BGColorFunction",
"(",
"function",
"ColorFunc",
")",
"OptionsFunc",
"{",
"return",
"func",
"(",
"w",
"*",
"Waveform",
")",
"error",
"{",
"return",
"w",
".",
"setBGColorFunction",
"(",
"function",
")",
"\n",
"}",
"\n",
"}"
] | // BGColorFunction generates an OptionsFunc which applies the input background
// ColorFunc to an input Waveform struct.
//
// This function is used to apply a variety of color schemes to the background
// of a waveform image, and is called during each drawing loop of the background
// image. | [
"BGColorFunction",
"generates",
"an",
"OptionsFunc",
"which",
"applies",
"the",
"input",
"background",
"ColorFunc",
"to",
"an",
"input",
"Waveform",
"struct",
".",
"This",
"function",
"is",
"used",
"to",
"apply",
"a",
"variety",
"of",
"color",
"schemes",
"to",
... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L88-L92 |
139,305 | mdlayher/waveform | options.go | SetBGColorFunction | func (w *Waveform) SetBGColorFunction(function ColorFunc) error {
return w.SetOptions(BGColorFunction(function))
} | go | func (w *Waveform) SetBGColorFunction(function ColorFunc) error {
return w.SetOptions(BGColorFunction(function))
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"SetBGColorFunction",
"(",
"function",
"ColorFunc",
")",
"error",
"{",
"return",
"w",
".",
"SetOptions",
"(",
"BGColorFunction",
"(",
"function",
")",
")",
"\n",
"}"
] | // SetBGColorFunction applies the input ColorFunc to the receiving Waveform
// struct for background use. | [
"SetBGColorFunction",
"applies",
"the",
"input",
"ColorFunc",
"to",
"the",
"receiving",
"Waveform",
"struct",
"for",
"background",
"use",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L96-L98 |
139,306 | mdlayher/waveform | options.go | setBGColorFunction | func (w *Waveform) setBGColorFunction(function ColorFunc) error {
// Function cannot be nil
if function == nil {
return errBGColorFunctionNil
}
w.bgColorFn = function
return nil
} | go | func (w *Waveform) setBGColorFunction(function ColorFunc) error {
// Function cannot be nil
if function == nil {
return errBGColorFunctionNil
}
w.bgColorFn = function
return nil
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"setBGColorFunction",
"(",
"function",
"ColorFunc",
")",
"error",
"{",
"// Function cannot be nil",
"if",
"function",
"==",
"nil",
"{",
"return",
"errBGColorFunctionNil",
"\n",
"}",
"\n\n",
"w",
".",
"bgColorFn",
"=",
"f... | // setBGColorFunction directly sets the background ColorFunc member of the
// receiving Waveform struct. | [
"setBGColorFunction",
"directly",
"sets",
"the",
"background",
"ColorFunc",
"member",
"of",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L102-L111 |
139,307 | mdlayher/waveform | options.go | FGColorFunction | func FGColorFunction(function ColorFunc) OptionsFunc {
return func(w *Waveform) error {
return w.setFGColorFunction(function)
}
} | go | func FGColorFunction(function ColorFunc) OptionsFunc {
return func(w *Waveform) error {
return w.setFGColorFunction(function)
}
} | [
"func",
"FGColorFunction",
"(",
"function",
"ColorFunc",
")",
"OptionsFunc",
"{",
"return",
"func",
"(",
"w",
"*",
"Waveform",
")",
"error",
"{",
"return",
"w",
".",
"setFGColorFunction",
"(",
"function",
")",
"\n",
"}",
"\n",
"}"
] | // FGColorFunction generates an OptionsFunc which applies the input foreground
// ColorFunc to an input Waveform struct.
//
// This function is used to apply a variety of color schemes to the foreground
// of a waveform image, and is called during each drawing loop of the foreground
// image. | [
"FGColorFunction",
"generates",
"an",
"OptionsFunc",
"which",
"applies",
"the",
"input",
"foreground",
"ColorFunc",
"to",
"an",
"input",
"Waveform",
"struct",
".",
"This",
"function",
"is",
"used",
"to",
"apply",
"a",
"variety",
"of",
"color",
"schemes",
"to",
... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L119-L123 |
139,308 | mdlayher/waveform | options.go | SetFGColorFunction | func (w *Waveform) SetFGColorFunction(function ColorFunc) error {
return w.SetOptions(FGColorFunction(function))
} | go | func (w *Waveform) SetFGColorFunction(function ColorFunc) error {
return w.SetOptions(FGColorFunction(function))
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"SetFGColorFunction",
"(",
"function",
"ColorFunc",
")",
"error",
"{",
"return",
"w",
".",
"SetOptions",
"(",
"FGColorFunction",
"(",
"function",
")",
")",
"\n",
"}"
] | // SetFGColorFunction applies the input ColorFunc to the receiving Waveform
// struct for foreground use. | [
"SetFGColorFunction",
"applies",
"the",
"input",
"ColorFunc",
"to",
"the",
"receiving",
"Waveform",
"struct",
"for",
"foreground",
"use",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L127-L129 |
139,309 | mdlayher/waveform | options.go | setFGColorFunction | func (w *Waveform) setFGColorFunction(function ColorFunc) error {
// Function cannot be nil
if function == nil {
return errFGColorFunctionNil
}
w.fgColorFn = function
return nil
} | go | func (w *Waveform) setFGColorFunction(function ColorFunc) error {
// Function cannot be nil
if function == nil {
return errFGColorFunctionNil
}
w.fgColorFn = function
return nil
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"setFGColorFunction",
"(",
"function",
"ColorFunc",
")",
"error",
"{",
"// Function cannot be nil",
"if",
"function",
"==",
"nil",
"{",
"return",
"errFGColorFunctionNil",
"\n",
"}",
"\n\n",
"w",
".",
"fgColorFn",
"=",
"f... | // setFGColorFunction directly sets the foreground ColorFunc member of the
// receiving Waveform struct. | [
"setFGColorFunction",
"directly",
"sets",
"the",
"foreground",
"ColorFunc",
"member",
"of",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L133-L142 |
139,310 | mdlayher/waveform | options.go | Resolution | func Resolution(resolution uint) OptionsFunc {
return func(w *Waveform) error {
return w.setResolution(resolution)
}
} | go | func Resolution(resolution uint) OptionsFunc {
return func(w *Waveform) error {
return w.setResolution(resolution)
}
} | [
"func",
"Resolution",
"(",
"resolution",
"uint",
")",
"OptionsFunc",
"{",
"return",
"func",
"(",
"w",
"*",
"Waveform",
")",
"error",
"{",
"return",
"w",
".",
"setResolution",
"(",
"resolution",
")",
"\n",
"}",
"\n",
"}"
] | // Resolution generates an OptionsFunc which applies the input resolution
// value to an input Waveform struct.
//
// This value indicates the number of times audio is read and drawn
// as a waveform, per second of audio. | [
"Resolution",
"generates",
"an",
"OptionsFunc",
"which",
"applies",
"the",
"input",
"resolution",
"value",
"to",
"an",
"input",
"Waveform",
"struct",
".",
"This",
"value",
"indicates",
"the",
"number",
"of",
"times",
"audio",
"is",
"read",
"and",
"drawn",
"as"... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L149-L153 |
139,311 | mdlayher/waveform | options.go | SetResolution | func (w *Waveform) SetResolution(resolution uint) error {
return w.SetOptions(Resolution(resolution))
} | go | func (w *Waveform) SetResolution(resolution uint) error {
return w.SetOptions(Resolution(resolution))
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"SetResolution",
"(",
"resolution",
"uint",
")",
"error",
"{",
"return",
"w",
".",
"SetOptions",
"(",
"Resolution",
"(",
"resolution",
")",
")",
"\n",
"}"
] | // SetResolution applies the input resolution to the receiving Waveform struct. | [
"SetResolution",
"applies",
"the",
"input",
"resolution",
"to",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L156-L158 |
139,312 | mdlayher/waveform | options.go | setResolution | func (w *Waveform) setResolution(resolution uint) error {
// Resolution cannot be zero
if resolution == 0 {
return errResolutionZero
}
w.resolution = resolution
return nil
} | go | func (w *Waveform) setResolution(resolution uint) error {
// Resolution cannot be zero
if resolution == 0 {
return errResolutionZero
}
w.resolution = resolution
return nil
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"setResolution",
"(",
"resolution",
"uint",
")",
"error",
"{",
"// Resolution cannot be zero",
"if",
"resolution",
"==",
"0",
"{",
"return",
"errResolutionZero",
"\n",
"}",
"\n\n",
"w",
".",
"resolution",
"=",
"resolutio... | // setResolution directly sets the resolution member of the receiving Waveform
// struct. | [
"setResolution",
"directly",
"sets",
"the",
"resolution",
"member",
"of",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L162-L171 |
139,313 | mdlayher/waveform | options.go | SampleFunction | func SampleFunction(function SampleReduceFunc) OptionsFunc {
return func(w *Waveform) error {
return w.setSampleFunction(function)
}
} | go | func SampleFunction(function SampleReduceFunc) OptionsFunc {
return func(w *Waveform) error {
return w.setSampleFunction(function)
}
} | [
"func",
"SampleFunction",
"(",
"function",
"SampleReduceFunc",
")",
"OptionsFunc",
"{",
"return",
"func",
"(",
"w",
"*",
"Waveform",
")",
"error",
"{",
"return",
"w",
".",
"setSampleFunction",
"(",
"function",
")",
"\n",
"}",
"\n",
"}"
] | // SampleFunc generates an OptionsFunc which applies the input SampleReduceFunc
// to an input Waveform struct.
//
// This function is used to compute values from audio samples, for use in
// waveform generation. The function is applied over a slice of float64
// audio samples, reducing them to a single value. | [
"SampleFunc",
"generates",
"an",
"OptionsFunc",
"which",
"applies",
"the",
"input",
"SampleReduceFunc",
"to",
"an",
"input",
"Waveform",
"struct",
".",
"This",
"function",
"is",
"used",
"to",
"compute",
"values",
"from",
"audio",
"samples",
"for",
"use",
"in",
... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L179-L183 |
139,314 | mdlayher/waveform | options.go | SetSampleFunction | func (w *Waveform) SetSampleFunction(function SampleReduceFunc) error {
return w.SetOptions(SampleFunction(function))
} | go | func (w *Waveform) SetSampleFunction(function SampleReduceFunc) error {
return w.SetOptions(SampleFunction(function))
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"SetSampleFunction",
"(",
"function",
"SampleReduceFunc",
")",
"error",
"{",
"return",
"w",
".",
"SetOptions",
"(",
"SampleFunction",
"(",
"function",
")",
")",
"\n",
"}"
] | // SetSampleFunction applies the input SampleReduceFunc to the receiving Waveform
// struct. | [
"SetSampleFunction",
"applies",
"the",
"input",
"SampleReduceFunc",
"to",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L187-L189 |
139,315 | mdlayher/waveform | options.go | setSampleFunction | func (w *Waveform) setSampleFunction(function SampleReduceFunc) error {
// Function cannot be nil
if function == nil {
return errSampleFunctionNil
}
w.sampleFn = function
return nil
} | go | func (w *Waveform) setSampleFunction(function SampleReduceFunc) error {
// Function cannot be nil
if function == nil {
return errSampleFunctionNil
}
w.sampleFn = function
return nil
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"setSampleFunction",
"(",
"function",
"SampleReduceFunc",
")",
"error",
"{",
"// Function cannot be nil",
"if",
"function",
"==",
"nil",
"{",
"return",
"errSampleFunctionNil",
"\n",
"}",
"\n\n",
"w",
".",
"sampleFn",
"=",
... | // setSampleFunction directly sets the SampleReduceFunc member of the receiving
// Waveform struct. | [
"setSampleFunction",
"directly",
"sets",
"the",
"SampleReduceFunc",
"member",
"of",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L193-L202 |
139,316 | mdlayher/waveform | options.go | Scale | func Scale(x uint, y uint) OptionsFunc {
return func(w *Waveform) error {
return w.setScale(x, y)
}
} | go | func Scale(x uint, y uint) OptionsFunc {
return func(w *Waveform) error {
return w.setScale(x, y)
}
} | [
"func",
"Scale",
"(",
"x",
"uint",
",",
"y",
"uint",
")",
"OptionsFunc",
"{",
"return",
"func",
"(",
"w",
"*",
"Waveform",
")",
"error",
"{",
"return",
"w",
".",
"setScale",
"(",
"x",
",",
"y",
")",
"\n",
"}",
"\n",
"}"
] | // Scale generates an OptionsFunc which applies the input X and Y axis scaling
// factors to an input Waveform struct.
//
// This value indicates how a generated waveform image will be scaled, for both
// its X and Y axes. | [
"Scale",
"generates",
"an",
"OptionsFunc",
"which",
"applies",
"the",
"input",
"X",
"and",
"Y",
"axis",
"scaling",
"factors",
"to",
"an",
"input",
"Waveform",
"struct",
".",
"This",
"value",
"indicates",
"how",
"a",
"generated",
"waveform",
"image",
"will",
... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L209-L213 |
139,317 | mdlayher/waveform | options.go | SetScale | func (w *Waveform) SetScale(x uint, y uint) error {
return w.SetOptions(Scale(x, y))
} | go | func (w *Waveform) SetScale(x uint, y uint) error {
return w.SetOptions(Scale(x, y))
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"SetScale",
"(",
"x",
"uint",
",",
"y",
"uint",
")",
"error",
"{",
"return",
"w",
".",
"SetOptions",
"(",
"Scale",
"(",
"x",
",",
"y",
")",
")",
"\n",
"}"
] | // SetScale applies the input X and Y axis scaling to the receiving Waveform
// struct. | [
"SetScale",
"applies",
"the",
"input",
"X",
"and",
"Y",
"axis",
"scaling",
"to",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L217-L219 |
139,318 | mdlayher/waveform | options.go | setScale | func (w *Waveform) setScale(x uint, y uint) error {
// X scale cannot be zero
if x == 0 {
return errScaleXZero
}
// Y scale cannot be zero
if y == 0 {
return errScaleYZero
}
w.scaleX = x
w.scaleY = y
return nil
} | go | func (w *Waveform) setScale(x uint, y uint) error {
// X scale cannot be zero
if x == 0 {
return errScaleXZero
}
// Y scale cannot be zero
if y == 0 {
return errScaleYZero
}
w.scaleX = x
w.scaleY = y
return nil
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"setScale",
"(",
"x",
"uint",
",",
"y",
"uint",
")",
"error",
"{",
"// X scale cannot be zero",
"if",
"x",
"==",
"0",
"{",
"return",
"errScaleXZero",
"\n",
"}",
"\n\n",
"// Y scale cannot be zero",
"if",
"y",
"==",
... | // setScale directly sets the scaleX and scaleY members of the receiving Waveform
// struct. | [
"setScale",
"directly",
"sets",
"the",
"scaleX",
"and",
"scaleY",
"members",
"of",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L223-L239 |
139,319 | mdlayher/waveform | options.go | setScaleClipping | func (w *Waveform) setScaleClipping(scaleClipping bool) error {
w.scaleClipping = scaleClipping
return nil
} | go | func (w *Waveform) setScaleClipping(scaleClipping bool) error {
w.scaleClipping = scaleClipping
return nil
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"setScaleClipping",
"(",
"scaleClipping",
"bool",
")",
"error",
"{",
"w",
".",
"scaleClipping",
"=",
"scaleClipping",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // setScaleClipping directly sets the scaleClipping member of the receiving Waveform
// struct. | [
"setScaleClipping",
"directly",
"sets",
"the",
"scaleClipping",
"member",
"of",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L261-L265 |
139,320 | mdlayher/waveform | options.go | Sharpness | func Sharpness(sharpness uint) OptionsFunc {
return func(w *Waveform) error {
return w.setSharpness(sharpness)
}
} | go | func Sharpness(sharpness uint) OptionsFunc {
return func(w *Waveform) error {
return w.setSharpness(sharpness)
}
} | [
"func",
"Sharpness",
"(",
"sharpness",
"uint",
")",
"OptionsFunc",
"{",
"return",
"func",
"(",
"w",
"*",
"Waveform",
")",
"error",
"{",
"return",
"w",
".",
"setSharpness",
"(",
"sharpness",
")",
"\n",
"}",
"\n",
"}"
] | // Sharpness generates an OptionsFunc which applies the input sharpness
// value to an input Waveform struct.
//
// This value indicates the amount of curvature which is applied to a
// waveform image, scaled on its X-axis. A higher value results in steeper
// curves, and a lower value results in more "blocky" curves. | [
"Sharpness",
"generates",
"an",
"OptionsFunc",
"which",
"applies",
"the",
"input",
"sharpness",
"value",
"to",
"an",
"input",
"Waveform",
"struct",
".",
"This",
"value",
"indicates",
"the",
"amount",
"of",
"curvature",
"which",
"is",
"applied",
"to",
"a",
"wav... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L273-L277 |
139,321 | mdlayher/waveform | options.go | SetSharpness | func (w *Waveform) SetSharpness(sharpness uint) error {
return w.SetOptions(Sharpness(sharpness))
} | go | func (w *Waveform) SetSharpness(sharpness uint) error {
return w.SetOptions(Sharpness(sharpness))
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"SetSharpness",
"(",
"sharpness",
"uint",
")",
"error",
"{",
"return",
"w",
".",
"SetOptions",
"(",
"Sharpness",
"(",
"sharpness",
")",
")",
"\n",
"}"
] | // SetSharpness applies the input sharpness to the receiving Waveform struct. | [
"SetSharpness",
"applies",
"the",
"input",
"sharpness",
"to",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L280-L282 |
139,322 | mdlayher/waveform | options.go | setSharpness | func (w *Waveform) setSharpness(sharpness uint) error {
w.sharpness = sharpness
return nil
} | go | func (w *Waveform) setSharpness(sharpness uint) error {
w.sharpness = sharpness
return nil
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"setSharpness",
"(",
"sharpness",
"uint",
")",
"error",
"{",
"w",
".",
"sharpness",
"=",
"sharpness",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // setSharpness directly sets the sharpness member of the receiving Waveform
// struct. | [
"setSharpness",
"directly",
"sets",
"the",
"sharpness",
"member",
"of",
"the",
"receiving",
"Waveform",
"struct",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/options.go#L286-L290 |
139,323 | mdlayher/waveform | colorfunc.go | CheckerColor | func CheckerColor(colorA color.Color, colorB color.Color, size uint) ColorFunc {
return func(n int, x int, y int, maxN int, maxX int, maxY int) color.Color {
if ((uint(x)/size)+(uint(y)/size))%2 == 0 {
return colorA
}
return colorB
}
} | go | func CheckerColor(colorA color.Color, colorB color.Color, size uint) ColorFunc {
return func(n int, x int, y int, maxN int, maxX int, maxY int) color.Color {
if ((uint(x)/size)+(uint(y)/size))%2 == 0 {
return colorA
}
return colorB
}
} | [
"func",
"CheckerColor",
"(",
"colorA",
"color",
".",
"Color",
",",
"colorB",
"color",
".",
"Color",
",",
"size",
"uint",
")",
"ColorFunc",
"{",
"return",
"func",
"(",
"n",
"int",
",",
"x",
"int",
",",
"y",
"int",
",",
"maxN",
"int",
",",
"maxX",
"i... | // CheckerColor generates a ColorFunc which produces a checkerboard pattern,
// using the two input colors. Each square is drawn to the size specified by
// the size parameter. | [
"CheckerColor",
"generates",
"a",
"ColorFunc",
"which",
"produces",
"a",
"checkerboard",
"pattern",
"using",
"the",
"two",
"input",
"colors",
".",
"Each",
"square",
"is",
"drawn",
"to",
"the",
"size",
"specified",
"by",
"the",
"size",
"parameter",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/colorfunc.go#L22-L30 |
139,324 | mdlayher/waveform | colorfunc.go | FuzzColor | func FuzzColor(colors ...color.Color) ColorFunc {
// Filter any nil values
colors = filterNilColors(colors)
// Seed RNG
rand.Seed(time.Now().UnixNano())
// Select a color at random on each call
return func(n int, x int, y int, maxN int, maxX int, maxY int) color.Color {
return colors[rand.Intn(len(colors))]
... | go | func FuzzColor(colors ...color.Color) ColorFunc {
// Filter any nil values
colors = filterNilColors(colors)
// Seed RNG
rand.Seed(time.Now().UnixNano())
// Select a color at random on each call
return func(n int, x int, y int, maxN int, maxX int, maxY int) color.Color {
return colors[rand.Intn(len(colors))]
... | [
"func",
"FuzzColor",
"(",
"colors",
"...",
"color",
".",
"Color",
")",
"ColorFunc",
"{",
"// Filter any nil values",
"colors",
"=",
"filterNilColors",
"(",
"colors",
")",
"\n\n",
"// Seed RNG",
"rand",
".",
"Seed",
"(",
"time",
".",
"Now",
"(",
")",
".",
"... | // FuzzColor generates a ColorFunc which applies a random color on each call,
// selected from an input, variadic slice of colors. This can be used to create
// a random fuzz or "static" effect in the resulting waveform image. | [
"FuzzColor",
"generates",
"a",
"ColorFunc",
"which",
"applies",
"a",
"random",
"color",
"on",
"each",
"call",
"selected",
"from",
"an",
"input",
"variadic",
"slice",
"of",
"colors",
".",
"This",
"can",
"be",
"used",
"to",
"create",
"a",
"random",
"fuzz",
"... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/colorfunc.go#L35-L46 |
139,325 | mdlayher/waveform | colorfunc.go | GradientColor | func GradientColor(start color.RGBA, end color.RGBA) ColorFunc {
// Float equivalents of color values
startFR, endFR := float64(start.R), float64(end.R)
startFG, endFG := float64(start.G), float64(end.G)
startFB, endFB := float64(start.B), float64(end.B)
// Values used for RGBA and percentage
var r, g, b, p floa... | go | func GradientColor(start color.RGBA, end color.RGBA) ColorFunc {
// Float equivalents of color values
startFR, endFR := float64(start.R), float64(end.R)
startFG, endFG := float64(start.G), float64(end.G)
startFB, endFB := float64(start.B), float64(end.B)
// Values used for RGBA and percentage
var r, g, b, p floa... | [
"func",
"GradientColor",
"(",
"start",
"color",
".",
"RGBA",
",",
"end",
"color",
".",
"RGBA",
")",
"ColorFunc",
"{",
"// Float equivalents of color values",
"startFR",
",",
"endFR",
":=",
"float64",
"(",
"start",
".",
"R",
")",
",",
"float64",
"(",
"end",
... | // GradientColor generates a ColorFunc which produces a color gradient between two
// RGBA input colors. The gradient attempts to gradually reduce the distance between
// two colors, creating a sweeping color change effect in the resulting waveform
// image. | [
"GradientColor",
"generates",
"a",
"ColorFunc",
"which",
"produces",
"a",
"color",
"gradient",
"between",
"two",
"RGBA",
"input",
"colors",
".",
"The",
"gradient",
"attempts",
"to",
"gradually",
"reduce",
"the",
"distance",
"between",
"two",
"colors",
"creating",
... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/colorfunc.go#L52-L89 |
139,326 | mdlayher/waveform | colorfunc.go | SolidColor | func SolidColor(inColor color.Color) ColorFunc {
return func(n int, x int, y int, maxN int, maxX int, maxY int) color.Color {
return inColor
}
} | go | func SolidColor(inColor color.Color) ColorFunc {
return func(n int, x int, y int, maxN int, maxX int, maxY int) color.Color {
return inColor
}
} | [
"func",
"SolidColor",
"(",
"inColor",
"color",
".",
"Color",
")",
"ColorFunc",
"{",
"return",
"func",
"(",
"n",
"int",
",",
"x",
"int",
",",
"y",
"int",
",",
"maxN",
"int",
",",
"maxX",
"int",
",",
"maxY",
"int",
")",
"color",
".",
"Color",
"{",
... | // SolidColor generates a ColorFunc which simply returns the input color
// as the color which should be drawn at all coordinates.
//
// This is the default behavior of the waveform package. | [
"SolidColor",
"generates",
"a",
"ColorFunc",
"which",
"simply",
"returns",
"the",
"input",
"color",
"as",
"the",
"color",
"which",
"should",
"be",
"drawn",
"at",
"all",
"coordinates",
".",
"This",
"is",
"the",
"default",
"behavior",
"of",
"the",
"waveform",
... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/colorfunc.go#L95-L99 |
139,327 | mdlayher/waveform | colorfunc.go | StripeColor | func StripeColor(colors ...color.Color) ColorFunc {
// Filter any nil values
colors = filterNilColors(colors)
var lastN int
return func(n int, x int, y int, maxN int, maxX int, maxY int) color.Color {
// For each new n value, use the next color in the slice
if n > lastN {
lastN = n
}
return colors[last... | go | func StripeColor(colors ...color.Color) ColorFunc {
// Filter any nil values
colors = filterNilColors(colors)
var lastN int
return func(n int, x int, y int, maxN int, maxX int, maxY int) color.Color {
// For each new n value, use the next color in the slice
if n > lastN {
lastN = n
}
return colors[last... | [
"func",
"StripeColor",
"(",
"colors",
"...",
"color",
".",
"Color",
")",
"ColorFunc",
"{",
"// Filter any nil values",
"colors",
"=",
"filterNilColors",
"(",
"colors",
")",
"\n\n",
"var",
"lastN",
"int",
"\n",
"return",
"func",
"(",
"n",
"int",
",",
"x",
"... | // StripeColor generates a ColorFunc which applies one color from the input,
// variadic slice at each computed value. Each color is used in order, and
// the rotation will repeat until the image is complete. This creates a stripe
// effect in the resulting waveform image. | [
"StripeColor",
"generates",
"a",
"ColorFunc",
"which",
"applies",
"one",
"color",
"from",
"the",
"input",
"variadic",
"slice",
"at",
"each",
"computed",
"value",
".",
"Each",
"color",
"is",
"used",
"in",
"order",
"and",
"the",
"rotation",
"will",
"repeat",
"... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/colorfunc.go#L105-L118 |
139,328 | mdlayher/waveform | colorfunc.go | filterNilColors | func filterNilColors(colors []color.Color) []color.Color {
var cleanColors []color.Color
for _, c := range colors {
if c != nil {
cleanColors = append(cleanColors, c)
}
}
return cleanColors
} | go | func filterNilColors(colors []color.Color) []color.Color {
var cleanColors []color.Color
for _, c := range colors {
if c != nil {
cleanColors = append(cleanColors, c)
}
}
return cleanColors
} | [
"func",
"filterNilColors",
"(",
"colors",
"[",
"]",
"color",
".",
"Color",
")",
"[",
"]",
"color",
".",
"Color",
"{",
"var",
"cleanColors",
"[",
"]",
"color",
".",
"Color",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"colors",
"{",
"if",
"c",
"!=",
... | // filterNilColors strips any nil color.Color values from the input slice. | [
"filterNilColors",
"strips",
"any",
"nil",
"color",
".",
"Color",
"values",
"from",
"the",
"input",
"slice",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/colorfunc.go#L121-L130 |
139,329 | mdlayher/waveform | waveform.go | Generate | func Generate(r io.Reader, options ...OptionsFunc) (image.Image, error) {
w, err := New(r, options...)
if err != nil {
return nil, err
}
values, err := w.Compute()
return w.Draw(values), err
} | go | func Generate(r io.Reader, options ...OptionsFunc) (image.Image, error) {
w, err := New(r, options...)
if err != nil {
return nil, err
}
values, err := w.Compute()
return w.Draw(values), err
} | [
"func",
"Generate",
"(",
"r",
"io",
".",
"Reader",
",",
"options",
"...",
"OptionsFunc",
")",
"(",
"image",
".",
"Image",
",",
"error",
")",
"{",
"w",
",",
"err",
":=",
"New",
"(",
"r",
",",
"options",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Generate immediately opens and reads an input audio stream, computes
// the values required for waveform generation, and returns a waveform image
// which is customized by zero or more, variadic, OptionsFunc parameters.
//
// Generate is equivalent to calling New, followed by the Compute and Draw
// methods of a Wav... | [
"Generate",
"immediately",
"opens",
"and",
"reads",
"an",
"input",
"audio",
"stream",
"computes",
"the",
"values",
"required",
"for",
"waveform",
"generation",
"and",
"returns",
"a",
"waveform",
"image",
"which",
"is",
"customized",
"by",
"zero",
"or",
"more",
... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/waveform.go#L68-L76 |
139,330 | mdlayher/waveform | waveform.go | New | func New(r io.Reader, options ...OptionsFunc) (*Waveform, error) {
// Generate Waveform struct with sane defaults
w := &Waveform{
// Read from input stream
r: r,
// Read audio and compute values once per second of audio
resolution: 1,
// Use RMSF64Samples as a SampleReduceFunc
sampleFn: RMSF64Samples,
... | go | func New(r io.Reader, options ...OptionsFunc) (*Waveform, error) {
// Generate Waveform struct with sane defaults
w := &Waveform{
// Read from input stream
r: r,
// Read audio and compute values once per second of audio
resolution: 1,
// Use RMSF64Samples as a SampleReduceFunc
sampleFn: RMSF64Samples,
... | [
"func",
"New",
"(",
"r",
"io",
".",
"Reader",
",",
"options",
"...",
"OptionsFunc",
")",
"(",
"*",
"Waveform",
",",
"error",
")",
"{",
"// Generate Waveform struct with sane defaults",
"w",
":=",
"&",
"Waveform",
"{",
"// Read from input stream",
"r",
":",
"r"... | // New generates a new Waveform struct, applying any input OptionsFunc
// on return. | [
"New",
"generates",
"a",
"new",
"Waveform",
"struct",
"applying",
"any",
"input",
"OptionsFunc",
"on",
"return",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/waveform.go#L80-L110 |
139,331 | mdlayher/waveform | waveform.go | Draw | func (w *Waveform) Draw(values []float64) image.Image {
return w.generateImage(values)
} | go | func (w *Waveform) Draw(values []float64) image.Image {
return w.generateImage(values)
} | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"Draw",
"(",
"values",
"[",
"]",
"float64",
")",
"image",
".",
"Image",
"{",
"return",
"w",
".",
"generateImage",
"(",
"values",
")",
"\n",
"}"
] | // Draw creates a new image.Image from a slice of float64 values.
//
// Draw is typically used after a waveform has been computed one time, and a slice
// of computed values was returned from the first computation. Subsequent calls to
// Draw may be used to customize a waveform using the same input values. | [
"Draw",
"creates",
"a",
"new",
"image",
".",
"Image",
"from",
"a",
"slice",
"of",
"float64",
"values",
".",
"Draw",
"is",
"typically",
"used",
"after",
"a",
"waveform",
"has",
"been",
"computed",
"one",
"time",
"and",
"a",
"slice",
"of",
"computed",
"val... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/waveform.go#L126-L128 |
139,332 | mdlayher/waveform | waveform.go | readAndComputeSamples | func (w *Waveform) readAndComputeSamples() ([]float64, error) {
// Validate struct members
// These checks are also done when applying options, but verifying them here
// will prevent a runtime panic if called on an empty Waveform instance.
if w.sampleFn == nil {
return nil, errSampleFunctionNil
}
if w.resoluti... | go | func (w *Waveform) readAndComputeSamples() ([]float64, error) {
// Validate struct members
// These checks are also done when applying options, but verifying them here
// will prevent a runtime panic if called on an empty Waveform instance.
if w.sampleFn == nil {
return nil, errSampleFunctionNil
}
if w.resoluti... | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"readAndComputeSamples",
"(",
")",
"(",
"[",
"]",
"float64",
",",
"error",
")",
"{",
"// Validate struct members",
"// These checks are also done when applying options, but verifying them here",
"// will prevent a runtime panic if called ... | // readAndComputeSamples opens the input audio stream, computes samples according
// to an input function, and returns a slice of computed values and any errors
// which occurred during the computation. | [
"readAndComputeSamples",
"opens",
"the",
"input",
"audio",
"stream",
"computes",
"samples",
"according",
"to",
"an",
"input",
"function",
"and",
"returns",
"a",
"slice",
"of",
"computed",
"values",
"and",
"any",
"errors",
"which",
"occurred",
"during",
"the",
"c... | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/waveform.go#L133-L198 |
139,333 | mdlayher/waveform | waveform.go | generateImage | func (w *Waveform) generateImage(computed []float64) image.Image {
// Store integer scale values
intScaleX := int(w.scaleX)
intScaleY := int(w.scaleY)
// Calculate maximum n, x, y, where:
// - n: number of computed values
// - x: number of pixels on X-axis
// - y: number of pixels on Y-axis
maxN := len(comp... | go | func (w *Waveform) generateImage(computed []float64) image.Image {
// Store integer scale values
intScaleX := int(w.scaleX)
intScaleY := int(w.scaleY)
// Calculate maximum n, x, y, where:
// - n: number of computed values
// - x: number of pixels on X-axis
// - y: number of pixels on Y-axis
maxN := len(comp... | [
"func",
"(",
"w",
"*",
"Waveform",
")",
"generateImage",
"(",
"computed",
"[",
"]",
"float64",
")",
"image",
".",
"Image",
"{",
"// Store integer scale values",
"intScaleX",
":=",
"int",
"(",
"w",
".",
"scaleX",
")",
"\n",
"intScaleY",
":=",
"int",
"(",
... | // generateImage takes a slice of computed values and generates
// a waveform image from the input. | [
"generateImage",
"takes",
"a",
"slice",
"of",
"computed",
"values",
"and",
"generates",
"a",
"waveform",
"image",
"from",
"the",
"input",
"."
] | 6b28917edfbacd50bff4d58f951cf80499c952c4 | https://github.com/mdlayher/waveform/blob/6b28917edfbacd50bff4d58f951cf80499c952c4/waveform.go#L202-L307 |
139,334 | neelance/parallel | parallel.go | Error | func (r *Run) Error(err error) {
r.errsMutex.Lock()
r.errs = append(r.errs, err)
r.errsMutex.Unlock()
} | go | func (r *Run) Error(err error) {
r.errsMutex.Lock()
r.errs = append(r.errs, err)
r.errsMutex.Unlock()
} | [
"func",
"(",
"r",
"*",
"Run",
")",
"Error",
"(",
"err",
"error",
")",
"{",
"r",
".",
"errsMutex",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"errs",
"=",
"append",
"(",
"r",
".",
"errs",
",",
"err",
")",
"\n",
"r",
".",
"errsMutex",
".",
"Unlock"... | // Error stores an error to be returned by Wait. | [
"Error",
"stores",
"an",
"error",
"to",
"be",
"returned",
"by",
"Wait",
"."
] | 4de9ce63d14c18517a79efe69e10e99d32c850c3 | https://github.com/neelance/parallel/blob/4de9ce63d14c18517a79efe69e10e99d32c850c3/parallel.go#L45-L49 |
139,335 | neelance/parallel | parallel.go | Wait | func (r *Run) Wait() error {
r.wg.Wait()
if len(r.errs) != 0 {
return Errors(r.errs)
}
return nil
} | go | func (r *Run) Wait() error {
r.wg.Wait()
if len(r.errs) != 0 {
return Errors(r.errs)
}
return nil
} | [
"func",
"(",
"r",
"*",
"Run",
")",
"Wait",
"(",
")",
"error",
"{",
"r",
".",
"wg",
".",
"Wait",
"(",
")",
"\n",
"if",
"len",
"(",
"r",
".",
"errs",
")",
"!=",
"0",
"{",
"return",
"Errors",
"(",
"r",
".",
"errs",
")",
"\n",
"}",
"\n",
"ret... | // Wait waits for all locks to be released. If any errors were encountered, it returns an
// Errors value describing all the errors in arbitrary order. | [
"Wait",
"waits",
"for",
"all",
"locks",
"to",
"be",
"released",
".",
"If",
"any",
"errors",
"were",
"encountered",
"it",
"returns",
"an",
"Errors",
"value",
"describing",
"all",
"the",
"errors",
"in",
"arbitrary",
"order",
"."
] | 4de9ce63d14c18517a79efe69e10e99d32c850c3 | https://github.com/neelance/parallel/blob/4de9ce63d14c18517a79efe69e10e99d32c850c3/parallel.go#L53-L59 |
139,336 | muesli/regommend | regommendtable.go | Count | func (table *RegommendTable) Count() int {
table.RLock()
defer table.RUnlock()
return len(table.items)
} | go | func (table *RegommendTable) Count() int {
table.RLock()
defer table.RUnlock()
return len(table.items)
} | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"Count",
"(",
")",
"int",
"{",
"table",
".",
"RLock",
"(",
")",
"\n",
"defer",
"table",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"table",
".",
"items",
")",
"\n",
"}"
] | // Count returns how many items are currently stored in the engine. | [
"Count",
"returns",
"how",
"many",
"items",
"are",
"currently",
"stored",
"in",
"the",
"engine",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L40-L44 |
139,337 | muesli/regommend | regommendtable.go | SetDataLoader | func (table *RegommendTable) SetDataLoader(f func(interface{}) *RegommendItem) {
table.Lock()
defer table.Unlock()
table.loadData = f
} | go | func (table *RegommendTable) SetDataLoader(f func(interface{}) *RegommendItem) {
table.Lock()
defer table.Unlock()
table.loadData = f
} | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"SetDataLoader",
"(",
"f",
"func",
"(",
"interface",
"{",
"}",
")",
"*",
"RegommendItem",
")",
"{",
"table",
".",
"Lock",
"(",
")",
"\n",
"defer",
"table",
".",
"Unlock",
"(",
")",
"\n",
"table",
".",... | // Configures a data-loader callback, which will be called when trying
// to use access a non-existing key. | [
"Configures",
"a",
"data",
"-",
"loader",
"callback",
"which",
"will",
"be",
"called",
"when",
"trying",
"to",
"use",
"access",
"a",
"non",
"-",
"existing",
"key",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L48-L52 |
139,338 | muesli/regommend | regommendtable.go | SetAddedItemCallback | func (table *RegommendTable) SetAddedItemCallback(f func(*RegommendItem)) {
table.Lock()
defer table.Unlock()
table.addedItem = f
} | go | func (table *RegommendTable) SetAddedItemCallback(f func(*RegommendItem)) {
table.Lock()
defer table.Unlock()
table.addedItem = f
} | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"SetAddedItemCallback",
"(",
"f",
"func",
"(",
"*",
"RegommendItem",
")",
")",
"{",
"table",
".",
"Lock",
"(",
")",
"\n",
"defer",
"table",
".",
"Unlock",
"(",
")",
"\n",
"table",
".",
"addedItem",
"=",... | // Configures a callback, which will be called every time a new item
// is added to the engine. | [
"Configures",
"a",
"callback",
"which",
"will",
"be",
"called",
"every",
"time",
"a",
"new",
"item",
"is",
"added",
"to",
"the",
"engine",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L56-L60 |
139,339 | muesli/regommend | regommendtable.go | SetAboutToDeleteItemCallback | func (table *RegommendTable) SetAboutToDeleteItemCallback(f func(*RegommendItem)) {
table.Lock()
defer table.Unlock()
table.aboutToDeleteItem = f
} | go | func (table *RegommendTable) SetAboutToDeleteItemCallback(f func(*RegommendItem)) {
table.Lock()
defer table.Unlock()
table.aboutToDeleteItem = f
} | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"SetAboutToDeleteItemCallback",
"(",
"f",
"func",
"(",
"*",
"RegommendItem",
")",
")",
"{",
"table",
".",
"Lock",
"(",
")",
"\n",
"defer",
"table",
".",
"Unlock",
"(",
")",
"\n",
"table",
".",
"aboutToDel... | // Configures a callback, which will be called every time an item
// is about to be removed from the engine. | [
"Configures",
"a",
"callback",
"which",
"will",
"be",
"called",
"every",
"time",
"an",
"item",
"is",
"about",
"to",
"be",
"removed",
"from",
"the",
"engine",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L64-L68 |
139,340 | muesli/regommend | regommendtable.go | SetLogger | func (table *RegommendTable) SetLogger(logger *log.Logger) {
table.Lock()
defer table.Unlock()
table.logger = logger
} | go | func (table *RegommendTable) SetLogger(logger *log.Logger) {
table.Lock()
defer table.Unlock()
table.logger = logger
} | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"SetLogger",
"(",
"logger",
"*",
"log",
".",
"Logger",
")",
"{",
"table",
".",
"Lock",
"(",
")",
"\n",
"defer",
"table",
".",
"Unlock",
"(",
")",
"\n",
"table",
".",
"logger",
"=",
"logger",
"\n",
"... | // Sets the logger to be used by this engine table. | [
"Sets",
"the",
"logger",
"to",
"be",
"used",
"by",
"this",
"engine",
"table",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L71-L75 |
139,341 | muesli/regommend | regommendtable.go | Delete | func (table *RegommendTable) Delete(key interface{}) (*RegommendItem, error) {
table.RLock()
r, ok := table.items[key]
if !ok {
table.RUnlock()
return nil, errors.New("Key not found in engine")
}
// engine value so we don't keep blocking the mutex.
aboutToDeleteItem := table.aboutToDeleteItem
table.RUnlock(... | go | func (table *RegommendTable) Delete(key interface{}) (*RegommendItem, error) {
table.RLock()
r, ok := table.items[key]
if !ok {
table.RUnlock()
return nil, errors.New("Key not found in engine")
}
// engine value so we don't keep blocking the mutex.
aboutToDeleteItem := table.aboutToDeleteItem
table.RUnlock(... | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"Delete",
"(",
"key",
"interface",
"{",
"}",
")",
"(",
"*",
"RegommendItem",
",",
"error",
")",
"{",
"table",
".",
"RLock",
"(",
")",
"\n",
"r",
",",
"ok",
":=",
"table",
".",
"items",
"[",
"key",
... | // Delete an item from the engine. | [
"Delete",
"an",
"item",
"from",
"the",
"engine",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L100-L125 |
139,342 | muesli/regommend | regommendtable.go | Exists | func (table *RegommendTable) Exists(key interface{}) bool {
table.RLock()
defer table.RUnlock()
_, ok := table.items[key]
return ok
} | go | func (table *RegommendTable) Exists(key interface{}) bool {
table.RLock()
defer table.RUnlock()
_, ok := table.items[key]
return ok
} | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"Exists",
"(",
"key",
"interface",
"{",
"}",
")",
"bool",
"{",
"table",
".",
"RLock",
"(",
")",
"\n",
"defer",
"table",
".",
"RUnlock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"table",
".",
"items",
... | // Test whether an item exists in the engine. Unlike the Value method
// Exists neither tries to fetch data via the loadData callback nor
// does it keep the item alive in the engine. | [
"Test",
"whether",
"an",
"item",
"exists",
"in",
"the",
"engine",
".",
"Unlike",
"the",
"Value",
"method",
"Exists",
"neither",
"tries",
"to",
"fetch",
"data",
"via",
"the",
"loadData",
"callback",
"nor",
"does",
"it",
"keep",
"the",
"item",
"alive",
"in",... | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L130-L136 |
139,343 | muesli/regommend | regommendtable.go | Value | func (table *RegommendTable) Value(key interface{}) (*RegommendItem, error) {
table.RLock()
r, ok := table.items[key]
loadData := table.loadData
table.RUnlock()
if ok {
return r, nil
}
// Item doesn't exist in engine. Try and fetch it with a data-loader.
if loadData != nil {
item := loadData(key)
if ite... | go | func (table *RegommendTable) Value(key interface{}) (*RegommendItem, error) {
table.RLock()
r, ok := table.items[key]
loadData := table.loadData
table.RUnlock()
if ok {
return r, nil
}
// Item doesn't exist in engine. Try and fetch it with a data-loader.
if loadData != nil {
item := loadData(key)
if ite... | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"Value",
"(",
"key",
"interface",
"{",
"}",
")",
"(",
"*",
"RegommendItem",
",",
"error",
")",
"{",
"table",
".",
"RLock",
"(",
")",
"\n",
"r",
",",
"ok",
":=",
"table",
".",
"items",
"[",
"key",
... | // Value gets an item from the engine and mark it to be kept alive. | [
"Value",
"gets",
"an",
"item",
"from",
"the",
"engine",
"and",
"mark",
"it",
"to",
"be",
"kept",
"alive",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L139-L161 |
139,344 | muesli/regommend | regommendtable.go | Flush | func (table *RegommendTable) Flush() {
table.Lock()
defer table.Unlock()
table.log("Flushing table", table.name)
table.items = make(map[interface{}]*RegommendItem)
} | go | func (table *RegommendTable) Flush() {
table.Lock()
defer table.Unlock()
table.log("Flushing table", table.name)
table.items = make(map[interface{}]*RegommendItem)
} | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"Flush",
"(",
")",
"{",
"table",
".",
"Lock",
"(",
")",
"\n",
"defer",
"table",
".",
"Unlock",
"(",
")",
"\n\n",
"table",
".",
"log",
"(",
"\"",
"\"",
",",
"table",
".",
"name",
")",
"\n\n",
"tabl... | // Delete all items from engine. | [
"Delete",
"all",
"items",
"from",
"engine",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L164-L171 |
139,345 | muesli/regommend | regommendtable.go | log | func (table *RegommendTable) log(v ...interface{}) {
if table.logger == nil {
return
}
table.logger.Println(v...)
} | go | func (table *RegommendTable) log(v ...interface{}) {
if table.logger == nil {
return
}
table.logger.Println(v...)
} | [
"func",
"(",
"table",
"*",
"RegommendTable",
")",
"log",
"(",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"table",
".",
"logger",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"table",
".",
"logger",
".",
"Println",
"(",
"v",
"...",
")",
... | // Internal logging method for convenience. | [
"Internal",
"logging",
"method",
"for",
"convenience",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommendtable.go#L276-L282 |
139,346 | muesli/regommend | regommend.go | Table | func Table(table string) *RegommendTable {
mutex.RLock()
t, ok := tables[table]
mutex.RUnlock()
if !ok {
t = &RegommendTable{
name: table,
items: make(map[interface{}]*RegommendItem),
}
mutex.Lock()
tables[table] = t
mutex.Unlock()
}
return t
} | go | func Table(table string) *RegommendTable {
mutex.RLock()
t, ok := tables[table]
mutex.RUnlock()
if !ok {
t = &RegommendTable{
name: table,
items: make(map[interface{}]*RegommendItem),
}
mutex.Lock()
tables[table] = t
mutex.Unlock()
}
return t
} | [
"func",
"Table",
"(",
"table",
"string",
")",
"*",
"RegommendTable",
"{",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"t",
",",
"ok",
":=",
"tables",
"[",
"table",
"]",
"\n",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"!",
"ok",
"{",
"t",
"=",
... | // Table returns the existing engine table with given name or creates a new one
// if the table does not exist yet. | [
"Table",
"returns",
"the",
"existing",
"engine",
"table",
"with",
"given",
"name",
"or",
"creates",
"a",
"new",
"one",
"if",
"the",
"table",
"does",
"not",
"exist",
"yet",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommend.go#L21-L38 |
139,347 | muesli/regommend | regommenditem.go | CreateRegommendItem | func CreateRegommendItem(key interface{}, data map[interface{}]float64) RegommendItem {
return RegommendItem{
key: key,
data: data,
}
} | go | func CreateRegommendItem(key interface{}, data map[interface{}]float64) RegommendItem {
return RegommendItem{
key: key,
data: data,
}
} | [
"func",
"CreateRegommendItem",
"(",
"key",
"interface",
"{",
"}",
",",
"data",
"map",
"[",
"interface",
"{",
"}",
"]",
"float64",
")",
"RegommendItem",
"{",
"return",
"RegommendItem",
"{",
"key",
":",
"key",
",",
"data",
":",
"data",
",",
"}",
"\n",
"}... | // CreateRegommendItem returns a newly created RegommendItem.
// Parameter key is the item's key.
// Parameter data is the item's value. | [
"CreateRegommendItem",
"returns",
"a",
"newly",
"created",
"RegommendItem",
".",
"Parameter",
"key",
"is",
"the",
"item",
"s",
"key",
".",
"Parameter",
"data",
"is",
"the",
"item",
"s",
"value",
"."
] | e879bb52e08f394cfebb9a0d91036cfb7cd8322b | https://github.com/muesli/regommend/blob/e879bb52e08f394cfebb9a0d91036cfb7cd8322b/regommenditem.go#L29-L34 |
139,348 | openshift/openshift-sdn | plugins/osdn/registry.go | RunEventQueue | func (registry *Registry) RunEventQueue(resourceName ResourceName) *oscache.EventQueue {
var client cache.Getter
var expectedType interface{}
switch resourceName {
case HostSubnets:
expectedType = &osapi.HostSubnet{}
client = registry.oClient
case NetNamespaces:
expectedType = &osapi.NetNamespace{}
client... | go | func (registry *Registry) RunEventQueue(resourceName ResourceName) *oscache.EventQueue {
var client cache.Getter
var expectedType interface{}
switch resourceName {
case HostSubnets:
expectedType = &osapi.HostSubnet{}
client = registry.oClient
case NetNamespaces:
expectedType = &osapi.NetNamespace{}
client... | [
"func",
"(",
"registry",
"*",
"Registry",
")",
"RunEventQueue",
"(",
"resourceName",
"ResourceName",
")",
"*",
"oscache",
".",
"EventQueue",
"{",
"var",
"client",
"cache",
".",
"Getter",
"\n",
"var",
"expectedType",
"interface",
"{",
"}",
"\n\n",
"switch",
"... | // Run event queue for the given resource | [
"Run",
"event",
"queue",
"for",
"the",
"given",
"resource"
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/plugins/osdn/registry.go#L263-L296 |
139,349 | openshift/openshift-sdn | plugins/osdn/subnets.go | watchSubnets | func (node *OsdnNode) watchSubnets() {
subnets := make(map[string]*osapi.HostSubnet)
eventQueue := node.registry.RunEventQueue(HostSubnets)
for {
eventType, obj, err := eventQueue.Pop()
if err != nil {
utilruntime.HandleError(fmt.Errorf("EventQueue failed for subnets: %v", err))
return
}
hs := obj.(*o... | go | func (node *OsdnNode) watchSubnets() {
subnets := make(map[string]*osapi.HostSubnet)
eventQueue := node.registry.RunEventQueue(HostSubnets)
for {
eventType, obj, err := eventQueue.Pop()
if err != nil {
utilruntime.HandleError(fmt.Errorf("EventQueue failed for subnets: %v", err))
return
}
hs := obj.(*o... | [
"func",
"(",
"node",
"*",
"OsdnNode",
")",
"watchSubnets",
"(",
")",
"{",
"subnets",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"osapi",
".",
"HostSubnet",
")",
"\n",
"eventQueue",
":=",
"node",
".",
"registry",
".",
"RunEventQueue",
"(",
"Host... | // Only run on the nodes | [
"Only",
"run",
"on",
"the",
"nodes"
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/plugins/osdn/subnets.go#L209-L257 |
139,350 | openshift/openshift-sdn | pkg/exec/exec.go | Exec | func Exec(cmd string, args ...string) (string, error) {
if testMode {
return testModeExec(cmd, args...)
}
glog.V(5).Infof("[cmd] %s %s", cmd, strings.Join(args, " "))
out, err := osexec.Command(cmd, args...).CombinedOutput()
if err != nil {
err = fmt.Errorf("%s failed: '%s %s': %v", cmd, cmd, strings.Join(arg... | go | func Exec(cmd string, args ...string) (string, error) {
if testMode {
return testModeExec(cmd, args...)
}
glog.V(5).Infof("[cmd] %s %s", cmd, strings.Join(args, " "))
out, err := osexec.Command(cmd, args...).CombinedOutput()
if err != nil {
err = fmt.Errorf("%s failed: '%s %s': %v", cmd, cmd, strings.Join(arg... | [
"func",
"Exec",
"(",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"testMode",
"{",
"return",
"testModeExec",
"(",
"cmd",
",",
"args",
"...",
")",
"\n",
"}",
"\n\n",
"glog",
".",
"V",
"(",
"5",
"... | // Exec executes a command with the given arguments and returns either the
// combined stdout+stdin, or an error. | [
"Exec",
"executes",
"a",
"command",
"with",
"the",
"given",
"arguments",
"and",
"returns",
"either",
"the",
"combined",
"stdout",
"+",
"stdin",
"or",
"an",
"error",
"."
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/pkg/exec/exec.go#L26-L44 |
139,351 | openshift/openshift-sdn | pkg/ipcmd/ipcmd.go | AddLink | func (tx *Transaction) AddLink(args ...string) {
tx.exec(append([]string{"link", "add", tx.link}, args...))
} | go | func (tx *Transaction) AddLink(args ...string) {
tx.exec(append([]string{"link", "add", tx.link}, args...))
} | [
"func",
"(",
"tx",
"*",
"Transaction",
")",
"AddLink",
"(",
"args",
"...",
"string",
")",
"{",
"tx",
".",
"exec",
"(",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"tx",
".",
"link",
"}",
",",
"args",
"...",
")",
... | // AddLink creates the interface associated with the transaction, optionally
// with additional properties. | [
"AddLink",
"creates",
"the",
"interface",
"associated",
"with",
"the",
"transaction",
"optionally",
"with",
"additional",
"properties",
"."
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/pkg/ipcmd/ipcmd.go#L48-L50 |
139,352 | openshift/openshift-sdn | pkg/ipcmd/ipcmd.go | SetLink | func (tx *Transaction) SetLink(args ...string) {
tx.exec(append([]string{"link", "set", tx.link}, args...))
} | go | func (tx *Transaction) SetLink(args ...string) {
tx.exec(append([]string{"link", "set", tx.link}, args...))
} | [
"func",
"(",
"tx",
"*",
"Transaction",
")",
"SetLink",
"(",
"args",
"...",
"string",
")",
"{",
"tx",
".",
"exec",
"(",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"tx",
".",
"link",
"}",
",",
"args",
"...",
")",
... | // SetLink sets the indicated properties on the interface. | [
"SetLink",
"sets",
"the",
"indicated",
"properties",
"on",
"the",
"interface",
"."
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/pkg/ipcmd/ipcmd.go#L59-L61 |
139,353 | openshift/openshift-sdn | pkg/ipcmd/ipcmd.go | AddAddress | func (tx *Transaction) AddAddress(cidr string, args ...string) {
tx.exec(append([]string{"addr", "add", cidr, "dev", tx.link}, args...))
} | go | func (tx *Transaction) AddAddress(cidr string, args ...string) {
tx.exec(append([]string{"addr", "add", cidr, "dev", tx.link}, args...))
} | [
"func",
"(",
"tx",
"*",
"Transaction",
")",
"AddAddress",
"(",
"cidr",
"string",
",",
"args",
"...",
"string",
")",
"{",
"tx",
".",
"exec",
"(",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"cidr",
",",
"\"",
"\"",
... | // AddAddress adds an address to the interface. | [
"AddAddress",
"adds",
"an",
"address",
"to",
"the",
"interface",
"."
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/pkg/ipcmd/ipcmd.go#L64-L66 |
139,354 | openshift/openshift-sdn | pkg/ipcmd/ipcmd.go | GetAddresses | func (tx *Transaction) GetAddresses() ([]string, error) {
out, err := tx.exec(append([]string{"addr", "show", "dev", tx.link}))
if err != nil {
return nil, err
}
matches := addressRegexp.FindAllStringSubmatch(out, -1)
addrs := make([]string, len(matches))
for i, match := range matches {
addrs[i] = match[1]
... | go | func (tx *Transaction) GetAddresses() ([]string, error) {
out, err := tx.exec(append([]string{"addr", "show", "dev", tx.link}))
if err != nil {
return nil, err
}
matches := addressRegexp.FindAllStringSubmatch(out, -1)
addrs := make([]string, len(matches))
for i, match := range matches {
addrs[i] = match[1]
... | [
"func",
"(",
"tx",
"*",
"Transaction",
")",
"GetAddresses",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"tx",
".",
"exec",
"(",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
... | // GetAddresses returns the IPv4 addresses associated with the interface. Since
// this function has a return value, it also returns an error immediately if an
// error occurs. | [
"GetAddresses",
"returns",
"the",
"IPv4",
"addresses",
"associated",
"with",
"the",
"interface",
".",
"Since",
"this",
"function",
"has",
"a",
"return",
"value",
"it",
"also",
"returns",
"an",
"error",
"immediately",
"if",
"an",
"error",
"occurs",
"."
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/pkg/ipcmd/ipcmd.go#L77-L89 |
139,355 | openshift/openshift-sdn | pkg/ipcmd/ipcmd.go | AddSlave | func (tx *Transaction) AddSlave(slave string) {
tx.exec([]string{"link", "set", slave, "master", tx.link})
} | go | func (tx *Transaction) AddSlave(slave string) {
tx.exec([]string{"link", "set", slave, "master", tx.link})
} | [
"func",
"(",
"tx",
"*",
"Transaction",
")",
"AddSlave",
"(",
"slave",
"string",
")",
"{",
"tx",
".",
"exec",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"slave",
",",
"\"",
"\"",
",",
"tx",
".",
"link",
"}",
")",
"\n",
"}"... | // AddSlave adds the indicated slave interface to the bridge, bond, or team
// interface associated with the transaction. | [
"AddSlave",
"adds",
"the",
"indicated",
"slave",
"interface",
"to",
"the",
"bridge",
"bond",
"or",
"team",
"interface",
"associated",
"with",
"the",
"transaction",
"."
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/pkg/ipcmd/ipcmd.go#L118-L120 |
139,356 | openshift/openshift-sdn | pkg/ipcmd/ipcmd.go | EndTransaction | func (tx *Transaction) EndTransaction() error {
err := tx.err
tx.err = nil
return err
} | go | func (tx *Transaction) EndTransaction() error {
err := tx.err
tx.err = nil
return err
} | [
"func",
"(",
"tx",
"*",
"Transaction",
")",
"EndTransaction",
"(",
")",
"error",
"{",
"err",
":=",
"tx",
".",
"err",
"\n",
"tx",
".",
"err",
"=",
"nil",
"\n",
"return",
"err",
"\n",
"}"
] | // EndTransaction ends a transaction and returns any error that occurred during
// the transaction. You should not use the transaction again after calling this
// function. | [
"EndTransaction",
"ends",
"a",
"transaction",
"and",
"returns",
"any",
"error",
"that",
"occurred",
"during",
"the",
"transaction",
".",
"You",
"should",
"not",
"use",
"the",
"transaction",
"again",
"after",
"calling",
"this",
"function",
"."
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/pkg/ipcmd/ipcmd.go#L139-L143 |
139,357 | openshift/openshift-sdn | pkg/ovs/ovs.go | DumpFlows | func (tx *Transaction) DumpFlows() ([]string, error) {
out, err := tx.ofctlExec("dump-flows", tx.bridge)
if err != nil {
return nil, err
}
lines := strings.Split(out, "\n")
flows := make([]string, 0, len(lines))
for _, line := range lines {
if strings.Contains(line, "cookie=") {
flows = append(flows, line... | go | func (tx *Transaction) DumpFlows() ([]string, error) {
out, err := tx.ofctlExec("dump-flows", tx.bridge)
if err != nil {
return nil, err
}
lines := strings.Split(out, "\n")
flows := make([]string, 0, len(lines))
for _, line := range lines {
if strings.Contains(line, "cookie=") {
flows = append(flows, line... | [
"func",
"(",
"tx",
"*",
"Transaction",
")",
"DumpFlows",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"tx",
".",
"ofctlExec",
"(",
"\"",
"\"",
",",
"tx",
".",
"bridge",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // DumpFlows dumps the flow table for the bridge and returns it as an array of
// strings, one per flow. Since this function has a return value, it also
// returns an error immediately if an error occurs. | [
"DumpFlows",
"dumps",
"the",
"flow",
"table",
"for",
"the",
"bridge",
"and",
"returns",
"it",
"as",
"an",
"array",
"of",
"strings",
"one",
"per",
"flow",
".",
"Since",
"this",
"function",
"has",
"a",
"return",
"value",
"it",
"also",
"returns",
"an",
"err... | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/pkg/ovs/ovs.go#L103-L117 |
139,358 | openshift/openshift-sdn | plugins/osdn/node_iptables.go | getStaticNodeIPTablesRules | func (n *NodeIPTables) getStaticNodeIPTablesRules() []FirewallRule {
return []FirewallRule{
{"nat", "POSTROUTING", []string{"-s", n.clusterNetworkCIDR, "!", "-d", n.clusterNetworkCIDR, "-j", "MASQUERADE"}},
{"filter", "INPUT", []string{"-p", "udp", "-m", "multiport", "--dports", VXLAN_PORT, "-m", "comment", "--com... | go | func (n *NodeIPTables) getStaticNodeIPTablesRules() []FirewallRule {
return []FirewallRule{
{"nat", "POSTROUTING", []string{"-s", n.clusterNetworkCIDR, "!", "-d", n.clusterNetworkCIDR, "-j", "MASQUERADE"}},
{"filter", "INPUT", []string{"-p", "udp", "-m", "multiport", "--dports", VXLAN_PORT, "-m", "comment", "--com... | [
"func",
"(",
"n",
"*",
"NodeIPTables",
")",
"getStaticNodeIPTablesRules",
"(",
")",
"[",
"]",
"FirewallRule",
"{",
"return",
"[",
"]",
"FirewallRule",
"{",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"n",
".",
"... | // Get openshift iptables rules | [
"Get",
"openshift",
"iptables",
"rules"
] | 5ca93d25828cb135e3d9c8d1917a8807b37abd1e | https://github.com/openshift/openshift-sdn/blob/5ca93d25828cb135e3d9c8d1917a8807b37abd1e/plugins/osdn/node_iptables.go#L94-L102 |
139,359 | akrennmair/gopcap | io.go | Time | func (p *PacketTime) Time() time.Time {
return time.Unix(int64(p.Sec), int64(p.Usec)*1000)
} | go | func (p *PacketTime) Time() time.Time {
return time.Unix(int64(p.Sec), int64(p.Usec)*1000)
} | [
"func",
"(",
"p",
"*",
"PacketTime",
")",
"Time",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"time",
".",
"Unix",
"(",
"int64",
"(",
"p",
".",
"Sec",
")",
",",
"int64",
"(",
"p",
".",
"Usec",
")",
"*",
"1000",
")",
"\n",
"}"
] | // Convert the PacketTime to a go Time struct. | [
"Convert",
"the",
"PacketTime",
"to",
"a",
"go",
"Time",
"struct",
"."
] | 00e11033259acb75598ba416495bb708d864a010 | https://github.com/akrennmair/gopcap/blob/00e11033259acb75598ba416495bb708d864a010/io.go#L28-L30 |
139,360 | akrennmair/gopcap | io.go | NewReader | func NewReader(reader io.Reader) (*Reader, error) {
r := &Reader{
buf: reader,
fourBytes: make([]byte, 4),
twoBytes: make([]byte, 2),
sixteenBytes: make([]byte, 16),
}
switch magic := r.readUint32(); magic {
case 0xa1b2c3d4:
r.flip = false
case 0xd4c3b2a1:
r.flip = true
default:
retu... | go | func NewReader(reader io.Reader) (*Reader, error) {
r := &Reader{
buf: reader,
fourBytes: make([]byte, 4),
twoBytes: make([]byte, 2),
sixteenBytes: make([]byte, 16),
}
switch magic := r.readUint32(); magic {
case 0xa1b2c3d4:
r.flip = false
case 0xd4c3b2a1:
r.flip = true
default:
retu... | [
"func",
"NewReader",
"(",
"reader",
"io",
".",
"Reader",
")",
"(",
"*",
"Reader",
",",
"error",
")",
"{",
"r",
":=",
"&",
"Reader",
"{",
"buf",
":",
"reader",
",",
"fourBytes",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
",",
"twoBytes",
... | // NewReader reads pcap data from an io.Reader. | [
"NewReader",
"reads",
"pcap",
"data",
"from",
"an",
"io",
".",
"Reader",
"."
] | 00e11033259acb75598ba416495bb708d864a010 | https://github.com/akrennmair/gopcap/blob/00e11033259acb75598ba416495bb708d864a010/io.go#L66-L91 |
139,361 | akrennmair/gopcap | io.go | Next | func (r *Reader) Next() *Packet {
d := r.sixteenBytes
r.err = r.read(d)
if r.err != nil {
return nil
}
timeSec := asUint32(d[0:4], r.flip)
timeUsec := asUint32(d[4:8], r.flip)
capLen := asUint32(d[8:12], r.flip)
origLen := asUint32(d[12:16], r.flip)
data := make([]byte, capLen)
if r.err = r.read(data); r.e... | go | func (r *Reader) Next() *Packet {
d := r.sixteenBytes
r.err = r.read(d)
if r.err != nil {
return nil
}
timeSec := asUint32(d[0:4], r.flip)
timeUsec := asUint32(d[4:8], r.flip)
capLen := asUint32(d[8:12], r.flip)
origLen := asUint32(d[12:16], r.flip)
data := make([]byte, capLen)
if r.err = r.read(data); r.e... | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Next",
"(",
")",
"*",
"Packet",
"{",
"d",
":=",
"r",
".",
"sixteenBytes",
"\n",
"r",
".",
"err",
"=",
"r",
".",
"read",
"(",
"d",
")",
"\n",
"if",
"r",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\... | // Next returns the next packet or nil if no more packets can be read. | [
"Next",
"returns",
"the",
"next",
"packet",
"or",
"nil",
"if",
"no",
"more",
"packets",
"can",
"be",
"read",
"."
] | 00e11033259acb75598ba416495bb708d864a010 | https://github.com/akrennmair/gopcap/blob/00e11033259acb75598ba416495bb708d864a010/io.go#L94-L115 |
139,362 | akrennmair/gopcap | io.go | NewWriter | func NewWriter(writer io.Writer, header *FileHeader) (*Writer, error) {
w := &Writer{
writer: writer,
buf: make([]byte, 24),
}
binary.LittleEndian.PutUint32(w.buf, header.MagicNumber)
binary.LittleEndian.PutUint16(w.buf[4:], header.VersionMajor)
binary.LittleEndian.PutUint16(w.buf[6:], header.VersionMinor)
... | go | func NewWriter(writer io.Writer, header *FileHeader) (*Writer, error) {
w := &Writer{
writer: writer,
buf: make([]byte, 24),
}
binary.LittleEndian.PutUint32(w.buf, header.MagicNumber)
binary.LittleEndian.PutUint16(w.buf[4:], header.VersionMajor)
binary.LittleEndian.PutUint16(w.buf[6:], header.VersionMinor)
... | [
"func",
"NewWriter",
"(",
"writer",
"io",
".",
"Writer",
",",
"header",
"*",
"FileHeader",
")",
"(",
"*",
"Writer",
",",
"error",
")",
"{",
"w",
":=",
"&",
"Writer",
"{",
"writer",
":",
"writer",
",",
"buf",
":",
"make",
"(",
"[",
"]",
"byte",
",... | // NewWriter creates a Writer that stores output in an io.Writer.
// The FileHeader is written immediately. | [
"NewWriter",
"creates",
"a",
"Writer",
"that",
"stores",
"output",
"in",
"an",
"io",
".",
"Writer",
".",
"The",
"FileHeader",
"is",
"written",
"immediately",
"."
] | 00e11033259acb75598ba416495bb708d864a010 | https://github.com/akrennmair/gopcap/blob/00e11033259acb75598ba416495bb708d864a010/io.go#L163-L179 |
139,363 | akrennmair/gopcap | io.go | Write | func (w *Writer) Write(pkt *Packet) error {
binary.LittleEndian.PutUint32(w.buf, uint32(pkt.Time.Unix()))
binary.LittleEndian.PutUint32(w.buf[4:], uint32(pkt.Time.Nanosecond()))
binary.LittleEndian.PutUint32(w.buf[8:], uint32(pkt.Time.Unix()))
binary.LittleEndian.PutUint32(w.buf[12:], pkt.Len)
if _, err := w.write... | go | func (w *Writer) Write(pkt *Packet) error {
binary.LittleEndian.PutUint32(w.buf, uint32(pkt.Time.Unix()))
binary.LittleEndian.PutUint32(w.buf[4:], uint32(pkt.Time.Nanosecond()))
binary.LittleEndian.PutUint32(w.buf[8:], uint32(pkt.Time.Unix()))
binary.LittleEndian.PutUint32(w.buf[12:], pkt.Len)
if _, err := w.write... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"pkt",
"*",
"Packet",
")",
"error",
"{",
"binary",
".",
"LittleEndian",
".",
"PutUint32",
"(",
"w",
".",
"buf",
",",
"uint32",
"(",
"pkt",
".",
"Time",
".",
"Unix",
"(",
")",
")",
")",
"\n",
"... | // Writer writes a packet to the underlying writer. | [
"Writer",
"writes",
"a",
"packet",
"to",
"the",
"underlying",
"writer",
"."
] | 00e11033259acb75598ba416495bb708d864a010 | https://github.com/akrennmair/gopcap/blob/00e11033259acb75598ba416495bb708d864a010/io.go#L182-L192 |
139,364 | akrennmair/gopcap | decode.go | Decode | func (p *Packet) Decode() {
if len(p.Data) <= 14 {
return
}
p.Type = int(binary.BigEndian.Uint16(p.Data[12:14]))
p.DestMac = decodemac(p.Data[0:6])
p.SrcMac = decodemac(p.Data[6:12])
if len(p.Data) >= 15 {
p.Payload = p.Data[14:]
}
switch p.Type {
case TYPE_IP:
p.decodeIp()
case TYPE_IP6:
p.decodeI... | go | func (p *Packet) Decode() {
if len(p.Data) <= 14 {
return
}
p.Type = int(binary.BigEndian.Uint16(p.Data[12:14]))
p.DestMac = decodemac(p.Data[0:6])
p.SrcMac = decodemac(p.Data[6:12])
if len(p.Data) >= 15 {
p.Payload = p.Data[14:]
}
switch p.Type {
case TYPE_IP:
p.decodeIp()
case TYPE_IP6:
p.decodeI... | [
"func",
"(",
"p",
"*",
"Packet",
")",
"Decode",
"(",
")",
"{",
"if",
"len",
"(",
"p",
".",
"Data",
")",
"<=",
"14",
"{",
"return",
"\n",
"}",
"\n\n",
"p",
".",
"Type",
"=",
"int",
"(",
"binary",
".",
"BigEndian",
".",
"Uint16",
"(",
"p",
".",... | // Decode decodes the headers of a Packet. | [
"Decode",
"decodes",
"the",
"headers",
"of",
"a",
"Packet",
"."
] | 00e11033259acb75598ba416495bb708d864a010 | https://github.com/akrennmair/gopcap/blob/00e11033259acb75598ba416495bb708d864a010/decode.go#L73-L96 |
139,365 | akrennmair/gopcap | decode.go | String | func (p *Packet) String() string {
// If there are no headers, print "unsupported protocol".
if len(p.Headers) == 0 {
return fmt.Sprintf("%s unsupported protocol %d", p.Time, int(p.Type))
}
return fmt.Sprintf("%s %s", p.Time, p.headerString(p.Headers))
} | go | func (p *Packet) String() string {
// If there are no headers, print "unsupported protocol".
if len(p.Headers) == 0 {
return fmt.Sprintf("%s unsupported protocol %d", p.Time, int(p.Type))
}
return fmt.Sprintf("%s %s", p.Time, p.headerString(p.Headers))
} | [
"func",
"(",
"p",
"*",
"Packet",
")",
"String",
"(",
")",
"string",
"{",
"// If there are no headers, print \"unsupported protocol\".",
"if",
"len",
"(",
"p",
".",
"Headers",
")",
"==",
"0",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
... | // String prints a one-line representation of the packet header.
// The output is suitable for use in a tcpdump program. | [
"String",
"prints",
"a",
"one",
"-",
"line",
"representation",
"of",
"the",
"packet",
"header",
".",
"The",
"output",
"is",
"suitable",
"for",
"use",
"in",
"a",
"tcpdump",
"program",
"."
] | 00e11033259acb75598ba416495bb708d864a010 | https://github.com/akrennmair/gopcap/blob/00e11033259acb75598ba416495bb708d864a010/decode.go#L134-L140 |
139,366 | zebresel-com/mongodm | query.go | extendQuery | func (self *Query) extendQuery(mgoQuery *mgo.Query) {
if self.selector != nil {
mgoQuery.Select(self.selector)
}
if len(self.sort) > 0 {
mgoQuery.Sort(self.sort...)
}
if self.limit != 0 {
mgoQuery.Limit(self.limit)
}
if self.skip != 0 {
mgoQuery.Skip(self.skip)
}
} | go | func (self *Query) extendQuery(mgoQuery *mgo.Query) {
if self.selector != nil {
mgoQuery.Select(self.selector)
}
if len(self.sort) > 0 {
mgoQuery.Sort(self.sort...)
}
if self.limit != 0 {
mgoQuery.Limit(self.limit)
}
if self.skip != 0 {
mgoQuery.Skip(self.skip)
}
} | [
"func",
"(",
"self",
"*",
"Query",
")",
"extendQuery",
"(",
"mgoQuery",
"*",
"mgo",
".",
"Query",
")",
"{",
"if",
"self",
".",
"selector",
"!=",
"nil",
"{",
"mgoQuery",
".",
"Select",
"(",
"self",
".",
"selector",
")",
"\n",
"}",
"\n\n",
"if",
"len... | //extendQuery sets all native query options if specified | [
"extendQuery",
"sets",
"all",
"native",
"query",
"options",
"if",
"specified"
] | 0f86ddb8074ef02ed5627369f982682db60a98f6 | https://github.com/zebresel-com/mongodm/blob/0f86ddb8074ef02ed5627369f982682db60a98f6/query.go#L211-L228 |
139,367 | chewxy/lingo | dep/dependencyParser.go | New | func New(m *Model) *Parser {
d := &Parser{
Output: make(chan *lingo.Dependency),
Error: make(chan error),
Model: m,
}
return d
} | go | func New(m *Model) *Parser {
d := &Parser{
Output: make(chan *lingo.Dependency),
Error: make(chan error),
Model: m,
}
return d
} | [
"func",
"New",
"(",
"m",
"*",
"Model",
")",
"*",
"Parser",
"{",
"d",
":=",
"&",
"Parser",
"{",
"Output",
":",
"make",
"(",
"chan",
"*",
"lingo",
".",
"Dependency",
")",
",",
"Error",
":",
"make",
"(",
"chan",
"error",
")",
",",
"Model",
":",
"m... | // New creates a new Parser | [
"New",
"creates",
"a",
"new",
"Parser"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/dependencyParser.go#L26-L35 |
139,368 | chewxy/lingo | dep/configuration.go | stackValue | func (c *configuration) stackValue(i int) head {
size := c.stackSize()
if i >= size || i < 0 {
return DOES_NOT_EXIST
}
return c.stack[size-1-i]
} | go | func (c *configuration) stackValue(i int) head {
size := c.stackSize()
if i >= size || i < 0 {
return DOES_NOT_EXIST
}
return c.stack[size-1-i]
} | [
"func",
"(",
"c",
"*",
"configuration",
")",
"stackValue",
"(",
"i",
"int",
")",
"head",
"{",
"size",
":=",
"c",
".",
"stackSize",
"(",
")",
"\n",
"if",
"i",
">=",
"size",
"||",
"i",
"<",
"0",
"{",
"return",
"DOES_NOT_EXIST",
"\n",
"}",
"\n",
"re... | // gets the sentence index of the ith word on the stack. If there isn't anything on the stack, it returns DOES_NOT_EXIST | [
"gets",
"the",
"sentence",
"index",
"of",
"the",
"ith",
"word",
"on",
"the",
"stack",
".",
"If",
"there",
"isn",
"t",
"anything",
"on",
"the",
"stack",
"it",
"returns",
"DOES_NOT_EXIST"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/configuration.go#L72-L78 |
139,369 | chewxy/lingo | dep/configuration.go | removeStack | func (c *configuration) removeStack(i int) {
c.stack = c.stack[:i+copy(c.stack[i:], c.stack[i+1:])]
} | go | func (c *configuration) removeStack(i int) {
c.stack = c.stack[:i+copy(c.stack[i:], c.stack[i+1:])]
} | [
"func",
"(",
"c",
"*",
"configuration",
")",
"removeStack",
"(",
"i",
"int",
")",
"{",
"c",
".",
"stack",
"=",
"c",
".",
"stack",
"[",
":",
"i",
"+",
"copy",
"(",
"c",
".",
"stack",
"[",
"i",
":",
"]",
",",
"c",
".",
"stack",
"[",
"i",
"+",... | // removes a value from the stack. | [
"removes",
"a",
"value",
"from",
"the",
"stack",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/configuration.go#L98-L100 |
139,370 | chewxy/lingo | dep/configuration.go | removeSecondTopStack | func (c *configuration) removeSecondTopStack() bool {
stackSize := c.stackSize()
if stackSize < 2 {
return false
}
i := stackSize - 2
c.removeStack(i)
return true
} | go | func (c *configuration) removeSecondTopStack() bool {
stackSize := c.stackSize()
if stackSize < 2 {
return false
}
i := stackSize - 2
c.removeStack(i)
return true
} | [
"func",
"(",
"c",
"*",
"configuration",
")",
"removeSecondTopStack",
"(",
")",
"bool",
"{",
"stackSize",
":=",
"c",
".",
"stackSize",
"(",
")",
"\n",
"if",
"stackSize",
"<",
"2",
"{",
"return",
"false",
"\n",
"}",
"\n",
"i",
":=",
"stackSize",
"-",
"... | // removeSecondTopStack removes the 2nd-to-last element | [
"removeSecondTopStack",
"removes",
"the",
"2nd",
"-",
"to",
"-",
"last",
"element"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/configuration.go#L103-L111 |
139,371 | chewxy/lingo | dep/configuration.go | lc | func (c *configuration) lc(k, cnt head) head {
if k < 0 || int(k) > c.N() {
return DOES_NOT_EXIST
}
cc := 0
for i := 1; i < int(k); i++ {
if c.Head(i) == int(k) {
cc++
if int(cnt) == cc {
return head(i)
}
}
}
return DOES_NOT_EXIST
} | go | func (c *configuration) lc(k, cnt head) head {
if k < 0 || int(k) > c.N() {
return DOES_NOT_EXIST
}
cc := 0
for i := 1; i < int(k); i++ {
if c.Head(i) == int(k) {
cc++
if int(cnt) == cc {
return head(i)
}
}
}
return DOES_NOT_EXIST
} | [
"func",
"(",
"c",
"*",
"configuration",
")",
"lc",
"(",
"k",
",",
"cnt",
"head",
")",
"head",
"{",
"if",
"k",
"<",
"0",
"||",
"int",
"(",
"k",
")",
">",
"c",
".",
"N",
"(",
")",
"{",
"return",
"DOES_NOT_EXIST",
"\n",
"}",
"\n\n",
"cc",
":=",
... | // gets the jth left child of the ith word of a sentence | [
"gets",
"the",
"jth",
"left",
"child",
"of",
"the",
"ith",
"word",
"of",
"a",
"sentence"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/configuration.go#L157-L172 |
139,372 | chewxy/lingo | dep/configuration.go | shift | func (c *configuration) shift() bool {
i := c.bufferValue(0)
if i == DOES_NOT_EXIST {
return false
}
c.bp++ // move the buffer pointer up
c.stack = append(c.stack, i) // push to it.... gotta work the pop
return true
} | go | func (c *configuration) shift() bool {
i := c.bufferValue(0)
if i == DOES_NOT_EXIST {
return false
}
c.bp++ // move the buffer pointer up
c.stack = append(c.stack, i) // push to it.... gotta work the pop
return true
} | [
"func",
"(",
"c",
"*",
"configuration",
")",
"shift",
"(",
")",
"bool",
"{",
"i",
":=",
"c",
".",
"bufferValue",
"(",
"0",
")",
"\n",
"if",
"i",
"==",
"DOES_NOT_EXIST",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"c",
".",
"bp",
"++",
"// move the b... | // Actual Transitioning stuff | [
"Actual",
"Transitioning",
"stuff"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/configuration.go#L205-L215 |
139,373 | chewxy/lingo | lexer/stateFn.go | lexNumber | func lexNumber(l *Lexer) (fn stateFn) {
l.acceptRunFn(unicode.IsDigit)
next := l.next()
switch next {
case '.':
l.accept() // accept the dot
l.acceptRunFn(unicode.IsDigit)
case '-', '/':
// standardize
l.r = '/'
l.accept()
return lexDate
case ':':
if l.pos-l.start == 3 {
l.accept()
return lex... | go | func lexNumber(l *Lexer) (fn stateFn) {
l.acceptRunFn(unicode.IsDigit)
next := l.next()
switch next {
case '.':
l.accept() // accept the dot
l.acceptRunFn(unicode.IsDigit)
case '-', '/':
// standardize
l.r = '/'
l.accept()
return lexDate
case ':':
if l.pos-l.start == 3 {
l.accept()
return lex... | [
"func",
"lexNumber",
"(",
"l",
"*",
"Lexer",
")",
"(",
"fn",
"stateFn",
")",
"{",
"l",
".",
"acceptRunFn",
"(",
"unicode",
".",
"IsDigit",
")",
"\n\n",
"next",
":=",
"l",
".",
"next",
"(",
")",
"\n",
"switch",
"next",
"{",
"case",
"'.'",
":",
"l"... | // lexNumber lexes numbers. It accepts runs of unicode digits.
// Upon stopping, it checks to see if the next value is a '.'. If it is, then it's a decimal value, and continues a run
// Upon stopping a second time, it checks for 'e' or 'E', for exponentiation - 1.2E2 | [
"lexNumber",
"lexes",
"numbers",
".",
"It",
"accepts",
"runs",
"of",
"unicode",
"digits",
".",
"Upon",
"stopping",
"it",
"checks",
"to",
"see",
"if",
"the",
"next",
"value",
"is",
"a",
".",
".",
"If",
"it",
"is",
"then",
"it",
"s",
"a",
"decimal",
"v... | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/lexer/stateFn.go#L117-L160 |
139,374 | chewxy/lingo | dep/train.go | WithTrainingModel | func WithTrainingModel(m *Model) TrainerConsOpt {
f := func(t *Trainer) {
t.Model = m
}
return f
} | go | func WithTrainingModel(m *Model) TrainerConsOpt {
f := func(t *Trainer) {
t.Model = m
}
return f
} | [
"func",
"WithTrainingModel",
"(",
"m",
"*",
"Model",
")",
"TrainerConsOpt",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Trainer",
")",
"{",
"t",
".",
"Model",
"=",
"m",
"\n",
"}",
"\n",
"return",
"f",
"\n",
"}"
] | // WithTrainingModel loads a trainer with a model | [
"WithTrainingModel",
"loads",
"a",
"trainer",
"with",
"a",
"model"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L18-L23 |
139,375 | chewxy/lingo | dep/train.go | WithTrainingSet | func WithTrainingSet(st []treebank.SentenceTag) TrainerConsOpt {
f := func(t *Trainer) {
t.trainingSet = st
}
return f
} | go | func WithTrainingSet(st []treebank.SentenceTag) TrainerConsOpt {
f := func(t *Trainer) {
t.trainingSet = st
}
return f
} | [
"func",
"WithTrainingSet",
"(",
"st",
"[",
"]",
"treebank",
".",
"SentenceTag",
")",
"TrainerConsOpt",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Trainer",
")",
"{",
"t",
".",
"trainingSet",
"=",
"st",
"\n",
"}",
"\n",
"return",
"f",
"\n",
"}"
] | // WithTrainingSet creates a trainer with a training set | [
"WithTrainingSet",
"creates",
"a",
"trainer",
"with",
"a",
"training",
"set"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L26-L31 |
139,376 | chewxy/lingo | dep/train.go | WithCrossValidationSet | func WithCrossValidationSet(st []treebank.SentenceTag) TrainerConsOpt {
f := func(t *Trainer) {
t.crossValSet = st
}
return f
} | go | func WithCrossValidationSet(st []treebank.SentenceTag) TrainerConsOpt {
f := func(t *Trainer) {
t.crossValSet = st
}
return f
} | [
"func",
"WithCrossValidationSet",
"(",
"st",
"[",
"]",
"treebank",
".",
"SentenceTag",
")",
"TrainerConsOpt",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Trainer",
")",
"{",
"t",
".",
"crossValSet",
"=",
"st",
"\n",
"}",
"\n",
"return",
"f",
"\n",
"}"
] | // WithCrossValidationSet creates a trainer with a cross validation set | [
"WithCrossValidationSet",
"creates",
"a",
"trainer",
"with",
"a",
"cross",
"validation",
"set"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L34-L39 |
139,377 | chewxy/lingo | dep/train.go | WithLemmatizer | func WithLemmatizer(l lingo.Lemmatizer) TrainerConsOpt {
f := func(t *Trainer) {
// cannot pass in itself!
if T, ok := l.(*Trainer); ok && T == t {
panic("Recursive definition of lemmatizer (trying to set the t.lemmatizer = T) !")
}
t.l = l
}
return f
} | go | func WithLemmatizer(l lingo.Lemmatizer) TrainerConsOpt {
f := func(t *Trainer) {
// cannot pass in itself!
if T, ok := l.(*Trainer); ok && T == t {
panic("Recursive definition of lemmatizer (trying to set the t.lemmatizer = T) !")
}
t.l = l
}
return f
} | [
"func",
"WithLemmatizer",
"(",
"l",
"lingo",
".",
"Lemmatizer",
")",
"TrainerConsOpt",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Trainer",
")",
"{",
"// cannot pass in itself!",
"if",
"T",
",",
"ok",
":=",
"l",
".",
"(",
"*",
"Trainer",
")",
";",
"ok",
... | // WithLemmatizer sets the lemmatizer option on the Trainer | [
"WithLemmatizer",
"sets",
"the",
"lemmatizer",
"option",
"on",
"the",
"Trainer"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L53-L63 |
139,378 | chewxy/lingo | dep/train.go | WithStemmer | func WithStemmer(s lingo.Stemmer) TrainerConsOpt {
f := func(t *Trainer) {
// cannot pass in itself
if T, ok := s.(*Trainer); ok && T == t {
panic("Recursive setting of stemmer! (Trying to set t.stemmer = T)")
}
t.s = s
}
return f
} | go | func WithStemmer(s lingo.Stemmer) TrainerConsOpt {
f := func(t *Trainer) {
// cannot pass in itself
if T, ok := s.(*Trainer); ok && T == t {
panic("Recursive setting of stemmer! (Trying to set t.stemmer = T)")
}
t.s = s
}
return f
} | [
"func",
"WithStemmer",
"(",
"s",
"lingo",
".",
"Stemmer",
")",
"TrainerConsOpt",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Trainer",
")",
"{",
"// cannot pass in itself",
"if",
"T",
",",
"ok",
":=",
"s",
".",
"(",
"*",
"Trainer",
")",
";",
"ok",
"&&",
... | // WithStemmer sets up the stemmer option on the DependencyParser | [
"WithStemmer",
"sets",
"up",
"the",
"stemmer",
"option",
"on",
"the",
"DependencyParser"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L66-L75 |
139,379 | chewxy/lingo | dep/train.go | WithCluster | func WithCluster(c map[string]lingo.Cluster) TrainerConsOpt {
f := func(t *Trainer) {
t.c = c
}
return f
} | go | func WithCluster(c map[string]lingo.Cluster) TrainerConsOpt {
f := func(t *Trainer) {
t.c = c
}
return f
} | [
"func",
"WithCluster",
"(",
"c",
"map",
"[",
"string",
"]",
"lingo",
".",
"Cluster",
")",
"TrainerConsOpt",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Trainer",
")",
"{",
"t",
".",
"c",
"=",
"c",
"\n",
"}",
"\n",
"return",
"f",
"\n",
"}"
] | // WithCluster sets the brown cluster options for the DependencyParser | [
"WithCluster",
"sets",
"the",
"brown",
"cluster",
"options",
"for",
"the",
"DependencyParser"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L78-L83 |
139,380 | chewxy/lingo | dep/train.go | WithCorpus | func WithCorpus(c *corpus.Corpus) TrainerConsOpt {
f := func(t *Trainer) {
t.corpus = c
t.nn.dict = c
}
return f
} | go | func WithCorpus(c *corpus.Corpus) TrainerConsOpt {
f := func(t *Trainer) {
t.corpus = c
t.nn.dict = c
}
return f
} | [
"func",
"WithCorpus",
"(",
"c",
"*",
"corpus",
".",
"Corpus",
")",
"TrainerConsOpt",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Trainer",
")",
"{",
"t",
".",
"corpus",
"=",
"c",
"\n",
"t",
".",
"nn",
".",
"dict",
"=",
"c",
"\n",
"}",
"\n",
"return... | // WithCorpus creates a Trainer with a corpus | [
"WithCorpus",
"creates",
"a",
"Trainer",
"with",
"a",
"corpus"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L86-L92 |
139,381 | chewxy/lingo | dep/train.go | WithGeneratedCorpus | func WithGeneratedCorpus(sts ...treebank.SentenceTag) TrainerConsOpt {
f := func(t *Trainer) {
dict := corpus.GenerateCorpus(sts)
if t.corpus == nil {
t.corpus = dict
} else {
t.corpus.Merge(dict)
}
t.nn.dict = t.corpus
}
return f
} | go | func WithGeneratedCorpus(sts ...treebank.SentenceTag) TrainerConsOpt {
f := func(t *Trainer) {
dict := corpus.GenerateCorpus(sts)
if t.corpus == nil {
t.corpus = dict
} else {
t.corpus.Merge(dict)
}
t.nn.dict = t.corpus
}
return f
} | [
"func",
"WithGeneratedCorpus",
"(",
"sts",
"...",
"treebank",
".",
"SentenceTag",
")",
"TrainerConsOpt",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Trainer",
")",
"{",
"dict",
":=",
"corpus",
".",
"GenerateCorpus",
"(",
"sts",
")",
"\n",
"if",
"t",
".",
"... | // WithGeneratedCorpus creates a Trainer's corpus from a list of SentenceTags. The corpus will be generated from the SentenceTags | [
"WithGeneratedCorpus",
"creates",
"a",
"Trainer",
"s",
"corpus",
"from",
"a",
"list",
"of",
"SentenceTags",
".",
"The",
"corpus",
"will",
"be",
"generated",
"from",
"the",
"SentenceTags"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L95-L107 |
139,382 | chewxy/lingo | dep/train.go | NewTrainer | func NewTrainer(opts ...TrainerConsOpt) *Trainer {
t := new(Trainer)
// set up the default model
t.Model = new(Model)
t.corpus = KnownWords
t.ts = transitions
// set up the neural network
t.nn = new(neuralnetwork2)
t.nn.NNConfig = DefaultNNConfig
t.nn.transitions = transitions
t.nn.dict = KnownWords
for _,... | go | func NewTrainer(opts ...TrainerConsOpt) *Trainer {
t := new(Trainer)
// set up the default model
t.Model = new(Model)
t.corpus = KnownWords
t.ts = transitions
// set up the neural network
t.nn = new(neuralnetwork2)
t.nn.NNConfig = DefaultNNConfig
t.nn.transitions = transitions
t.nn.dict = KnownWords
for _,... | [
"func",
"NewTrainer",
"(",
"opts",
"...",
"TrainerConsOpt",
")",
"*",
"Trainer",
"{",
"t",
":=",
"new",
"(",
"Trainer",
")",
"\n",
"// set up the default model",
"t",
".",
"Model",
"=",
"new",
"(",
"Model",
")",
"\n",
"t",
".",
"corpus",
"=",
"KnownWords... | // NewTrainer creates a new Trainer. | [
"NewTrainer",
"creates",
"a",
"new",
"Trainer",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L133-L150 |
139,383 | chewxy/lingo | dep/train.go | Lemmatize | func (t *Trainer) Lemmatize(a string, pt lingo.POSTag) ([]string, error) {
if t.l == nil {
return nil, componentUnavailable("Lemmatizer")
}
return t.l.Lemmatize(a, pt)
} | go | func (t *Trainer) Lemmatize(a string, pt lingo.POSTag) ([]string, error) {
if t.l == nil {
return nil, componentUnavailable("Lemmatizer")
}
return t.l.Lemmatize(a, pt)
} | [
"func",
"(",
"t",
"*",
"Trainer",
")",
"Lemmatize",
"(",
"a",
"string",
",",
"pt",
"lingo",
".",
"POSTag",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"t",
".",
"l",
"==",
"nil",
"{",
"return",
"nil",
",",
"componentUnavailable",
... | // Lemmatize implemnets lingo.Lemmatizer | [
"Lemmatize",
"implemnets",
"lingo",
".",
"Lemmatizer"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L153-L158 |
139,384 | chewxy/lingo | dep/train.go | Stem | func (t *Trainer) Stem(a string) (string, error) {
if t.s == nil {
return "", componentUnavailable("Stemmer")
}
return t.s.Stem(a)
} | go | func (t *Trainer) Stem(a string) (string, error) {
if t.s == nil {
return "", componentUnavailable("Stemmer")
}
return t.s.Stem(a)
} | [
"func",
"(",
"t",
"*",
"Trainer",
")",
"Stem",
"(",
"a",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"t",
".",
"s",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"componentUnavailable",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"ret... | // Stem implements lingo.Stemmer | [
"Stem",
"implements",
"lingo",
".",
"Stemmer"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L161-L166 |
139,385 | chewxy/lingo | dep/train.go | Clusters | func (t *Trainer) Clusters() (map[string]lingo.Cluster, error) {
if t.c == nil {
return nil, componentUnavailable("Clusters")
}
return t.c, nil
} | go | func (t *Trainer) Clusters() (map[string]lingo.Cluster, error) {
if t.c == nil {
return nil, componentUnavailable("Clusters")
}
return t.c, nil
} | [
"func",
"(",
"t",
"*",
"Trainer",
")",
"Clusters",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"lingo",
".",
"Cluster",
",",
"error",
")",
"{",
"if",
"t",
".",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"componentUnavailable",
"(",
"\"",
"\"",
")... | // Clusters implements lingo.Fixer | [
"Clusters",
"implements",
"lingo",
".",
"Fixer"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L169-L174 |
139,386 | chewxy/lingo | dep/train.go | Perf | func (t *Trainer) Perf() <-chan Performance {
if t.perf == nil {
t.perf = make(chan Performance)
}
return t.perf
} | go | func (t *Trainer) Perf() <-chan Performance {
if t.perf == nil {
t.perf = make(chan Performance)
}
return t.perf
} | [
"func",
"(",
"t",
"*",
"Trainer",
")",
"Perf",
"(",
")",
"<-",
"chan",
"Performance",
"{",
"if",
"t",
".",
"perf",
"==",
"nil",
"{",
"t",
".",
"perf",
"=",
"make",
"(",
"chan",
"Performance",
")",
"\n",
"}",
"\n",
"return",
"t",
".",
"perf",
"\... | // Perf returns a channel of Performance for monitoring the training. | [
"Perf",
"returns",
"a",
"channel",
"of",
"Performance",
"for",
"monitoring",
"the",
"training",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L188-L193 |
139,387 | chewxy/lingo | dep/train.go | Train | func (t *Trainer) Train(epochs int) error {
if err := t.pretrainCheck(); err != nil {
return err
}
if len(t.crossValSet) > 0 {
return t.crossValidateTrain(epochs)
}
return t.train(epochs)
} | go | func (t *Trainer) Train(epochs int) error {
if err := t.pretrainCheck(); err != nil {
return err
}
if len(t.crossValSet) > 0 {
return t.crossValidateTrain(epochs)
}
return t.train(epochs)
} | [
"func",
"(",
"t",
"*",
"Trainer",
")",
"Train",
"(",
"epochs",
"int",
")",
"error",
"{",
"if",
"err",
":=",
"t",
".",
"pretrainCheck",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"t",
".",
"crossV... | // Train trains a model.
//
// If a cross validation set is provided, it will automatically train with the cross validation set | [
"Train",
"trains",
"a",
"model",
".",
"If",
"a",
"cross",
"validation",
"set",
"is",
"provided",
"it",
"will",
"automatically",
"train",
"with",
"the",
"cross",
"validation",
"set"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L209-L217 |
139,388 | chewxy/lingo | dep/train.go | train | func (t *Trainer) train(epochs int) error {
var epochChan chan struct{}
if t.cost != nil {
defer func() {
close(t.cost)
t.cost = nil
}()
epochChan = t.handleCosts()
if epochChan != nil {
defer close(epochChan)
}
}
examples := makeExamples(t.trainingSet, t.nn.NNConfig, t.nn.dict, t.ts, t)
for... | go | func (t *Trainer) train(epochs int) error {
var epochChan chan struct{}
if t.cost != nil {
defer func() {
close(t.cost)
t.cost = nil
}()
epochChan = t.handleCosts()
if epochChan != nil {
defer close(epochChan)
}
}
examples := makeExamples(t.trainingSet, t.nn.NNConfig, t.nn.dict, t.ts, t)
for... | [
"func",
"(",
"t",
"*",
"Trainer",
")",
"train",
"(",
"epochs",
"int",
")",
"error",
"{",
"var",
"epochChan",
"chan",
"struct",
"{",
"}",
"\n",
"if",
"t",
".",
"cost",
"!=",
"nil",
"{",
"defer",
"func",
"(",
")",
"{",
"close",
"(",
"t",
".",
"co... | // train simply trains the model without having a cross validation. | [
"train",
"simply",
"trains",
"the",
"model",
"without",
"having",
"a",
"cross",
"validation",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L225-L254 |
139,389 | chewxy/lingo | dep/train.go | crossValidateTrain | func (t *Trainer) crossValidateTrain(epochs int) error {
if t.perf != nil {
defer func() {
close(t.perf)
t.perf = nil
}()
}
var epochChan chan struct{}
if t.cost != nil {
defer func() {
close(t.cost)
t.cost = nil
}()
epochChan = t.handleCosts()
if epochChan != nil {
defer close(epochCha... | go | func (t *Trainer) crossValidateTrain(epochs int) error {
if t.perf != nil {
defer func() {
close(t.perf)
t.perf = nil
}()
}
var epochChan chan struct{}
if t.cost != nil {
defer func() {
close(t.cost)
t.cost = nil
}()
epochChan = t.handleCosts()
if epochChan != nil {
defer close(epochCha... | [
"func",
"(",
"t",
"*",
"Trainer",
")",
"crossValidateTrain",
"(",
"epochs",
"int",
")",
"error",
"{",
"if",
"t",
".",
"perf",
"!=",
"nil",
"{",
"defer",
"func",
"(",
")",
"{",
"close",
"(",
"t",
".",
"perf",
")",
"\n",
"t",
".",
"perf",
"=",
"n... | // crossValidateTrain trains the model but also does cross validation to ensure overfitting don't happen. | [
"crossValidateTrain",
"trains",
"the",
"model",
"but",
"also",
"does",
"cross",
"validation",
"to",
"ensure",
"overfitting",
"don",
"t",
"happen",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L257-L316 |
139,390 | chewxy/lingo | dep/train.go | pretrainCheck | func (t *Trainer) pretrainCheck() error {
// check
if t.nn == nil || !t.nn.initialized() {
return errors.Errorf("DependencyParser not init()'d. Perhaps you forgot to call .Init() somewhere?")
}
if len(t.trainingSet) == 0 {
return errors.Errorf("Cannot train with no training data set")
}
return nil
} | go | func (t *Trainer) pretrainCheck() error {
// check
if t.nn == nil || !t.nn.initialized() {
return errors.Errorf("DependencyParser not init()'d. Perhaps you forgot to call .Init() somewhere?")
}
if len(t.trainingSet) == 0 {
return errors.Errorf("Cannot train with no training data set")
}
return nil
} | [
"func",
"(",
"t",
"*",
"Trainer",
")",
"pretrainCheck",
"(",
")",
"error",
"{",
"// check",
"if",
"t",
".",
"nn",
"==",
"nil",
"||",
"!",
"t",
".",
"nn",
".",
"initialized",
"(",
")",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
... | // pretrainCheck checks if everything is sane | [
"pretrainCheck",
"checks",
"if",
"everything",
"is",
"sane"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/train.go#L319-L330 |
139,391 | chewxy/lingo | POSTag.go | InPOSTags | func InPOSTags(x POSTag, set []POSTag) bool {
for _, v := range set {
if v == x {
return true
}
}
return false
} | go | func InPOSTags(x POSTag, set []POSTag) bool {
for _, v := range set {
if v == x {
return true
}
}
return false
} | [
"func",
"InPOSTags",
"(",
"x",
"POSTag",
",",
"set",
"[",
"]",
"POSTag",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"set",
"{",
"if",
"v",
"==",
"x",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // POSTag related functions | [
"POSTag",
"related",
"functions"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/POSTag.go#L34-L41 |
139,392 | chewxy/lingo | pos/postagger.go | Lemmatize | func (p *Tagger) Lemmatize(a string, pt lingo.POSTag) ([]string, error) {
if p.Lemmatizer == nil {
return nil, componentUnavailable("lemmatizer")
}
return p.Lemmatizer.Lemmatize(a, pt)
} | go | func (p *Tagger) Lemmatize(a string, pt lingo.POSTag) ([]string, error) {
if p.Lemmatizer == nil {
return nil, componentUnavailable("lemmatizer")
}
return p.Lemmatizer.Lemmatize(a, pt)
} | [
"func",
"(",
"p",
"*",
"Tagger",
")",
"Lemmatize",
"(",
"a",
"string",
",",
"pt",
"lingo",
".",
"POSTag",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"p",
".",
"Lemmatizer",
"==",
"nil",
"{",
"return",
"nil",
",",
"componentUnavaila... | // Lemmatize implements the lingo.Lemmatize interface. It however, defers the actual doing of the job to the Lemmatizer. | [
"Lemmatize",
"implements",
"the",
"lingo",
".",
"Lemmatize",
"interface",
".",
"It",
"however",
"defers",
"the",
"actual",
"doing",
"of",
"the",
"job",
"to",
"the",
"Lemmatizer",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/pos/postagger.go#L138-L143 |
139,393 | chewxy/lingo | pos/postagger.go | Stem | func (p *Tagger) Stem(a string) (string, error) {
if p.Stemmer == nil {
return "", componentUnavailable("stemmer")
}
return p.Stemmer.Stem(a)
} | go | func (p *Tagger) Stem(a string) (string, error) {
if p.Stemmer == nil {
return "", componentUnavailable("stemmer")
}
return p.Stemmer.Stem(a)
} | [
"func",
"(",
"p",
"*",
"Tagger",
")",
"Stem",
"(",
"a",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"p",
".",
"Stemmer",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"componentUnavailable",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
... | // Stem implements the lingo.Stemmer interface. It however, defers the actual stemming to the stemmer passed in. | [
"Stem",
"implements",
"the",
"lingo",
".",
"Stemmer",
"interface",
".",
"It",
"however",
"defers",
"the",
"actual",
"stemming",
"to",
"the",
"stemmer",
"passed",
"in",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/pos/postagger.go#L146-L151 |
139,394 | chewxy/lingo | pos/postagger.go | Clusters | func (p *Tagger) Clusters() (map[string]lingo.Cluster, error) {
if p.clusters == nil {
return nil, componentUnavailable("clusters")
}
return p.clusters, nil
} | go | func (p *Tagger) Clusters() (map[string]lingo.Cluster, error) {
if p.clusters == nil {
return nil, componentUnavailable("clusters")
}
return p.clusters, nil
} | [
"func",
"(",
"p",
"*",
"Tagger",
")",
"Clusters",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"lingo",
".",
"Cluster",
",",
"error",
")",
"{",
"if",
"p",
".",
"clusters",
"==",
"nil",
"{",
"return",
"nil",
",",
"componentUnavailable",
"(",
"\"",
"\""... | // Clusters implements the lingo.AnnotationFixer interface. | [
"Clusters",
"implements",
"the",
"lingo",
".",
"AnnotationFixer",
"interface",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/pos/postagger.go#L154-L159 |
139,395 | chewxy/lingo | pos/postagger.go | Progress | func (p *Tagger) Progress() <-chan Progress {
if p.progress == nil {
p.progress = make(chan Progress)
}
return p.progress
} | go | func (p *Tagger) Progress() <-chan Progress {
if p.progress == nil {
p.progress = make(chan Progress)
}
return p.progress
} | [
"func",
"(",
"p",
"*",
"Tagger",
")",
"Progress",
"(",
")",
"<-",
"chan",
"Progress",
"{",
"if",
"p",
".",
"progress",
"==",
"nil",
"{",
"p",
".",
"progress",
"=",
"make",
"(",
"chan",
"Progress",
")",
"\n",
"}",
"\n",
"return",
"p",
".",
"progre... | // Progress creates and returns a channel of progress. By default the progress channel isn't created, and no progress info is sent | [
"Progress",
"creates",
"and",
"returns",
"a",
"channel",
"of",
"progress",
".",
"By",
"default",
"the",
"progress",
"channel",
"isn",
"t",
"created",
"and",
"no",
"progress",
"info",
"is",
"sent"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/pos/postagger.go#L162-L167 |
139,396 | chewxy/lingo | pos/postagger.go | Train | func (p *Tagger) Train(sentences []treebank.SentenceTag, iterations int) {
if p.progress != nil {
defer func() {
close(p.progress)
p.progress = nil
}()
}
p.fillCache(sentences)
// Somehow sentenceTag.AnnotatedSentence() is memory leaky.
// As a result, the more training iterations there is, the more me... | go | func (p *Tagger) Train(sentences []treebank.SentenceTag, iterations int) {
if p.progress != nil {
defer func() {
close(p.progress)
p.progress = nil
}()
}
p.fillCache(sentences)
// Somehow sentenceTag.AnnotatedSentence() is memory leaky.
// As a result, the more training iterations there is, the more me... | [
"func",
"(",
"p",
"*",
"Tagger",
")",
"Train",
"(",
"sentences",
"[",
"]",
"treebank",
".",
"SentenceTag",
",",
"iterations",
"int",
")",
"{",
"if",
"p",
".",
"progress",
"!=",
"nil",
"{",
"defer",
"func",
"(",
")",
"{",
"close",
"(",
"p",
".",
"... | // Train trains a POSTagger, given a bunch of SentenceTags | [
"Train",
"trains",
"a",
"POSTagger",
"given",
"a",
"bunch",
"of",
"SentenceTags"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/pos/postagger.go#L170-L245 |
139,397 | chewxy/lingo | pos/postagger.go | LoadShortcuts | func (p *Tagger) LoadShortcuts(shortcuts map[string]lingo.POSTag) {
for shortcut, tags := range shortcuts {
p.cachedTags[shortcut] = tags
}
} | go | func (p *Tagger) LoadShortcuts(shortcuts map[string]lingo.POSTag) {
for shortcut, tags := range shortcuts {
p.cachedTags[shortcut] = tags
}
} | [
"func",
"(",
"p",
"*",
"Tagger",
")",
"LoadShortcuts",
"(",
"shortcuts",
"map",
"[",
"string",
"]",
"lingo",
".",
"POSTag",
")",
"{",
"for",
"shortcut",
",",
"tags",
":=",
"range",
"shortcuts",
"{",
"p",
".",
"cachedTags",
"[",
"shortcut",
"]",
"=",
... | // LoadShortcuts allows for domain specific things to be mapped into the tagger. | [
"LoadShortcuts",
"allows",
"for",
"domain",
"specific",
"things",
"to",
"be",
"mapped",
"into",
"the",
"tagger",
"."
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/pos/postagger.go#L248-L252 |
139,398 | chewxy/lingo | dep/example.go | makeOneExample | func makeOneExample(i int, sentenceTag treebank.SentenceTag, dict *corpus.Corpus, ts []transition, f lingo.AnnotationFixer) ([]example, error) {
var examples []example
s := sentenceTag.AnnotatedSentence(f)
dep := s.Dependency()
if dep.IsProjective() {
c := newConfiguration(s, true)
count := 0
for !c.isTermi... | go | func makeOneExample(i int, sentenceTag treebank.SentenceTag, dict *corpus.Corpus, ts []transition, f lingo.AnnotationFixer) ([]example, error) {
var examples []example
s := sentenceTag.AnnotatedSentence(f)
dep := s.Dependency()
if dep.IsProjective() {
c := newConfiguration(s, true)
count := 0
for !c.isTermi... | [
"func",
"makeOneExample",
"(",
"i",
"int",
",",
"sentenceTag",
"treebank",
".",
"SentenceTag",
",",
"dict",
"*",
"corpus",
".",
"Corpus",
",",
"ts",
"[",
"]",
"transition",
",",
"f",
"lingo",
".",
"AnnotationFixer",
")",
"(",
"[",
"]",
"example",
",",
... | // makeOneExample is an example of a poorly named function. It makes an example from a SentenceTag | [
"makeOneExample",
"is",
"an",
"example",
"of",
"a",
"poorly",
"named",
"function",
".",
"It",
"makes",
"an",
"example",
"from",
"a",
"SentenceTag"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/dep/example.go#L43-L82 |
139,399 | chewxy/lingo | treebank/treebank.go | LoadUniversal | func LoadUniversal(fileName string) []SentenceTag {
f, err := os.Open(fileName)
if err != nil {
panic(err)
}
defer f.Close()
return ReadConllu(f)
} | go | func LoadUniversal(fileName string) []SentenceTag {
f, err := os.Open(fileName)
if err != nil {
panic(err)
}
defer f.Close()
return ReadConllu(f)
} | [
"func",
"LoadUniversal",
"(",
"fileName",
"string",
")",
"[",
"]",
"SentenceTag",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"fileName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"defer",
"f",
"... | // LoadUniversal loads a treebank file formatted in a CONLLU format | [
"LoadUniversal",
"loads",
"a",
"treebank",
"file",
"formatted",
"in",
"a",
"CONLLU",
"format"
] | 238c8836f032c232f721977047cece06842fcdf2 | https://github.com/chewxy/lingo/blob/238c8836f032c232f721977047cece06842fcdf2/treebank/treebank.go#L21-L29 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.