def accuracy(trg, pred):
     """Computes accuracy between a target sequence
     and a predicted sequence

     Args:
        - trg (str): reference
        - pred (str): generated output

     Returns:
        - acc (float): word level accuracy
     """
     trg_words = trg.split(' ')
     pred_words = pred.split(' ')
     acc = 0
     for i, w in enumerate(trg_words):
         if i < len(pred_words):
             if w == pred_words[i]:
                 acc += 1
         else:
             break
     return float(acc) / float(len(trg_words))