Documentation ¶
Index ¶
- func ItemType(s string) itemType
- type CFG
- type Element
- type Grammar
- type Interpreter
- type Item
- type Items
- func (is *Items) Add(i *Item)
- func (is Items) Empty() bool
- func (is *Items) FixMissingVariable() bool
- func (is Items) Get(typ itemType) set.Set
- func (is Items) LastType() itemType
- func (is Items) Len() int
- func (is Items) String() string
- func (is *Items) TrimKnownItems()
- func (is *Items) TrimRangeItems()
- func (is *Items) TrimUnknownItems()
- type Lexer
- type List
- type Node
- func (n *Node) Contains(m *Node) bool
- func (n *Node) EvalBound() (*relation.Limit, bool)
- func (n *Node) EvalNums() []string
- func (n *Node) EvalRange() *relation.Limit
- func (n *Node) EvalRelation() (*relation.Relation, error)
- func (n *Node) EvalRelations() (relation.Relations, relation.Relations)
- func (n *Node) EvalUnit() string
- func (n *Node) EvalVariable() string
- func (n *Node) Size() int
- func (n *Node) String() string
- type Parser
- type Pos
- type RuleType
- type Rules
- type Token
- type Tokens
- type Tree
- type Trees
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CFG ¶
type CFG struct {
// contains filtered or unexported fields
}
CFG defines the Context-Free Grammar, which is specified by its production rules. It implements the Grammar interface.
func NewCFGrammar ¶
NewCFGrammar creates a new Context-Free Grammar. It loads the production rules from s.
func (*CFG) BuildTrees ¶
BuildTrees computes the parse trees from the input items using the Lange-Leiss implementation of the CYK algorithm. The grammar is assumed to be in the binary normal form. Lange and Leiss, "To CNF or not to CNF? An Efficient Yet Presentable Version of the CYK Algorithm", Informatica Didactica 8 (2009).
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element defines the element of the CYK state table.
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
Interpreter defines the interpreter struct to convert unstructured criteria strings to structured relations.
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Item defines the lexical item that is syntactically constructed from the lexer token.
type Items ¶
type Items []*Item
Items defines a slice of items.
func (*Items) FixMissingVariable ¶
FixMissingVariable adds missing variable to the items, if it can be inferred from the unit.
func (*Items) TrimKnownItems ¶
func (is *Items) TrimKnownItems()
TrimKnownItems merges consecutive variable, unit, and comparison items with the same name to one.
func (*Items) TrimRangeItems ¶
func (is *Items) TrimRangeItems()
TrimRangeItems removes a range item if it precedes a comparison item.
func (*Items) TrimUnknownItems ¶
func (is *Items) TrimUnknownItems()
TrimUnknownItems merges consecutive unknown items to one, removes the first item if it is an unknown item, and removes unknown items that precede or follow a variable or unit item.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer defines the struct that converts a string to tokens. Rob Pike's presentation has been a great inspiration for this design. https://www.youtube.com/watch?v=HxaD_trXwRE
type List ¶
type List []Items
List defines a slice of items.
func (List) FixMissingVariable ¶
func (l List) FixMissingVariable()
FixMissingVariable adds missing variables to the list of items, if they can be inferred from the unit info.
func (List) Sort ¶
func (l List) Sort()
Sort sorts the list elements by their length in descending order.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node defines a node in the parse tree, which is constructed by applying grammar production rules to the parsed items.
func (*Node) EvalNums ¶
EvalNums evaluates and returns the list of numbers stored in the terminal leafs.
func (*Node) EvalRange ¶
EvalRange evaluates and returns the lower or upper bound of the range condition.
func (*Node) EvalRelation ¶
EvalRelation evaluates and returns the relation stored in the parse node based on the production rules.
func (*Node) EvalRelations ¶
EvalRelations evaluates and returns the 'or' and 'and' relations stored in the parse node.
func (*Node) EvalVariable ¶
EvalVariable evaluates and returns the variable name stored in the terminal leaf.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser defines the parser logic for parsing clinical trial eligibility criteria.
type RuleType ¶
type RuleType int
RuleType defines the type of rules that are being loaded from the string.
type Rules ¶
type Rules struct {
// contains filtered or unexported fields
}
Rules define the grammar production rules.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token defines a token or text string that is returned from the lexer.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree defines the parse tree.
func (*Tree) Contains ¶
Contains returns true if the tree t contains the tree v as a sub-tree or they are same.
type Trees ¶
type Trees []*Tree
Trees defines a slice of parse trees.
func (*Trees) Dedupe ¶
func (ts *Trees) Dedupe()
Dedupe deduplicates trees by removing exact duplicates and stumps that are contained by other trees.