Module Expr Str ImportFrom alias alias alias ImportFrom alias alias Import alias Import alias TryExcept body Import alias handlers ExceptHandler type NameLoad body Expr Call NameLoad Str Expr Call NameLoad Str Import alias ClassDef bases NameLoad body Expr Str Pass decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad TryExcept body Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return NameLoad While NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad TryExcept body Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return NameLoad While BoolOpAnd NameLoad CompareEq Call NameLoad NameLoad Num body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return ListLoad Return ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore SubscriptLoad NameLoad Slice Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return ListLoad Return ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore SubscriptLoad NameLoad Slice Num Call NameLoad GeneratorExp CompareEq NameLoad Num comprehension NameStore NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return ListLoad Return ListComp SubscriptLoad NameLoad Index SubscriptLoad NameLoad Slice NameLoad comprehension NameStore Call NameLoad Num BinOpAdd Call NameLoad NameLoad Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad Assign NameStore NameLoad While BoolOpAnd NameLoad Call NameLoad NameLoad CompareEq Call NameLoad NameLoad Num body Assign NameStore SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return ListLoad Return ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore Call AttributeLoad NameLoad attr CompareLt SubscriptLoad NameLoad Slice Call NameLoad NameLoad SubscriptLoad NameLoad Slice Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return ListLoad Assign NameStore BinOpSub Call NameLoad NameLoad Num While BoolOpAnd CompareLtE Num NameLoad CompareEq SubscriptLoad NameLoad Index NameLoad Num body AugAssignSub NameStore Num If CompareLt NameLoad Num body Return ListLoad Assign NameStore Call NameLoad SubscriptLoad NameLoad Slice BinOpAdd NameLoad Num AugAssignSub SubscriptStore NameLoad Index Num Num Assign NameStore SubscriptLoad NameLoad Index NameLoad Return BinOpAdd ListLoad NameLoad Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return ListLoad Return ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore Call AttributeLoad NameLoad attr CompareGt SubscriptLoad NameLoad Slice Call NameLoad NameLoad SubscriptLoad NameLoad Slice Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return ListLoad Assign NameStore BinOpSub Call NameLoad NameLoad Num While BoolOpAnd CompareLtE Num NameLoad CompareEq SubscriptLoad NameLoad Index NameLoad BinOpSub Call NameLoad NameLoad Num body AugAssignSub NameStore Num Assign NameStore Call AttributeLoad NameLoad attr If CompareLt NameLoad Num body Return ListLoad Assign NameStore Call NameLoad SubscriptLoad NameLoad Slice BinOpAdd NameLoad Num AugAssignAdd SubscriptStore NameLoad Index Num Num Assign NameStore SubscriptLoad NameLoad Index NameLoad Return BinOpAdd ListLoad NameLoad Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return IfExp Call NameLoad NameLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assert CompareEq Call NameLoad NameLoad Num Assert CompareEq SubscriptLoad SubscriptLoad NameLoad Index Num Index Num Str Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Num Slice Num FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body If BoolOpOr CompareIs NameLoad NameLoad CompareNotIn NameLoad NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Return Call SubscriptLoad NameLoad Index NameLoad NameLoad NameLoad NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If CompareEq SubscriptLoad NameLoad Index Num Str body Assign NameStore SubscriptLoad NameLoad Slice Num If CompareGt Call NameLoad NameLoad Num body Assert CompareEq Call NameLoad Call NameLoad SubscriptLoad NameLoad Slice Num Num ListLoad Str Assign NameStore ListComp Call NameLoad NameLoad NameLoad ListLoad NameLoad comprehension NameStore SubscriptLoad NameLoad Slice Num Return Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore NameLoad NameLoad orelse If Call NameLoad SubscriptLoad NameLoad Index Num Str body Return SubscriptLoad NameLoad Index Num orelse If BoolOpOr CompareEq SubscriptLoad NameLoad Index Num Str CompareEq SubscriptLoad NameLoad Index Num Str body Return Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad orelse If Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str body Assert Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str Assign NameStore Call AttributeLoad Call AttributeLoad SubscriptLoad SubscriptLoad NameLoad Index Num Slice Num Num attr Str Str attr Str Str Return Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad CompareEq Call NameLoad NameLoad NameLoad NameLoad orelse If Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str body Assert Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Num Slice Num Num Return Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad Call AttributeLoad NameLoad attr NameLoad orelse If Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str body Assign NameStore Call NameLoad NameLoad NameLoad ListLoad Call AttributeLoad SubscriptLoad SubscriptLoad NameLoad Index Num Slice Num attr Return Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad Call AttributeLoad Call NameLoad NameLoad attr NameLoad orelse Return Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad CompareEq Call NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assert CompareEq Call NameLoad NameLoad Num Assert CompareEq SubscriptLoad NameLoad Index Num Str Assert CompareEq SubscriptLoad NameLoad Index Num Str Return SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad GeneratorExp Call NameLoad NameLoad comprehension NameStore NameLoad Call AttributeLoad NameLoad attr Return Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str CompareEq Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore NameLoad If CompareEq SubscriptLoad NameLoad Index Num Str body Assign NameStore NameLoad Assign NameStore SubscriptLoad NameLoad Slice Num If CompareEq SubscriptLoad NameLoad Index Num Str body Assert CompareEq Call NameLoad NameLoad Num Assert CompareEq SubscriptLoad NameLoad Index Num Str Assign NameStore SubscriptLoad NameLoad Index Num orelse Assert CompareEq Call NameLoad NameLoad Num Assign TupleStore NameStore NameStore NameLoad If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad Call NameLoad SubscriptLoad NameLoad Index Num NameLoad NameLoad orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr CompareIs NameLoad SubscriptLoad Call AttributeLoad NameLoad attr Index Num Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If BoolOpAnd CompareEq SubscriptLoad NameLoad Index Num Str Call AttributeLoad SubscriptLoad NameLoad Slice Num attr body Assign NameStore Call NameLoad SubscriptLoad NameLoad Slice Num Assign NameStore Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad CompareLtELt Num NameLoad Call NameLoad NameLoad Call NameLoad SubscriptLoad NameLoad Index NameLoad NameLoad NameLoad BinOpSub NameLoad Num orelse If BoolOpAnd CompareEq SubscriptLoad NameLoad Index Num Str Call AttributeLoad SubscriptLoad NameLoad Slice Num attr body Assign NameStore Call NameLoad SubscriptLoad NameLoad Slice Num Assign NameStore Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr CompareLtELt Num NameLoad Call NameLoad Call AttributeLoad NameLoad attr CompareIs NameLoad SubscriptLoad Call AttributeLoad NameLoad attr Index NameLoad Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad BinOpSub NameLoad Num orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad Call NameLoad SubscriptLoad NameLoad Index Num NameLoad NameLoad orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr CompareIs NameLoad SubscriptLoad Call AttributeLoad NameLoad attr Index Num Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If BoolOpAnd CompareEq SubscriptLoad NameLoad Slice Num Str Call AttributeLoad SubscriptLoad NameLoad Slice Num attr body Assign NameStore UnaryOpUSub Call NameLoad SubscriptLoad NameLoad Slice Num Assign NameStore Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad CompareLtELt Num BinOpAdd NameLoad Call NameLoad NameLoad Call NameLoad NameLoad Call NameLoad SubscriptLoad NameLoad Index BinOpAdd NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad orelse If BoolOpAnd CompareEq SubscriptLoad NameLoad Slice Num Str Call AttributeLoad SubscriptLoad NameLoad Slice Num attr body Assign NameStore UnaryOpUSub Call NameLoad SubscriptLoad NameLoad Slice Num Assign NameStore Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr CompareLtELt Num BinOpAdd NameLoad Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr CompareIs NameLoad SubscriptLoad Call AttributeLoad NameLoad attr Index BinOpAdd NameLoad Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad CompareEq Call NameLoad NameLoad Num Call NameLoad SubscriptLoad NameLoad Index Num NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr CompareEq Call NameLoad Call AttributeLoad NameLoad attr Num Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp BoolOpAnd Call NameLoad NameLoad NameLoad NameLoad CompareIn NameLoad Call NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp BoolOpAnd Call NameLoad NameLoad NameLoad NameLoad CompareIn NameLoad Call NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call NameLoad NameLoad orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore Call AttributeLoad NameLoad attr CompareIsNot NameLoad NameLoad orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore SubscriptLoad Call AttributeLoad NameLoad attr Slice BinOpAdd Call AttributeLoad NameLoad attr Num orelse If BoolOpOr CompareEq NameLoad Str CompareEq NameLoad Str body Assign NameStore Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpAnd Call NameLoad NameLoad Str Call NameLoad NameLoad Str Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore SubscriptLoad Call AttributeLoad NameLoad attr Slice Call AttributeLoad NameLoad attr orelse Raise Call NameLoad Call AttributeLoad Str attr NameLoad If NameLoad body Return Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad UnaryOpNot Call NameLoad NameLoad NameLoad NameLoad NameLoad orelse Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str body Expr Str Assign NameStore ListComp NameLoad comprehension NameStore NameLoad CompareNotEq NameLoad NameLoad If CompareEq Call NameLoad NameLoad Num body Return SubscriptLoad NameLoad Index Num orelse Return Call Lambda arguments args NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Slice Num FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If BoolOpOr CompareIs NameLoad NameLoad CompareNotIn NameLoad NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign NameStore SubscriptLoad NameLoad Index NameLoad Return Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assert CompareEq Call NameLoad NameLoad Num Assert Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str Return SubscriptLoad SubscriptLoad NameLoad Index Num Slice Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assert CompareEq Call NameLoad NameLoad Num Assert Call AttributeLoad SubscriptLoad NameLoad Index Num attr Str Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Num Slice Num FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body If BoolOpOr CompareIs NameLoad NameLoad CompareNotIn NameLoad NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign NameStore SubscriptLoad NameLoad Index NameLoad Return CompareIs NameLoad NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If CompareEq Call NameLoad NameLoad Num body Return SubscriptLoad NameLoad Index Num orelse Assert CompareEq Call NameLoad NameLoad Num Assert CompareEq SubscriptLoad NameLoad Index Num Str Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Index Num FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body If Call NameLoad NameLoad NameLoad NameLoad body If CompareIs NameLoad NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad Return NameLoad orelse Return NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore ListComp NameLoad comprehension NameStore NameLoad CompareNotEq NameLoad Str If CompareEq Call NameLoad NameLoad Num body Return SubscriptLoad NameLoad Index Num orelse If CompareEq Call NameLoad NameLoad Num body Return Call Lambda arguments args NameParam NameParam defaults Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad BoolOpOr Call NameLoad NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assert CompareEq Call NameLoad NameLoad Num Assert CompareEq SubscriptLoad NameLoad Index Num Str Return Dict SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If CompareEq Call NameLoad NameLoad Num body Return Lambda arguments args NameParam NameParam NameParam defaults NameLoad NameLoad Call SubscriptLoad NameLoad Index Num NameLoad NameLoad Dict Assign NameStore ListComp NameLoad comprehension NameStore NameLoad CompareNotEq NameLoad Str Assign NameStore Dict Assign NameStore ListComp NameLoad comprehension NameStore NameLoad Call NameLoad NameLoad NameLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore ListComp NameLoad comprehension NameStore NameLoad UnaryOpNot Call NameLoad NameLoad NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Assign NameStore Dict Return Call NameLoad GeneratorExp Call NameLoad NameLoad NameLoad NameLoad comprehension NameStore NameLoad decorator_list Return NameLoad decorator_list FunctionDef arguments args NameParam defaults NameLoad body Expr Str Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr keyword Str keyword Str keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword Str keyword Str keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore BinOpAdd BinOpAdd Call AttributeLoad NameLoad attr Str NameLoad Str Assign NameStore BinOpAdd BinOpAdd Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr BinOpAdd Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword Str Call AttributeLoad NameLoad attr Str Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad Assign NameStore BinOpBitOr BinOpBitOr BinOpBitOr BinOpBitOr BinOpBitOr BinOpBitOr BinOpBitOr BinOpBitOr NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Str NameLoad Assign NameStore BinOpBitOr BinOpAdd BinOpAdd NameLoad Call AttributeLoad Call AttributeLoad NameLoad attr Str attr Str Call AttributeLoad Call AttributeLoad NameLoad attr attr Str NameLoad Assign NameStore BinOpBitOr NameLoad BinOpAdd BinOpAdd Call AttributeLoad NameLoad attr Str NameLoad Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd Call AttributeLoad NameLoad attr Str Str NameLoad Str Assign NameStore BinOpBitOr NameLoad BinOpAdd NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Expr BinOpLShift NameLoad BinOpAdd NameLoad Call AttributeLoad NameLoad attr BinOpAdd Call AttributeLoad NameLoad attr Str NameLoad Expr BinOpLShift NameLoad BinOpAdd NameLoad Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad Expr BinOpLShift NameLoad BinOpAdd NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd NameLoad Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd Call AttributeLoad NameLoad attr Str Call AttributeLoad Call AttributeLoad NameLoad attr attr NameLoad NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd NameLoad Call AttributeLoad NameLoad attr BinOpAdd Str NameLoad Str NameLoad Call AttributeLoad NameLoad attr BinOpAdd Str BinOpBitOr NameLoad NameLoad Call AttributeLoad Call AttributeLoad NameLoad attr Str attr If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad keyword Str Expr Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr BinOpAdd Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Return Call NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Return SubscriptLoad Call NameLoad Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Index Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad For NameStore NameLoad body For NameStore Call NameLoad Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice NameLoad Return ListComp NameLoad comprehension NameStore NameLoad CompareIn NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad For NameStore NameLoad body TryExcept body If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr orelse Assign NameStore Call NameLoad NameLoad Expr Yield ListComp NameLoad comprehension NameStore NameLoad Call NameLoad SubscriptLoad NameLoad Index NameLoad handlers ExceptHandler type NameLoad body Expr Yield ListLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If Call NameLoad NameLoad TupleLoad NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad For NameStore NameLoad body TryExcept body If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr orelse Assign NameStore Call NameLoad NameLoad Expr Yield ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore NameLoad Call NameLoad SubscriptLoad NameLoad Index NameLoad handlers ExceptHandler type NameLoad body Expr Yield ListLoad decorator_list
N/A N/A 
============================================
 TGrep search implementation for NLTK trees
