Exemplo n.º 1
0
Arquivo: dir.go Projeto: timtadh/sfp
func NewDir(c *config.Config, fmtr lattice.Formatter, showPr bool, dirname string) (*Dir, error) {
	samples := c.OutputFile(dirname)
	err := os.MkdirAll(samples, 0775)
	if err != nil {
		return nil, err
	}
	var prfmtr lattice.PrFormatter
	if showPr {
		prfmtr = fmtr.PrFormatter()
	}
	r := &Dir{
		config: c,
		fmtr:   fmtr,
		prfmtr: prfmtr,
		dir:    samples,
	}
	return r, nil
}
Exemplo n.º 2
0
func NewUnique(conf *config.Config, fmtr lattice.Formatter, reporter miners.Reporter, histogramName string) (*Unique, error) {
	seen, err := conf.BytesIntMultiMap("unique-seen")
	if err != nil {
		return nil, err
	}
	var histogram io.WriteCloser = nil
	if histogramName != "" {
		histogram, err = os.Create(conf.OutputFile(histogramName + ".csv"))
		if err != nil {
			return nil, err
		}
	}
	u := &Unique{
		fmtr:      fmtr,
		Seen:      seen,
		Reporter:  reporter,
		histogram: histogram,
	}
	return u, nil
}
Exemplo n.º 3
0
Arquivo: file.go Projeto: timtadh/sfp
func NewFile(c *config.Config, fmtr lattice.Formatter, showPr bool, patternsFilename, embeddingsFilename, namesFilename, matricesFilename, prsFilename string) (*File, error) {
	patterns, err := os.Create(c.OutputFile(patternsFilename + fmtr.FileExt()))
	if err != nil {
		return nil, err
	}
	embeddings, err := os.Create(c.OutputFile(embeddingsFilename + fmtr.FileExt()))
	if err != nil {
		return nil, err
	}
	names, err := os.Create(c.OutputFile(namesFilename))
	if err != nil {
		return nil, err
	}
	var matrices io.WriteCloser
	var prs io.WriteCloser
	var prfmtr lattice.PrFormatter
	if showPr {
		prfmtr = fmtr.PrFormatter()
		if prfmtr != nil {
			prs, err = os.Create(c.OutputFile(prsFilename))
			if err != nil {
				return nil, err
			}
			matrices, err = os.Create(c.OutputFile(matricesFilename))
			if err != nil {
				return nil, err
			}
		}
	}
	r := &File{
		config:     c,
		fmtr:       fmtr,
		prfmtr:     prfmtr,
		patterns:   patterns,
		embeddings: embeddings,
		names:      names,
		matrices:   matrices,
		prs:        prs,
	}
	return r, nil
}