document

package
v0.0.0-...-8f845b4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	DocumentName string          `json:"documentName"`
	Matches      []*PatternMatch `json:"matches"`
}

A Document represents an instance of a text document and a series of pattern matches for a specified search term.

func NewDocument

func NewDocument(documentName string) *Document

NewDocument creates a new document with a document name and blank matches

func (*Document) HasMatchIndex

func (doc *Document) HasMatchIndex(indexToFind int) bool

HasMatchIndex returns true/false if this document has a match captured at this location/index in the text document

type DocumentIndex

type DocumentIndex map[string]*Document

A DocumentIndex represents a matched pattern text in a single document. This is used during the document scanning process.

type FileIndexMatch

type FileIndexMatch struct {
	Captures []string
	Key      string
	Location int
	Match    string
}

A FileIndexMatch is used when scanning a file for text patterns

type PatternMatch

type PatternMatch struct {
	Captures []string `json:"captures"`
	Location int      `json:"location"`
	Match    string   `json:"match"`
}

A PatternMatch is the information about a particlar match in a document. This includes the starting location/index of the match, the contents of the match, and all regex capture groups.

type PhysicalFile

type PhysicalFile struct {
	Contents string `json:"contents"`
	FileName string `json:"fileName"`
	// contains filtered or unexported fields
}

A PhysicalFile represents a file on a file system. This structure provides methods to read a file and perform an pattern match scan on it.

func NewPhysicalFile

func NewPhysicalFile(fileName string, textPatterns []*config.TextPattern) *PhysicalFile

NewPhysicalFile creates a new PhysicalFile structure. It takes a file name and a set of regular expressions to run against it.

func (*PhysicalFile) CreateIndex

func (file *PhysicalFile) CreateIndex() DocumentIndex

CreateIndex creates an index of matched patterns, each with a set of documents attached to them.

func (*PhysicalFile) Read

func (file *PhysicalFile) Read() (string, error)

Read reads the actual contents of a file and puts them into the Contents key

func (*PhysicalFile) String

func (file *PhysicalFile) String() string

String returns the file name

type Term

type Term struct {
	Key       string      `json:"key"`
	Documents []*Document `json:"documents"`
}

Term is a structure that represents an instance of a matched pattern in one or more text documents. This is used as the value of tree nodes, and is what is returned to callers when searching for terms.

func NewTerm

func NewTerm(key string) *Term

NewTerm creates a new Term instance with a key name and blank slice of documents.

func (*Term) Compare

func (term *Term) Compare(compareToTerm *Term) int

Compare returns 0, 1, or -1 if the second instance of Term is the same as, greater than, or less than the first instance.

func (*Term) Equal

func (term *Term) Equal(compareToTerm *Term) bool

Equal returns true/false if two Term keys are the same.

func (*Term) ToJSON

func (term *Term) ToJSON() string

ToJSON returns a string of pretty-print JSON representing this term.

Jump to

Keyboard shortcuts

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