============================================

This module supports TGrep2 syntax for matching parts of NLTK Trees.
Note that many tgrep operators require the tree passed to be a
``ParentedTree``.

External links:

- `Tgrep tutorial <http://www.stanford.edu/dept/linguistics/corpora/cas-tut-tgrep.html>`_
- `Tgrep2 manual <http://tedlab.mit.edu/~dr/Tgrep2/tgrep2.pdf>`_
- `Tgrep2 source <http://tedlab.mit.edu/~dr/Tgrep2/>`_

Usage
=====

>>> from nltk.tree import ParentedTree
>>> from nltk.tgrep import tgrep_nodes, tgrep_positions
>>> tree = ParentedTree.fromstring('(S (NP (DT the) (JJ big) (NN dog)) (VP bit) (NP (DT a) (NN cat)))')
>>> list(tgrep_nodes('NN', [tree]))
[[ParentedTree('NN', ['dog']), ParentedTree('NN', ['cat'])]]
>>> list(tgrep_positions('NN', [tree]))
[[(0, 2), (2, 1)]]
>>> list(tgrep_nodes('DT', [tree]))
[[ParentedTree('DT', ['the']), ParentedTree('DT', ['a'])]]
>>> list(tgrep_nodes('DT $ JJ', [tree]))
[[ParentedTree('DT', ['the'])]]

