tree

package
v0.0.0-...-ab00388 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFiletype = 7

	TypeOther    = 0
	TypeSource   = 1
	TypeBuild    = 2
	TypeConfig   = 3
	TypeStatic   = 4
	TypeDocument = 5
	TypeImage    = 6
)
View Source
const INF = 10000000
View Source
const MaxV = 50000

Maximum number of network nodes

View Source
const SIGINIGICANT_DIGITS = 100000

Variables

View Source
var (
	GoSourceRegex         = regexp.MustCompile(`.*\.go$`)
	JsSourceRegex         = regexp.MustCompile(`.*\.(js|jsx|_js|bones|cjs|es|es6|frag|gs|jake|jsb|jscad|jsfl|jsm|jss|mjs|njs|pac|sjs|ssjs|xsjs|xsjslib|js\.erb|vue|)$`)
	PythonSourceRegex     = regexp.MustCompile(`.*\.(py|pyx|pxd|pxi|numpy|numpyw|numsc|bzl|cgi|fcgi|gyp|gypi|lmi|py3|pyde|pyi|pyp|pyt|pyw|rpy|smk|spec|tac|wsgi|xpy|pytb|sage|sagews)$`)
	JavaSourceRegex       = regexp.MustCompile(`.*\.(java|properties|jsp)$`)
	PhpSourceRegex        = regexp.MustCompile(`.*\.(php|hack|hh|hhi|aw|ctp|fcgi|inc|php3|php4|php5|phps|php_cs|php_cs\.dist|zig)$`)
	CsharpSourceRegex     = regexp.MustCompile(`.*\.(cs|cake|csx)$`)
	CppSourceRegex        = regexp.MustCompile(`.*\.(cpp|c\+\+|cc|cp|cxx|h|h\+\+|hh|hpp|hxx|inc|inl|ino|ipp|re|tcc|tpp)$`)
	TypescriptSourceRegex = regexp.MustCompile(`.*\.(ts|tsx)$`)
	ShellSourceRegex      = regexp.MustCompile(`(.*\.(sh|ebuild|eclass|ps1|psd1|psm1|bash|bats|cgi|command|fcgi|ksh|sh\.in|tmux|tool|zsh|tcsh|csh|fish)$)|(^(\.(bash_aliases|bash_history|bash_logout|bash_profile|bashrc|cshrc|login|profile|zlogin|zlogout|zprofile|zshenv|zshrc)|9fs|PKGBUILD|bash_aliases|bash_logout|bash_profile|bashrc|cshrc|gradlew|login|man|profile|zlogin|zlogout|zprofile|zshenv|zshrc)$)`)
	CSourceRegex          = regexp.MustCompile(`.*\.(c|cats|h|idc)$`)
	RubySourceRegex       = regexp.MustCompile(`(.*\.(rb|builder|eye|fcgi|gemspec|god|jbuilder|mspec|pluginspec|podspec|rabl|rake|rbi|rbuild|rbw|rbx|ru|ruby|spec|thor|watchr)$)|(^(\.irbrc|\.pryrc|Appraisals|Berksfile|Brewfile|Buildfile|Capfile|Dangerfile|Deliverfile|Fastfile|Gemfile|Gemfile\.lock|Guardfile|Jarfile|Mavenfile|Podfile|Puppetfile|Rakefile|Snapfile|Thorfile|Vagrantfile|buildfile)$)`)

	BuildfileRegex  = regexp.MustCompile(`(.*\.(mak|d|make|mk|mkfile|dockerfile)$)|(^(Makefile|BSDmakefile|GNUmakefile|Kbuild|Makefile\.am|Makefile\.boot|Makefile\.frag|Makefile\.in|Makefile\.inc|Makefile\.wat|makefile|makefile\.sco|mkfile|Dockerfile)$)`)
	ConfigfileRegex = regexp.MustCompile(`.*\.(env|cfg)$`)
	StaticfileRegex = regexp.MustCompile(`.*\.(html|htm|html\.hl|inc|st|xht|xhtml|jinja|jinja2|mustache|njk|ecr|eex|erb|erb\.deface|phtml|cshtml|razor|haml|haml\.deface|handlebars|hbs|kit|latte|liquid|mtml|marko|jade|pug|rhtml|scaml|slim|svelte|twig|css|less|mss|pcss|postcss|sass|styl|sss|scss)$`)
	DocumentsRegex  = regexp.MustCompile(`.*\.(md|markdown|mdown|mdwn|mdx|mkd|mkdn|mkdown|ronn|wrokbook|rmd|txt)$`)
)

see https://github.com/github/linguist/blob/master/lib/linguist/languages.yml

Functions

func AlignmentDistance

func AlignmentDistance(sNodes, tNodes []*Node) (sum float64, err error)

func FileClassifier

func FileClassifier(filePath, language string) (int, error)

func MinCostFlow

func MinCostFlow(g *Graph, s int, t int, inif int) int

func NodeDataDiff

func NodeDataDiff(sNode *Node, tNode *Node) (res float64)

func OutputAbstractRepository

func OutputAbstractRepository(nodes []*Node, outPath string, thr float64) error

func SwapNodeSlice

func SwapNodeSlice(sNodes, tNodes []*Node) ([]*Node, []*Node)

Types

type Edge

type Edge struct {
	Rev  int
	From int
	To   int
	Cap  int
	ICap int
	Cost int
}

type Graph

type Graph struct {
	NodeNum int
	Nodes   [MaxV]McfNode
}

func (*Graph) AddEdge

func (g *Graph) AddEdge(from, to, cap, cost int)

func (*Graph) ReEdge

func (g *Graph) ReEdge(e *Edge) *Edge

type McfNode

type McfNode struct {
	Edges []Edge
}

type Node

type Node struct {
	Vector        [MaxFiletype]float64 `json:"data"`
	DirectoryName string               `json:"directory_name"`
	ChildNodes    []*Node              `json:"child_nodes"`
}

func MakeNode

func MakeNode(dirPath string, dirName string, depth, maxDepth int, language string) (*Node, error)

type NodeInfo

type NodeInfo struct {
	RootNode       *Node  `json:"root_node"`
	RepositoryName string `json:"repository_name"`
	Language       string `json:"language"`
	CreatedDate    string `json:"created_date"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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