genericize chain remover to use it for bridge and addressed chains
This commit is contained in:
parent
19cd23879f
commit
76a052e091
|
@ -15,8 +15,16 @@ class Command(BaseCommand):
|
|||
for context in markov_contexts:
|
||||
self.stdout.write(self.style.NOTICE(f"scanning context {context}..."))
|
||||
# get starting states that look like they came over the bridge
|
||||
start_states = context.states.filter(k1=MarkovState._start1, k2=MarkovState._start2,
|
||||
bridge_states = context.states.filter(k1=MarkovState._start1, k2=MarkovState._start2,
|
||||
v__regex=r'<.*>')
|
||||
self._chain_remover(context, bridge_states)
|
||||
|
||||
def _chain_remover(self, context, start_states):
|
||||
"""Remove a given k from markov states, deleting the found states after rebuilding subsequent states.
|
||||
|
||||
As in, if trying to remove A,B -> X, then B,X -> C and X,C -> D must be rebuilt (A,B -> C / B,C -> D)
|
||||
then the three states with X deleted.
|
||||
"""
|
||||
for start_state in start_states:
|
||||
self.stdout.write(self.style.NOTICE(f" diving into {start_state}..."))
|
||||
# find the states that build off of the start
|
||||
|
|
Loading…
Reference in New Issue