コード例 #1
0
ファイル: dir.go プロジェクト: 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
}
コード例 #2
0
ファイル: mine.go プロジェクト: timtadh/sfp
func NewWalker(conf *config.Config, estimatingWalks int, max bool) (*Walker, error) {
	ests, err := conf.BytesFloatMultiMap("uniprox-weight-ests")
	if err != nil {
		return nil, err
	}
	prs, err := conf.BytesFloatMultiMap("uniprox-selection-prs")
	if err != nil {
		return nil, err
	}
	miner := &Walker{
		EstimatingWalks: estimatingWalks,
		Ests:            ests,
		Prs:             prs,
		Max:             max,
	}
	miner.Walker = *walker.NewWalker(conf, graple.MakeAbsorbingWalk(graple.MakeSample(miner), make(chan error)))
	return miner, nil
}
コード例 #3
0
ファイル: unique.go プロジェクト: timtadh/sfp
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
}
コード例 #4
0
ファイル: file.go プロジェクト: 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
}
コード例 #5
0
ファイル: loader.go プロジェクト: timtadh/sfp
func NewItemSets(config *config.Config, min, max int) (i *ItemSets, err error) {
	parents, err := config.IntsIntsMultiMap("itemsets-parents")
	if err != nil {
		return nil, err
	}
	parentCount, err := config.IntsIntMultiMap("itemsets-parent-count")
	if err != nil {
		return nil, err
	}
	children, err := config.IntsIntsMultiMap("itemsets-children")
	if err != nil {
		return nil, err
	}
	childCount, err := config.IntsIntMultiMap("itemsets-child-count")
	if err != nil {
		return nil, err
	}
	canonKids, err := config.IntsIntsMultiMap("itemsets-canon-kids")
	if err != nil {
		return nil, err
	}
	canonKidCount, err := config.IntsIntMultiMap("itemsets-canon-kid-count")
	if err != nil {
		return nil, err
	}
	embeddings, err := config.IntsIntsMultiMap("itemsets-embeddings")
	if err != nil {
		return nil, err
	}
	i = &ItemSets{
		MinItems:      min,
		MaxItems:      max,
		Parents:       parents,
		ParentCount:   parentCount,
		Children:      children,
		ChildCount:    childCount,
		CanonKids:     canonKids,
		CanonKidCount: canonKidCount,
		Embeddings:    embeddings,
		config:        config,
	}
	return i, nil
}
コード例 #6
0
ファイル: digraph.go プロジェクト: timtadh/sfp
func NewDigraph(config *config.Config, dc *Config) (g *Digraph, err error) {
	if dc.MaxEdges <= 0 {
		dc.MaxEdges = int(math.MaxInt32)
	}
	if dc.MaxVertices <= 0 {
		dc.MaxVertices = int(math.MaxInt32)
	}
	if dc.MinEdges > dc.MaxEdges {
		dc.MinEdges = dc.MaxEdges - 1
	}
	if dc.MinVertices > dc.MaxVertices {
		dc.MinVertices = dc.MaxVertices - 1
	}
	nodeAttrs, err := config.IntJsonMultiMap("digraph-node-attrs")
	if err != nil {
		return nil, err
	}
	parents, err := config.MultiMap("digraph-parents")
	if err != nil {
		return nil, err
	}
	parentCount, err := config.BytesIntMultiMap("digraph-parent-count")
	if err != nil {
		return nil, err
	}
	children, err := config.MultiMap("digraph-children")
	if err != nil {
		return nil, err
	}
	childCount, err := config.BytesIntMultiMap("digraph-child-count")
	if err != nil {
		return nil, err
	}
	canonKids, err := config.MultiMap("digraph-canon-kids")
	if err != nil {
		return nil, err
	}
	canonKidCount, err := config.BytesIntMultiMap("digraph-canon-kid-count")
	if err != nil {
		return nil, err
	}
	embeddings, err := config.SubgraphEmbeddingMultiMap("digraph-embeddings")
	if err != nil {
		return nil, err
	}
	var unsupEmbs subgraph_embedding.MultiMap = nil
	if dc.Mode&EmbeddingPruning == EmbeddingPruning {
		unsupEmbs, err = config.SubgraphEmbeddingMultiMap("digraph-unsupported-embeddings")
		if err != nil {
			return nil, err
		}
	}
	var overlap subgraph_overlap.MultiMap = nil
	if dc.Mode&OverlapPruning == OverlapPruning {
		overlap, err = config.SubgraphOverlapMultiMap("digraph-overlap")
		if err != nil {
			return nil, err
		}
	}
	exts, err := config.BytesExtensionMultiMap("digraph-extensions")
	if err != nil {
		return nil, err
	}
	var unexts bytes_extension.MultiMap
	if dc.Mode&ExtensionPruning == ExtensionPruning {
		unexts, err = config.BytesExtensionMultiMap("digraph-unsupported-extensions")
		if err != nil {
			return nil, err
		}
	}
	frequency, err := config.BytesIntMultiMap("digraph-pattern-frequency")
	if err != nil {
		return nil, err
	}
	g = &Digraph{
		Config:        *dc,
		NodeAttrs:     nodeAttrs,
		Embeddings:    embeddings,
		UnsupEmbs:     unsupEmbs,
		Overlap:       overlap,
		Extensions:    exts,
		UnsupExts:     unexts,
		Parents:       parents,
		ParentCount:   parentCount,
		Children:      children,
		ChildCount:    childCount,
		CanonKids:     canonKids,
		CanonKidCount: canonKidCount,
		Frequency:     frequency,
		config:        config,
		pool:          pool.New(config.Workers()),
	}
	return g, nil
}