This implementation adds syntax to select nodes based on their NLTK
tree position.  This syntax is ``N`` plus a Python tuple representing
the tree position.  For instance, ``N()``, ``N(0,)``, ``N(0,0)`` are
valid node selectors.  Example:

>>> tree = ParentedTree.fromstring('(S (NP (DT the) (JJ big) (NN dog)) (VP bit) (NP (DT a) (NN cat)))')
>>> tree[0,0]
ParentedTree('DT', ['the'])
>>> tree[0,0].treeposition()
(0, 0)
>>> list(tgrep_nodes('N(0,0)', [tree]))
[[ParentedTree('DT', ['the'])]]

Caveats:
========

- Link modifiers: "?" and "=" are not implemented.
- Tgrep compatibility: Using "@" for "!", "{" for "<", "}" for ">" are
  not implemented.
- The "=" and "~" links are not implemented.

Known Issues:
=============

- There are some issues with link relations involving leaf nodes
  (which are represented as bare strings in NLTK trees).  For
  instance, consider the tree::

      (S (A x))

  The search string ``* !>> S`` should select all nodes which are not
  dominated in some way by an ``S`` node (i.e., all nodes which are
  not descendants of an ``S``).  Clearly, in this tree, the only node
  which fulfills this criterion is the top node (since it is not
  dominated by anything).  However, the code here will find both the
  top node and the leaf node ``x``.  This is because we cannot recover
  the parent of the leaf, since it is stored as a bare string.

  A possible workaround, when performing this kind of search, would be
  to filter out all leaf nodes.

Implementation notes
====================

This implementation is (somewhat awkwardly) based on lambda functions
which are predicates on a node.  A predicate is a function which is
either True or False; using a predicate function, we can identify sets
of nodes with particular properties.  A predicate function, could, for
instance, return True only if a particular node has a label matching a
particular regular expression, and has a daughter node which has no
sisters.  Because tgrep2 search strings can do things statefully (such
as substituting in macros, and binding nodes with node labels), the
actual predicate function is declared with three arguments::

    pred = lambda n, m, l: return True # some logic here

``n``
    is a node in a tree; this argument must always be given

``m``
    contains a dictionary, mapping macro names onto predicate functions

``l``
    is a dictionary to map node labels onto nodes in the tree

