Markov: make some attempt to avoid name: chains
there are a lot of these, so it's a hard problem to solve entirely, but this will avoided some cases at least
This commit is contained in:
parent
6a12763c81
commit
7322ebde8f
@ -449,8 +449,8 @@ class Markov(Module):
|
||||
|
||||
new_sentence = self._create_chain_with_k1_k2(self.start1,
|
||||
self.start2,
|
||||
3,
|
||||
context_id)
|
||||
3, context_id,
|
||||
avoid_address=True)
|
||||
|
||||
if len(new_sentence) > 0:
|
||||
self.log.debug("started new sentence "
|
||||
@ -587,7 +587,8 @@ class Markov(Module):
|
||||
raise
|
||||
finally: cur.close()
|
||||
|
||||
def _create_chain_with_k1_k2(self, k1, k2, length, context_id):
|
||||
def _create_chain_with_k1_k2(self, k1, k2, length, context_id,
|
||||
avoid_address=False):
|
||||
"""Create a chain of the given length, using k1,k2.
|
||||
|
||||
k1,k2 does not appear in the resulting chain.
|
||||
@ -604,6 +605,12 @@ class Markov(Module):
|
||||
if v:
|
||||
chain.append(v)
|
||||
|
||||
# check for addresses (the "whoever:" in
|
||||
# __start1 __start2 whoever: some words)
|
||||
addressing_suffixes = [':', ',']
|
||||
if chain[2][-1] in addressing_suffixes and avoid_address:
|
||||
return chain[3:]
|
||||
else:
|
||||
return chain[2:]
|
||||
|
||||
def _get_chatter_targets(self):
|
||||
|
Loading…
Reference in New Issue
Block a user