Skip to Main Content
Listing 2. 
a:split node as described in Python using StringCatSplitAction. Action is a subclass of the ControlNode class that contains the transition function. All aspects of Action are overwritten in StringCatSplitAction.
1 class StringCatSplitAction(node.Action): 
3  def _ _init_ _(self, writesample, readsample, readcontainers=None): 
4   super(StringCatSplitAction, self)._ _init_ _(writesample, readsample, readcontainers) 
5   self.sample = None 
6   pass 
8  def read(self): 
9   self.sample = self.readsample.read() 
10 
11  def check(self): 
12   return super(StringCatSplitAction, self).check() 
13 
14  def pull(self): 
15   self.readsample.remove(self.sample) 
16 
17  def process(self): 
18   doubleindex = [i for i in range(0, len(self.sample) - 1) if self.sample [i] == self.sample [i+1]] 
19   index = random.choice(doubleindex) 
20   self.sample = [self.sample [0:index], self.sample [index:0]] 
21   pass 
22 
23  def push(self): 
24   self.writesample.add(self.sample) 
1 class StringCatSplitAction(node.Action): 
3  def _ _init_ _(self, writesample, readsample, readcontainers=None): 
4   super(StringCatSplitAction, self)._ _init_ _(writesample, readsample, readcontainers) 
5   self.sample = None 
6   pass 
8  def read(self): 
9   self.sample = self.readsample.read() 
10 
11  def check(self): 
12   return super(StringCatSplitAction, self).check() 
13 
14  def pull(self): 
15   self.readsample.remove(self.sample) 
16 
17  def process(self): 
18   doubleindex = [i for i in range(0, len(self.sample) - 1) if self.sample [i] == self.sample [i+1]] 
19   index = random.choice(doubleindex) 
20   self.sample = [self.sample [0:index], self.sample [index:0]] 
21   pass 
22 
23  def push(self): 
24   self.writesample.add(self.sample) 
Close Modal

or Create an Account

Close Modal
Close Modal