``m`` and ``l`` are declared to default to ``None``, and so need not be
specified in a call to a predicate.  Predicates which call other
predicates must always pass the value of these arguments on.  The
top-level predicate (constructed by ``_tgrep_exprs_action``) binds the
macro definitions to ``m`` and initialises ``l`` to an empty dictionary.
 __future__ absolute_import print_function unicode_literals nltk.compat binary_type text_type N/A functools N/A nltk.tree N/A N/A N/A pyparsing N/A N/A N/A ImportError N/A N/A N/A print Warning: nltk.tgrep will not work without the `pyparsing` package N/A N/A print installed. N/A re TgrepException N/A Exception N/A N/A Tgrep exception type. N/A N/A ancestors N/A N/A node N/A N/A N/A 
    Returns the list of all nodes dominating the given tree node.
    This method will not work with leaf nodes, since there is no way
    to recover the parent.
     N/A results N/A N/A N/A N/A current N/A N/A node parent N/A N/A N/A AttributeError N/A N/A results N/A current N/A N/A N/A N/A results append current N/A current N/A N/A current parent N/A results N/A unique_ancestors N/A N/A node N/A N/A N/A 
    Returns the list of all nodes dominating the given node, where
    there is only a single path of descent.
     N/A results N/A N/A N/A N/A current N/A N/A node parent N/A N/A N/A AttributeError N/A N/A results N/A N/A current N/A N/A len current 1 N/A N/A N/A N/A results append current N/A current N/A N/A current parent N/A results N/A _descendants N/A N/A node N/A N/A N/A 
    Returns the list of all nodes which are descended from the given
    tree node in some way.
     N/A N/A N/A treepos N/A N/A node treepositions N/A N/A N/A AttributeError N/A N/A N/A N/A N/A N/A node N/A x N/A x N/A treepos N/A 1 N/A _leftmost_descendants N/A N/A node N/A N/A N/A 
    Returns the set of all nodes descended in some way through
    left branches from this node.
     N/A N/A N/A treepos N/A N/A node treepositions N/A N/A N/A AttributeError N/A N/A N/A N/A N/A N/A node N/A x N/A x N/A treepos N/A 1 N/A all N/A N/A y 0 N/A y x N/A _rightmost_descendants N/A N/A node N/A N/A N/A 
    Returns the set of all nodes descended in some way through
    right branches from this node.
     N/A N/A N/A rightmost_leaf N/A max N/A N/A node treepositions N/A N/A N/A AttributeError N/A N/A N/A N/A N/A N/A node N/A N/A rightmost_leaf N/A i N/A i N/A range 1 N/A N/A len rightmost_leaf 1 N/A _istree N/A N/A obj N/A N/A N/A Predicate to check whether `obj` is a nltk.tree.Tree. N/A N/A isinstance obj N/A N/A nltk tree Tree N/A _unique_descendants N/A N/A node N/A N/A N/A 
    Returns the list of all nodes descended from the given node, where
    there is only a single path of descent.
     N/A results N/A N/A current node N/A N/A current N/A _istree current N/A N/A len current 1 N/A N/A current N/A current N/A 0 N/A N/A N/A results append current N/A results N/A _before N/A N/A node N/A N/A N/A 
    Returns the set of all nodes that are before the given node.
     N/A N/A N/A pos N/A N/A node treeposition N/A tree N/A N/A node root N/A N/A N/A AttributeError N/A N/A N/A N/A N/A N/A tree N/A x N/A x N/A N/A tree treepositions N/A N/A x N/A N/A len pos N/A pos N/A N/A len x N/A _immediately_before N/A N/A node N/A N/A N/A 
    Returns the set of all nodes that are immediately before the given
    node.

    Tree node A immediately precedes node B if the last terminal
    symbol (word) produced by A immediately precedes the first
    terminal symbol produced by B.
     N/A N/A N/A pos N/A N/A node treeposition N/A tree N/A N/A node root N/A N/A N/A AttributeError N/A N/A N/A N/A idx N/A N/A len pos 1 N/A N/A N/A 0 idx N/A N/A pos N/A idx 0 N/A N/A idx 1 N/A N/A idx 0 N/A N/A N/A N/A pos N/A list N/A pos N/A N/A idx 1 N/A N/A pos N/A -1 1 N/A before N/A tree N/A pos N/A N/A N/A before N/A _rightmost_descendants before N/A _after N/A N/A node N/A N/A N/A 
    Returns the set of all nodes that are after the given node.
     N/A N/A N/A pos N/A N/A node treeposition N/A tree N/A N/A node root N/A N/A N/A AttributeError N/A N/A N/A N/A N/A N/A tree N/A x N/A x N/A N/A tree treepositions N/A N/A x N/A N/A len pos N/A pos N/A N/A len x N/A _immediately_after N/A N/A node N/A N/A N/A 
    Returns the set of all nodes that are immediately after the given
    node.

    Tree node A immediately follows node B if the first terminal
    symbol (word) produced by A immediately follows the last
    terminal symbol produced by B.
     N/A N/A N/A pos N/A N/A node treeposition N/A tree N/A N/A node root N/A current N/A N/A node parent N/A N/A N/A AttributeError N/A N/A N/A N/A idx N/A N/A len pos 1 N/A N/A N/A 0 idx N/A N/A pos N/A idx N/A N/A len current 1 N/A N/A idx 1 N/A current N/A N/A current parent N/A N/A idx 0 N/A N/A N/A N/A pos N/A list N/A pos N/A N/A idx 1 N/A N/A pos N/A -1 1 N/A after N/A tree N/A pos N/A N/A N/A after N/A _leftmost_descendants after N/A _tgrep_node_literal_value N/A N/A node N/A N/A N/A 
    Gets the string value of a given parse tree node, for comparison
    using the tgrep node literal predicates.
     N/A N/A N/A _istree node N/A N/A node label N/A text_type node N/A _tgrep_macro_use_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function which looks up the macro name used.
     N/A N/A N/A len tokens 1 N/A N/A N/A N/A tokens N/A 0 N/A 0 @ N/A macro_name N/A N/A tokens N/A 0 N/A 1 macro_use N/A N/A n m l N/A None None N/A N/A N/A N/A m None N/A macro_name m N/A N/A N/A TgrepException N/A N/A macro {0} not defined format macro_name N/A N/A N/A m N/A macro_name n m l N/A N/A macro_use N/A _tgrep_node_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function representing a predicate on a tree node
    depending on the name of its node.
     N/A N/A N/A tokens N/A 0 ' N/A N/A tokens N/A tokens N/A 1 N/A N/A N/A len tokens 1 N/A N/A N/A N/A list N/A set N/A tokens N/A 1 2 N/A | N/A tokens N/A N/A _tgrep_node_action None None N/A node N/A node N/A tokens N/A 2 N/A N/A N/A N/A N/A t N/A N/A N/A N/A n m l N/A None None N/A any N/A N/A f n m l N/A f t tokens N/A N/A N/A hasattr N/A tokens N/A 0 __call__ N/A N/A N/A tokens N/A 0 N/A N/A N/A N/A N/A tokens N/A 0 * N/A N/A tokens N/A 0 __ N/A N/A N/A N/A N/A n m l N/A None None True N/A N/A N/A N/A N/A tokens N/A 0 startswith " N/A N/A N/A N/A N/A tokens N/A 0 endswith " N/A node_lit N/A N/A N/A N/A N/A N/A tokens N/A 0 N/A 1 -1 replace \" " replace \\ \ N/A N/A N/A N/A N/A s N/A N/A N/A N/A n m l N/A None None N/A N/A _tgrep_node_literal_value n s node_lit N/A N/A N/A N/A N/A tokens N/A 0 startswith / N/A N/A N/A N/A N/A tokens N/A 0 endswith / N/A node_lit N/A N/A tokens N/A 0 N/A 1 -1 N/A N/A N/A N/A N/A r N/A N/A N/A N/A n m l N/A None None N/A N/A r search N/A _tgrep_node_literal_value n N/A N/A re compile node_lit N/A N/A N/A N/A N/A tokens N/A 0 startswith i@ N/A N/A node_func N/A _tgrep_node_action _s _l N/A N/A N/A N/A N/A tokens N/A 0 N/A 2 lower N/A N/A N/A N/A N/A f N/A N/A N/A N/A n m l N/A None None N/A f N/A N/A N/A _tgrep_node_literal_value n lower node_func N/A N/A N/A N/A N/A N/A s N/A N/A N/A N/A n m l N/A None None N/A N/A _tgrep_node_literal_value n s N/A tokens N/A 0 N/A _tgrep_parens_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function representing a predicate on a tree node
    from a parenthetical notation.
     N/A N/A N/A len tokens 3 N/A N/A N/A tokens N/A 0 ( N/A N/A N/A tokens N/A 2 ) N/A N/A tokens N/A 1 N/A _tgrep_nltk_tree_pos_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function representing a predicate on a tree node
    which returns true if the node is located at a specific tree
    position.
     N/A node_tree_position N/A tuple N/A N/A int x N/A x tokens N/A N/A x isdigit N/A N/A N/A N/A N/A i N/A N/A N/A N/A n m l N/A None None N/A N/A hasattr n treeposition N/A N/A N/A n treeposition i node_tree_position N/A _tgrep_relation_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function representing a predicate on a tree node
    depending on its relation to other nodes in the tree.
     N/A negated False N/A N/A N/A tokens N/A 0 ! N/A N/A negated True N/A tokens N/A tokens N/A 1 N/A N/A N/A tokens N/A 0 [ N/A N/A N/A N/A len tokens 3 N/A N/A N/A tokens N/A 2 ] N/A retval N/A tokens N/A 1 N/A N/A N/A N/A len tokens 2 N/A N/A operator predicate tokens N/A N/A operator < N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A any N/A N/A predicate x m l N/A x n N/A N/A N/A operator > N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A bool N/A N/A n parent N/A predicate N/A N/A n parent m l N/A N/A N/A N/A operator <, N/A operator <1 N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A bool N/A list n N/A predicate N/A n N/A 0 m l N/A N/A N/A N/A operator >, N/A operator >1 N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A bool N/A N/A n parent N/A n N/A N/A N/A n parent N/A 0 N/A predicate N/A N/A n parent m l N/A N/A N/A N/A N/A operator N/A 0 < N/A N/A N/A operator N/A 1 isdigit N/A N/A idx N/A int N/A operator N/A 1 N/A retval N/A N/A N/A N/A i N/A N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A bool N/A list n N/A 0 i N/A len n N/A predicate N/A n N/A i m l N/A idx 1 N/A N/A N/A N/A N/A operator N/A 0 > N/A N/A N/A operator N/A 1 isdigit N/A N/A idx N/A int N/A operator N/A 1 N/A retval N/A N/A N/A N/A i N/A N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A bool N/A N/A n parent N/A 0 i N/A len N/A N/A n parent N/A n N/A N/A N/A n parent N/A i N/A predicate N/A N/A n parent m l N/A idx 1 N/A N/A N/A N/A operator <' N/A operator <- N/A operator <-1 N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A bool N/A list n N/A predicate N/A n N/A -1 m l N/A N/A N/A N/A operator >' N/A operator >- N/A operator >-1 N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A bool N/A N/A n parent N/A n N/A N/A N/A n parent N/A -1 N/A predicate N/A N/A n parent m l N/A N/A N/A N/A N/A operator N/A 2 <- N/A N/A N/A operator N/A 2 isdigit N/A N/A idx N/A N/A int N/A operator N/A 2 N/A retval N/A N/A N/A N/A i N/A N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A bool N/A list n N/A 0 N/A i N/A len n N/A len n N/A predicate N/A n N/A N/A i N/A len n m l idx N/A N/A N/A N/A N/A operator N/A 2 >- N/A N/A N/A operator N/A 2 isdigit N/A N/A idx N/A N/A int N/A operator N/A 2 N/A retval N/A N/A N/A N/A i N/A N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A bool N/A N/A n parent N/A 0 N/A i N/A len N/A N/A n parent N/A len N/A N/A n parent N/A n N/A N/A N/A n parent N/A N/A i N/A len N/A N/A n parent N/A predicate N/A N/A n parent m l idx N/A N/A N/A operator <: N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A N/A len n 1 N/A predicate N/A n N/A 0 m l N/A N/A N/A operator >: N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A bool N/A N/A n parent N/A N/A len N/A N/A n parent 1 N/A predicate N/A N/A n parent m l N/A N/A N/A operator << N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A any N/A N/A predicate x m l N/A x N/A _descendants n N/A N/A N/A operator >> N/A N/A retval N/A N/A N/A n m l N/A None None N/A any N/A N/A predicate x m l N/A x N/A ancestors n N/A N/A N/A N/A operator <<, N/A operator <<1 N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A any N/A N/A predicate x m l N/A x N/A _leftmost_descendants n N/A N/A N/A operator >>, N/A N/A retval N/A N/A N/A n m l N/A None None N/A any N/A N/A N/A predicate x m l N/A n N/A _leftmost_descendants x N/A x N/A ancestors n N/A N/A N/A operator <<' N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A any N/A N/A predicate x m l N/A x N/A _rightmost_descendants n N/A N/A N/A operator >>' N/A N/A retval N/A N/A N/A n m l N/A None None N/A any N/A N/A N/A predicate x m l N/A n N/A _rightmost_descendants x N/A x N/A ancestors n N/A N/A N/A operator <<: N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A _istree n N/A any N/A N/A predicate x m l N/A x N/A _unique_descendants n N/A N/A N/A operator >>: N/A N/A retval N/A N/A N/A n m l N/A None None N/A any N/A N/A predicate x m l N/A x N/A unique_ancestors n N/A N/A N/A operator . N/A N/A retval N/A N/A N/A n m l N/A None None N/A any N/A N/A predicate x m l N/A x N/A _immediately_after n N/A N/A N/A operator , N/A N/A retval N/A N/A N/A n m l N/A None None N/A any N/A N/A predicate x m l N/A x N/A _immediately_before n N/A N/A N/A operator .. N/A N/A retval N/A N/A N/A n m l N/A None None N/A any N/A N/A predicate x m l N/A x N/A _after n N/A N/A N/A operator ,, N/A N/A retval N/A N/A N/A n m l N/A None None N/A any N/A N/A predicate x m l N/A x N/A _before n N/A N/A N/A N/A operator $ N/A operator % N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A bool N/A N/A n parent N/A any N/A N/A predicate x m l N/A x N/A N/A n parent N/A x n N/A N/A N/A N/A operator $. N/A operator %. N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n right_sibling N/A bool N/A N/A n right_sibling N/A predicate N/A N/A n right_sibling m l N/A N/A N/A N/A operator $, N/A operator %, N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n left_sibling N/A bool N/A N/A n left_sibling N/A predicate N/A N/A n left_sibling m l N/A N/A N/A N/A operator $.. N/A operator %.. N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A hasattr n parent_index N/A bool N/A N/A n parent N/A any N/A N/A predicate x m l N/A x N/A N/A N/A n parent N/A N/A N/A N/A n parent_index 1 N/A N/A N/A N/A operator $,, N/A operator %,, N/A N/A retval N/A N/A N/A n m l N/A None None N/A N/A hasattr n parent N/A hasattr n parent_index N/A bool N/A N/A n parent N/A any N/A N/A predicate x m l N/A x N/A N/A N/A n parent N/A N/A N/A n parent_index N/A N/A N/A TgrepException N/A N/A cannot interpret tgrep operator "{0}" format operator N/A negated N/A N/A N/A N/A N/A N/A r N/A N/A N/A N/A n m l N/A None None N/A N/A r n m l retval N/A N/A retval N/A _tgrep_conjunction_action N/A N/A _s _l tokens join_char N/A & N/A N/A 
    Builds a lambda function representing a predicate on a tree node
    from the conjunction of several other such lambda functions.

    This is prototypically called for expressions like
    (`tgrep_rel_conjunction`)::

        < NP & < AP < VP

    where tokens is a list of predicates representing the relations
    (`< NP`, `< AP`, and `< VP`), possibly with the character `&`
    included (as in the example here).

    This is also called for expressions like (`tgrep_node_expr2`)::

        NP < NN
        S=s < /NP/=n : s < /VP/=v : n .. v

    tokens[0] is a tgrep_expr predicate; tokens[1:] are an (optional)
    list of segmented patterns (`tgrep_expr_labeled`, processed by
    `_tgrep_segmented_pattern_action`).
     N/A tokens N/A x N/A x tokens N/A x join_char N/A N/A N/A len tokens 1 N/A N/A N/A tokens N/A 0 N/A N/A N/A N/A N/A N/A ts N/A N/A N/A N/A n m l N/A None None N/A all N/A N/A predicate n m l N/A predicate ts tokens N/A _tgrep_segmented_pattern_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function representing a segmented pattern.

    Called for expressions like (`tgrep_expr_labeled`)::

        =s .. =v < =n

    This is a segmented pattern, a tgrep2 expression which begins with
    a node label.

    The problem is that for segemented_pattern_action (': =v < =s'),
    the first element (in this case, =v) is specifically selected by
    virtue of matching a particular node in the tree; to retrieve
    the node, we need the label, not a lambda function.  For node
    labels inside a tgrep_node_expr, we need a lambda function which
    returns true if the node visited is the same as =v.

    We solve this by creating two copies of a node_label_use in the
    grammar; the label use inside a tgrep_expr_labeled has a separate
    parse action to the pred use inside a node_expr.  See
    `_tgrep_node_label_use_action` and
    `_tgrep_node_label_pred_use_action`.
     N/A node_label N/A tokens N/A 0 N/A reln_preds N/A tokens N/A 1 pattern_segment_pred N/A N/A n m l N/A None None N/A N/A This predicate function ignores its node argument. N/A N/A N/A l None N/A node_label l N/A N/A N/A TgrepException N/A N/A node_label ={0} not bound in pattern format node_label N/A node N/A l N/A node_label N/A N/A all N/A N/A pred node m l N/A pred reln_preds N/A N/A pattern_segment_pred N/A _tgrep_node_label_use_action N/A N/A _s _l tokens N/A N/A N/A 
    Returns the node label used to begin a tgrep_expr_labeled.  See
    `_tgrep_segmented_pattern_action`.

    Called for expressions like (`tgrep_node_label_use`)::

        =s

    when they appear as the first element of a `tgrep_expr_labeled`
    expression (see `_tgrep_segmented_pattern_action`).

    It returns the node label.
     N/A N/A N/A len tokens 1 N/A N/A N/A N/A tokens N/A 0 startswith = N/A N/A N/A tokens N/A 0 N/A 1 N/A _tgrep_node_label_pred_use_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function representing a predicate on a tree node
    which describes the use of a previously bound node label.

    Called for expressions like (`tgrep_node_label_use_pred`)::

        =s

    when they appear inside a tgrep_node_expr (for example, inside a
    relation).  The predicate returns true if and only if its node
    argument is identical the the node looked up in the node label
    dictionary using the node's label.
     N/A N/A N/A len tokens 1 N/A N/A N/A N/A tokens N/A 0 startswith = N/A node_label N/A N/A tokens N/A 0 N/A 1 node_label_use_pred N/A N/A n m l N/A None None N/A N/A N/A N/A l None N/A node_label l N/A N/A N/A TgrepException N/A N/A node_label ={0} not bound in pattern format node_label N/A node N/A l N/A node_label N/A N/A n node N/A N/A node_label_use_pred N/A _tgrep_bind_node_label_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function representing a predicate on a tree node
    which can optionally bind a matching node into the tgrep2 string's
    label_dict.

    Called for expressions like (`tgrep_node_expr2`)::

        /NP/
        @NP=n
     N/A N/A N/A len tokens 1 N/A N/A N/A tokens N/A 0 N/A N/A N/A N/A len tokens 3 N/A N/A N/A tokens N/A 1 = N/A node_pred N/A tokens N/A 0 N/A node_label N/A tokens N/A 2 node_label_bind_pred N/A N/A n m l N/A None None N/A N/A N/A node_pred n m l N/A N/A N/A l None N/A N/A N/A TgrepException N/A N/A cannot bind node_label {0}: label_dict is None format node_label N/A N/A l N/A node_label n N/A True N/A N/A False N/A N/A node_label_bind_pred N/A _tgrep_rel_disjunction_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a lambda function representing a predicate on a tree node
    from the disjunction of several other such lambda functions.
     N/A tokens N/A x N/A x tokens N/A x | N/A N/A N/A len tokens 1 N/A N/A N/A tokens N/A 0 N/A N/A N/A N/A len tokens 2 N/A N/A N/A N/A N/A N/A a b N/A N/A N/A N/A n m l N/A None None N/A N/A a n m l N/A b n m l N/A tokens N/A 0 N/A tokens N/A 1 N/A _macro_defn_action N/A N/A _s _l tokens N/A N/A N/A 
    Builds a dictionary structure which defines the given macro.
     N/A N/A N/A len tokens 3 N/A N/A N/A tokens N/A 0 @ N/A N/A N/A tokens N/A 1 N/A tokens N/A 2 N/A _tgrep_exprs_action N/A N/A _s _l tokens N/A N/A N/A 
    This is the top-lebel node in a tgrep2 search string; the
    predicate function it returns binds together all the state of a
    tgrep2 search string.

    Builds a lambda function representing a predicate on a tree node
    from the disjunction of several tgrep expressions.  Also handles
    macro definitions and macro name binding, and node label
    definitions and node label binding.
     N/A N/A N/A len tokens 1 N/A N/A N/A N/A N/A n m l N/A None None N/A N/A tokens N/A 0 n None N/A N/A tokens N/A x N/A x tokens N/A x ; N/A macro_dict N/A N/A macro_defs N/A tok N/A tok tokens N/A isinstance tok dict N/A macro_def macro_defs N/A N/A N/A N/A macro_dict update macro_def N/A tgrep_exprs N/A tok N/A tok tokens N/A N/A isinstance tok dict top_level_pred N/A N/A n m l N/A macro_dict None N/A N/A label_dict N/A N/A N/A any N/A N/A predicate n m label_dict N/A predicate tgrep_exprs N/A N/A top_level_pred N/A _build_tgrep_parser N/A N/A set_parse_actions N/A True N/A N/A 
    Builds a pyparsing-based parser object for tokenizing and
    interpreting tgrep search strings.
     N/A tgrep_op N/A N/A N/A pyparsing Optional ! N/A N/A pyparsing Regex [$%,.<>][%,.<>0-9-':]* N/A tgrep_qstring N/A N/A pyparsing QuotedString quoteChar " escChar \ unquoteResults False N/A tgrep_node_regex N/A N/A pyparsing QuotedString quoteChar / escChar \ unquoteResults False N/A tgrep_qstring_icase N/A N/A pyparsing Regex i@\"(?:[^"\n\r\\]|(?:\\.))*\" N/A tgrep_node_regex_icase N/A N/A pyparsing Regex i@\/(?:[^/\n\r\\]|(?:\\.))*\/ N/A tgrep_node_literal N/A N/A pyparsing Regex [^][ 
	
;:.,&|<>()$!@%'^=]+ N/A tgrep_expr N/A N/A pyparsing Forward N/A tgrep_relations N/A N/A pyparsing Forward N/A tgrep_parens N/A N/A N/A N/A pyparsing Literal ( tgrep_expr ) N/A tgrep_nltk_tree_pos N/A N/A N/A N/A pyparsing Literal N( N/A N/A pyparsing Optional N/A N/A N/A N/A pyparsing Word N/A pyparsing nums , N/A N/A pyparsing Optional N/A N/A N/A pyparsing delimitedList N/A N/A pyparsing Word N/A pyparsing nums delim , N/A N/A pyparsing Optional , ) N/A tgrep_node_label N/A N/A pyparsing Regex [A-Za-z0-9]+ N/A tgrep_node_label_use N/A N/A pyparsing Combine N/A = tgrep_node_label N/A tgrep_node_label_use_pred N/A N/A tgrep_node_label_use copy N/A macro_name N/A N/A pyparsing Regex [^];:.,&|<>()[$!@%'^=
	
 ]+ N/A N/A N/A macro_name setWhitespaceChars N/A macro_use N/A N/A pyparsing Combine N/A @ macro_name N/A tgrep_node_expr N/A N/A N/A N/A N/A N/A N/A N/A tgrep_node_label_use_pred macro_use tgrep_nltk_tree_pos tgrep_qstring_icase tgrep_node_regex_icase tgrep_qstring tgrep_node_regex * tgrep_node_literal N/A tgrep_node_expr2 N/A N/A N/A tgrep_node_expr N/A N/A N/A N/A pyparsing Literal = setWhitespaceChars N/A N/A N/A N/A tgrep_node_label copy setWhitespaceChars tgrep_node_expr N/A tgrep_node N/A tgrep_parens N/A N/A N/A N/A pyparsing Optional ' tgrep_node_expr2 N/A N/A pyparsing ZeroOrMore N/A | tgrep_node_expr N/A tgrep_brackets N/A N/A N/A N/A N/A pyparsing Optional ! [ tgrep_relations ] N/A tgrep_relation N/A tgrep_brackets N/A tgrep_op tgrep_node N/A tgrep_rel_conjunction N/A N/A pyparsing Forward N/A N/A tgrep_rel_conjunction N/A tgrep_relation N/A N/A pyparsing ZeroOrMore N/A N/A N/A pyparsing Optional & tgrep_rel_conjunction N/A N/A tgrep_relations N/A tgrep_rel_conjunction N/A N/A pyparsing ZeroOrMore N/A | tgrep_relations N/A N/A tgrep_expr N/A tgrep_node N/A N/A pyparsing Optional tgrep_relations N/A tgrep_expr_labeled N/A tgrep_node_label_use N/A N/A pyparsing Optional tgrep_relations N/A tgrep_expr2 N/A tgrep_expr N/A N/A pyparsing ZeroOrMore N/A : tgrep_expr_labeled N/A macro_defn N/A N/A N/A N/A N/A pyparsing Literal @ N/A N/A N/A N/A pyparsing White suppress macro_name tgrep_expr2 N/A tgrep_exprs N/A N/A N/A N/A N/A pyparsing Optional N/A N/A macro_defn N/A N/A pyparsing ZeroOrMore N/A ; macro_defn ; tgrep_expr2 N/A N/A pyparsing ZeroOrMore N/A ; N/A macro_defn tgrep_expr2 N/A N/A N/A N/A pyparsing ZeroOrMore ; suppress N/A set_parse_actions N/A N/A N/A N/A tgrep_node_label_use setParseAction _tgrep_node_label_use_action N/A N/A N/A tgrep_node_label_use_pred setParseAction _tgrep_node_label_pred_use_action N/A N/A N/A macro_use setParseAction _tgrep_macro_use_action N/A N/A N/A tgrep_node setParseAction _tgrep_node_action N/A N/A N/A tgrep_node_expr2 setParseAction _tgrep_bind_node_label_action N/A N/A N/A tgrep_parens setParseAction _tgrep_parens_action N/A N/A N/A tgrep_nltk_tree_pos setParseAction _tgrep_nltk_tree_pos_action N/A N/A N/A tgrep_relation setParseAction _tgrep_relation_action N/A N/A N/A tgrep_rel_conjunction setParseAction _tgrep_conjunction_action N/A N/A N/A tgrep_relations setParseAction _tgrep_rel_disjunction_action N/A N/A N/A macro_defn setParseAction _macro_defn_action N/A N/A N/A tgrep_expr setParseAction _tgrep_conjunction_action N/A N/A N/A tgrep_expr_labeled setParseAction _tgrep_segmented_pattern_action N/A N/A N/A tgrep_expr2 setParseAction N/A N/A functools partial _tgrep_conjunction_action join_char : N/A N/A N/A tgrep_exprs setParseAction _tgrep_exprs_action N/A N/A N/A tgrep_exprs ignore N/A # N/A pyparsing restOfLine N/A tgrep_tokenize N/A N/A tgrep_string N/A N/A N/A 
    Tokenizes a TGrep search string into separate tokens.
     N/A parser N/A _build_tgrep_parser False N/A N/A isinstance tgrep_string binary_type N/A N/A tgrep_string N/A N/A tgrep_string decode N/A N/A list N/A N/A parser parseString tgrep_string N/A tgrep_compile N/A N/A tgrep_string N/A N/A N/A 
    Parses (and tokenizes, if necessary) a TGrep search string into a
    lambda function.
     N/A parser N/A _build_tgrep_parser True N/A N/A isinstance tgrep_string binary_type N/A N/A tgrep_string N/A N/A tgrep_string decode N/A N/A N/A list N/A N/A parser parseString tgrep_string parseAll True N/A 0 N/A treepositions_no_leaves N/A N/A tree N/A N/A N/A 
    Returns all the tree positions in the given tree which are not
    leaf nodes.
     N/A treepositions N/A N/A tree treepositions N/A prefixes N/A set N/A pos treepositions N/A N/A length N/A range N/A len pos N/A N/A N/A N/A prefixes add N/A pos N/A length N/A N/A pos N/A pos treepositions N/A pos prefixes N/A tgrep_positions N/A N/A pattern trees search_leaves N/A True N/A N/A 
    Return the tree positions in the trees which match the given pattern.

    :param pattern: a tgrep search pattern
    :type pattern: str or output of tgrep_compile()
    :param trees: a sequence of NLTK trees (usually ParentedTrees)
    :type trees: iter(ParentedTree) or iter(Tree)
    :param search_leaves: whether ot return matching leaf nodes
    :type search_leaves: bool
    :rtype: iter(tree positions)
     N/A N/A isinstance pattern N/A binary_type text_type N/A N/A pattern N/A tgrep_compile pattern N/A tree trees N/A N/A N/A N/A search_leaves N/A N/A positions N/A N/A tree treepositions N/A N/A positions N/A treepositions_no_leaves tree N/A N/A N/A position N/A position positions N/A pattern N/A tree N/A position N/A N/A N/A AttributeError N/A N/A N/A N/A N/A tgrep_nodes N/A N/A pattern trees search_leaves N/A True N/A N/A 
    Return the tree nodes in the trees which match the given pattern.

    :param pattern: a tgrep search pattern
    :type pattern: str or output of tgrep_compile()
    :param trees: a sequence of NLTK trees (usually ParentedTrees)
    :type trees: iter(ParentedTree) or iter(Tree)
    :param search_leaves: whether ot return matching leaf nodes
    :type search_leaves: bool
    :rtype: iter(tree nodes)
     N/A N/A isinstance pattern N/A binary_type text_type N/A N/A pattern N/A tgrep_compile pattern N/A tree trees N/A N/A N/A N/A search_leaves N/A N/A positions N/A N/A tree treepositions N/A N/A positions N/A treepositions_no_leaves tree N/A N/A N/A N/A tree N/A position N/A position positions N/A pattern N/A tree N/A position N/A N/A N/A AttributeError N/A N/A N/A N/A N/A