miner

package
v0.0.0-...-fff90db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommentsFactory

func NewCommentsFactory() entity.MinerFactory

NewCommentsFactory creates a new comments miner factory.

func NewDeclarationsFactory

func NewDeclarationsFactory() entity.MinerFactory

NewDeclarationsFactory creates a new declarations miner factory.

func NewGlobalFreqTableFactory

func NewGlobalFreqTableFactory() entity.MinerFactory

NewGlobalFreqTableFactory creates a new declarations miner factory.

func NewMinerFactory

func NewMinerFactory() entity.MinerAbstractFactory

NewMinerFactory creates a new entity.MinerAbstractFactory, including the available miner factories. It supports:

  • "comments"
  • "declarations"
  • "global-frequency-table"
  • "scoped-declarations"
  • "wordcount"

func NewScopesFactory

func NewScopesFactory() entity.MinerFactory

NewScopesFactory creates a new scopes miner factory.

func NewWordcountFactory

func NewWordcountFactory() entity.MinerFactory

NewWordcountFactory creates a new wordcount miner factory.

Types

type Comments

type Comments struct {
	// contains filtered or unexported fields
}

Comments handles the comments mining process.

func NewComments

func NewComments() *Comments

NewComments creates a new Comments miner.

func (Comments) Name

func (m Comments) Name() string

Name return the name of the miner.

func (*Comments) Results

func (c *Comments) Results() interface{}

Results returns the list of comments found.

func (*Comments) SetCurrentFile

func (c *Comments) SetCurrentFile(filename string)

SetCurrentFile specifies the current file being mined.

func (*Comments) Visit

func (c *Comments) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface and handles the logic for the data extraction.

type Decl

type Decl struct {
	ID       string
	DeclType token.Token
	Words    map[string]struct{}
	Phrases  map[string]struct{}
}

Decl contains the mined text (words and phrases) related to a declaration.

type Declaration

type Declaration struct {
	Filename    string
	Dict        lists.List
	PackageName string
	Comments    []*ast.CommentGroup
	Included    []ast.Decl
	Decls       map[string]Decl
	// contains filtered or unexported fields
}

Declaration represents the declarations miner, which extracts information about words and phrases for each function/variable/struct/interface declaration.

func NewDeclaration

func NewDeclaration(dict lists.List) *Declaration

NewDeclaration initializes a new declarations miner.

func (Declaration) Name

func (m Declaration) Name() string

Name return the name of the miner.

func (Declaration) Results

func (m Declaration) Results() interface{}

Results returns a map of declaration IDs and the mined text for each declaration.

func (*Declaration) SetCurrentFile

func (m *Declaration) SetCurrentFile(filename string)

SetCurrentFile specifies the current file being mined.

func (*Declaration) Visit

func (m *Declaration) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface and handles the logic for the data extraction.

type GlobalFreqTable

type GlobalFreqTable struct {
	// contains filtered or unexported fields
}

GlobalFreqTable represents a Global Frequency Table miner.

func NewGlobalFreqTable

func NewGlobalFreqTable(ft *samurai.FrequencyTable) GlobalFreqTable

NewGlobalFreqTable creates a new GlobalFreqTable miner with the provided frequency table.

func (GlobalFreqTable) Name

func (m GlobalFreqTable) Name() string

Name return the name of the miner.

func (GlobalFreqTable) Results

func (g GlobalFreqTable) Results() interface{}

Results returns the global *samurai.FrequencyTable after the mining process.

func (GlobalFreqTable) SetCurrentFile

func (g GlobalFreqTable) SetCurrentFile(filename string)

SetCurrentFile changes the current file on the miner using the provided filename.

func (GlobalFreqTable) Visit

func (g GlobalFreqTable) Visit(node ast.Node) ast.Visitor

Visit traverses a ast.Node for mining.

type Scope

type Scope struct {
	Filename        string
	PackageName     string
	PackageComments []string
	Comments        []*ast.CommentGroup
	Included        []ast.Decl
	Scopes          map[string]ScopedDecl
	// contains filtered or unexported fields
}

Scope represents a scopes miner, which extracts information about the scope for each function/variable/struct/interface declaration.

func NewScope

func NewScope() *Scope

NewScope initializes a new scopes miner.

func (Scope) Name

func (m Scope) Name() string

Name return the name of the miner.

func (Scope) Results

func (m Scope) Results() interface{}

Results returns a map of IDs and the mined scope for each declaration.

func (*Scope) SetCurrentFile

func (m *Scope) SetCurrentFile(filename string)

SetCurrentFile specifies the current file being mined.

func (*Scope) Visit

func (m *Scope) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface and handles the logic for the data extraction.

type ScopedDecl

type ScopedDecl struct {
	ID              string
	DeclType        token.Token
	Name            string
	VariableDecls   []string
	Statements      []string
	BodyText        []string
	Comments        []string
	PackageComments []string
}

ScopedDecl represents the related scope for a declaration.

type WordCount

type WordCount struct {
	// contains filtered or unexported fields
}

WordCount handles the word count mining process.

func NewWordCount

func NewWordCount() WordCount

NewWordCount creates a new Count miner.

func (WordCount) Name

func (m WordCount) Name() string

Name return the name of the miner.

func (WordCount) Results

func (m WordCount) Results() interface{}

Results returns the word count.

func (WordCount) SetCurrentFile

func (m WordCount) SetCurrentFile(filename string)

SetCurrentFile specifies the current file being mined.

func (WordCount) Visit

func (m WordCount) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface and handles the logic for the data extraction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL