本文整理汇总了Python中logr.Logr.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Logr.debug方法的具体用法?Python Logr.debug怎么用?Python Logr.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logr.Logr
的用法示例。
在下文中一共展示了Logr.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_merge_is_order_independent
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def test_merge_is_order_independent(self):
root_one = [
self._create_chain(['avatar', 'the', 'legend', 'of', 'korra']),
self._create_chain(['la', 'leggenda', 'di', 'korra']),
self._create_chain(['the', 'last', 'airbender', 'the', 'legend', 'of', 'korra'])
]
self._create_chain(['legend', 'of', 'korra'], root_one[-1])
root_one.append(self._create_chain(['legend', 'of', 'korra']))
result_one = self.merge.merge(root_one)
Logr.debug("-----------------------------------------------------------------")
root_two = [
self._create_chain(['the', 'legend', 'of', 'korra']),
]
self._create_chain(['last', 'airbender', 'the', 'legend', 'of', 'korra'], root_two[-1])
root_two += [
self._create_chain(['legend', 'of', 'korra']),
self._create_chain(['la', 'leggenda', 'di', 'korra']),
self._create_chain(['avatar', 'the', 'legend', 'of', 'korra'])
]
result_two = self.merge.merge(root_two)
Logr.debug("=================================================================")
assert itemsMatch(
self._get_chain_values(result_one),
self._get_chain_values(result_two)
)
示例2: calculate_sim_links
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def calculate_sim_links(for_node, other_nodes):
for node in other_nodes:
if node in for_node.links:
continue
Logr.debug('calculating similarity between "%s" and "%s"', for_node.value, node.value)
# Get similarity
similarity_matcher = create_matcher(for_node.value, node.value)
similarity = similarity_matcher.quick_ratio()
# Get for_node -> node opcodes
a_opcodes_matcher = create_matcher(for_node.value, node.value, swap_longest = False)
a_opcodes = a_opcodes_matcher.get_opcodes()
a_stats = get_opcode_stats(for_node, node, a_opcodes)
Logr.debug('-' * 100)
# Get node -> for_node opcodes
b_opcodes_matcher = create_matcher(node.value, for_node.value, swap_longest = False)
b_opcodes = b_opcodes_matcher.get_opcodes()
b_stats = get_opcode_stats(for_node, node, b_opcodes)
for_node.links[node] = SimLink(similarity, a_opcodes, a_stats)
node.links[for_node] = SimLink(similarity, b_opcodes, b_stats)
示例3: parse_closure
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def parse_closure(self, parent_head, subject):
parent_node = parent_head[0] if type(parent_head) is list else parent_head
nodes, match = self.match(parent_head, parent_node, subject)
# Capturing broke on constraint, return now
if not match:
return nodes
Logr.debug('created closure node with subject.value: "%s"' % subject.value)
result = [CaperClosureNode(
subject,
parent_head,
match
)]
# Branch if the match was indefinite (weight below 1.0)
if match.result and match.weight < 1.0:
if match.num_fragments == 1:
result.append(CaperClosureNode(subject, parent_head))
else:
nodes.append(CaperClosureNode(subject, parent_head))
nodes.append(result[0] if len(result) == 1 else result)
return nodes
示例4: parse
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def parse(self, titles):
root = []
tails = []
for title in titles:
Logr.debug(title)
cur = None
words = title.split(' ')
for wx in xrange(len(words)):
word = strip(words[wx])
if cur is None:
cur = find_node(root, word)
if cur is None:
cur = DNode(word, None, num_children=len(words) - wx, original_value=title)
root.append(cur)
else:
parent = cur
parent.weight += 1
cur = find_node(parent.right, word)
if cur is None:
Logr.debug("%s %d", word, len(words) - wx)
cur = DNode(word, parent, num_children=len(words) - wx)
sorted_append(parent.right, cur, lambda a: a.num_children < cur.num_children)
else:
cur.weight += 1
tails.append(cur)
return root, tails
示例5: _merge
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def _merge(self, nodes, depth = 0):
Logr.debug(str('\t' * depth) + str(nodes))
if not len(nodes):
return []
top = nodes[0]
# Merge into top
for x in range(len(nodes)):
# Merge extra results into top
if x > 0:
top.value = None
top.weight += nodes[x].weight
self.destroy_nodes_right(top.right)
if len(nodes[x].right):
top.join_right(nodes[x].right)
Logr.debug("= %s joined %s", nodes[x], top)
nodes[x].dead = True
nodes = [n for n in nodes if not n.dead]
# Traverse further
for node in nodes:
if len(node.right):
node.right = self._merge(node.right, depth + 1)
return nodes
示例6: merge
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def merge(self, root):
for x in range(len(root)):
Logr.debug(root[x])
root[x].right = self._merge(root[x].right)
Logr.debug('=================================================================')
return root
示例7: print_tree
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def print_tree(node, depth = 0):
Logr.debug(str('\t' * depth) + str(node))
if len(node.right):
for child in node.right:
print_tree(child, depth + 1)
else:
Logr.debug(node.full_value()[1])
示例8: load
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def load(self):
parser = ConfigParser.ConfigParser()
parser.read(os.path.join(self.base_dir, 'data.cfg'))
for module_name, spec in self.module_loader.modules.items():
if parser.has_section(module_name):
self.load_module(parser, module_name, spec)
else:
Logr.debug("no section named '%s'" % module_name)
示例9: parse_subject
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def parse_subject(self, parent_head, subject):
Logr.debug("parse_subject (%s) subject: %s", self.step_source, repr(subject))
if type(subject) is CaperClosure:
return self.parse_closure(parent_head, subject)
if type(subject) is CaperFragment:
return self.parse_fragment(parent_head, subject)
raise ValueError('Unknown subject (%s)', subject)
示例10: fragment_match
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def fragment_match(self, fragment, group_name=None):
"""Follow a fragment chain to try find a match
:type fragment: caper.objects.CaperFragment
:type group_name: str or None
:return: The weight of the match found between 0.0 and 1.0,
where 1.0 means perfect match and 0.0 means no match
:rtype: (float, dict, int)
"""
group_name, weight_groups = self.find_group(group_name)
for weight, patterns in weight_groups:
for pattern in patterns:
success = True
result = {}
num_matched = 0
fragment_iterator = fragment.take_right(
return_type='value',
include_separators=pattern.include_separators,
include_source=True
)
for subject, fragment_pattern in itertools.izip_longest(fragment_iterator, pattern):
# No patterns left to match
if not fragment_pattern:
break
# No fragments left to match against pattern
if not subject:
success = False
break
value, source = subject
matches = pattern.execute(fragment_pattern, value)
if matches:
for match in pattern.process(matches):
update_dict(result, match)
else:
success = False
break
if source == 'subject':
num_matched += 1
if success:
Logr.debug('Found match with weight %s using regex pattern "%s"' % (weight, [sre.pattern for sre in pattern.patterns]))
return float(weight), result, num_matched
return 0.0, None, 1
示例11: print_link_tree
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def print_link_tree(nodes):
for node in nodes:
Logr.debug(node.value)
Logr.debug('\tnum_merges: %s', node.num_merges)
if len(node.links):
Logr.debug('\t========== LINKS ==========')
for link_node, link in node.links.items():
Logr.debug('\t%0.2f -- %s', link.similarity, link_node.value)
Logr.debug('\t---------------------------')
示例12: kill_nodes_above
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def kill_nodes_above(nodes, above_sim):
killed_nodes = []
for node in nodes:
if node.dead:
continue
Logr.debug(node.value)
for link_node, link in node.links.items():
if link_node.dead:
continue
Logr.debug('\t%0.2f -- %s', link.similarity, link_node.value)
if link.similarity >= above_sim:
if len(link_node.value) > len(node.value):
Logr.debug('\t\tvery similar, killed this node')
link_node.dead = True
node.num_merges += 1
killed_nodes.append(link_node)
else:
Logr.debug('\t\tvery similar, killed owner')
node.dead = True
link_node.num_merges += 1
killed_nodes.append(node)
kill_nodes(nodes, killed_nodes)
示例13: check_constraints
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def check_constraints(self, constraints, parent_head, subject, **kwargs):
parent_node = parent_head[0] if type(parent_head) is list else parent_head
# Check constraints
for constraint in [c for c in constraints if c.target == subject.__key__ or not c.target]:
Logr.debug("Testing constraint %s against subject %s", repr(constraint), repr(subject))
weight, success = constraint.execute(parent_node, subject, **kwargs)
if success:
Logr.debug('capturing broke on "%s" at %s', subject.value, constraint)
parent_node.finished_groups.append(self)
return True, weight == 1.0
return False, None
示例14: parse
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def parse(self, name, parser='scene'):
closures = self._closure_split(name)
closures = self._fragment_split(closures)
# Print closures
for closure in closures:
Logr.debug("closure [%s]", closure.value)
for fragment in closure.fragments:
Logr.debug("\tfragment [%s]", fragment.value)
if parser not in self.parsers:
raise ValueError("Unknown parser")
# TODO autodetect the parser type
return self.parsers[parser](self.debug).run(closures)
示例15: kill_trailing_nodes
# 需要导入模块: from logr import Logr [as 别名]
# 或者: from logr.Logr import debug [as 别名]
def kill_trailing_nodes(nodes):
killed_nodes = []
for node in nodes:
if node.dead:
continue
Logr.debug(node.value)
for link_node, link in node.links.items():
if link_node.dead:
continue
is_valid = link.stats.get('valid', False)
has_deletions = False
has_insertions = False
has_replacements = False
for opcode in link.opcodes:
if opcode[0] == 'delete':
has_deletions = True
if opcode[0] == 'insert':
has_insertions = True
if opcode[0] == 'replace':
has_replacements = True
equal_perc = link.stats.get('equal', 0) / float(len(node.value))
insert_perc = link.stats.get('insert', 0) / float(len(node.value))
Logr.debug('\t({0:<24}) [{1:02d}:{2:02d} = {3:02d} {4:3.0f}% {5:3.0f}%] -- {6:<45}'.format(
'd:%s, i:%s, r:%s' % (has_deletions, has_insertions, has_replacements),
len(node.value), len(link_node.value), link.stats.get('equal', 0),
equal_perc * 100, insert_perc * 100,
'"{0}"'.format(link_node.value)
))
Logr.debug('\t\t%s', link.stats)
kill = all([
is_valid,
equal_perc >= 0.5,
insert_perc < 2,
has_insertions,
not has_deletions,
not has_replacements
])
if kill:
Logr.debug('\t\tkilled this node')
link_node.dead = True
node.num_merges += 1
killed_nodes.append(link_node)
kill_nodes(nodes, killed_nodes)