text: import numpy as np
  import json
  import codecs
  import re
  import csv 
  
  #source: ( That ( ( 's ( ( a lot ) ( to ( pack ( into ( 18 minutes ) ) ) ) ) ) . ) )
  #target: وأخرج ملتحفا فوطتي، كان الجميع يراني .
  def load_data(source_path, target_path, trg_language="arabic", src_language="english", data_type="gt", is_lowercase=True):
      examples = []
      s_file=open(source_path)
      t_file=open(target_path)
      for element in zip(s_file.readlines(), t_file.readlines()):
          line = element[0].strip()
          s_tokens, s_transitions=convert_binary_bracketing(line, data_type=data_type, lowercase=is_lowercase)
          t_tokens=element[1].lower().split()
          example = {}
          example["source_tokens"] = s_tokens
          example["target_tokens"] = t_tokens
          example["source_transitions"] = s_transitions
          examples.append(example)
      return examples
  
  
  def convert_binary_bracketing(parse, data_type="gt",lowercase=False):
      transitions = []
      tokens = []
      for word in parse.split(' '):
          if word[0] != "(":
              if word.strip() == ")":
                  transitions.append(1)
              else:
                  # Downcase all words to match GloVe.
                  if lowercase:
                      tokens.append(word.lower())
                  else:
                      tokens.append(word)
                  transitions.append(0)
      if(data_type=="lb"):
          transitions=lb_build(len(tokens))
      elif(data_type=="bal"):
          transitions=balanced_transitions(len(tokens))
      #print(transitions)
      return tokens, transitions
  
  def lb_build(N):
        if N==2:
            return [0,0,1]
        else:
            return [0,0,1]+(N-2)*[0,1]
  
  def balanced_transitions(N):
          """
          Recursively creates a balanced binary tree with N
          leaves using shift reduce transitions.
          """
          if N == 3:
              return [0, 0, 1, 0, 1]
          elif N == 2:
              return [0, 0, 1]
          elif N == 1:
              return [0]
          else:
              right_N = N // 2
              left_N = N - right_N
              return balanced_transitions(left_N) + balanced_transitions(right_N) + [1]
  
  
  