      Defaults = BaseDefaults
      lang = None
  
      @classmethod
      @contextmanager
      def train(cls, path, gold_tuples, *configs):
          if isinstance(path, basestring):
              path = pathlib.Path(path)
          tagger_cfg, parser_cfg, entity_cfg = configs
          dep_model_dir = path / 'deps'
          ner_model_dir = path / 'ner'
          pos_model_dir = path / 'pos'
          if dep_model_dir.exists():
              shutil.rmtree(str(dep_model_dir))
          if ner_model_dir.exists():
              shutil.rmtree(str(ner_model_dir))
          if pos_model_dir.exists():
              shutil.rmtree(str(pos_model_dir))
          dep_model_dir.mkdir()
          ner_model_dir.mkdir()
          pos_model_dir.mkdir()
  
          if parser_cfg['pseudoprojective']:
              # preprocess training data here before ArcEager.get_labels() is called
              gold_tuples = PseudoProjectivity.preprocess_training_data(gold_tuples)
  
 
</s> remove         parser_cfg['actions'] = ArcEager.get_actions(gold_parses=gold_tuples)
        entity_cfg['actions'] = BiluoPushDown.get_actions(gold_parses=gold_tuples)

        with (dep_model_dir / 'config.json').open('wb') as file_:
            data = ujson.dumps(parser_cfg)
            if isinstance(data, unicode):
                data = data.encode('utf8')
            file_.write(data)
        with (ner_model_dir / 'config.json').open('wb') as file_:
            data = ujson.dumps(entity_cfg)
            if isinstance(data, unicode):
                data = data.encode('utf8')
            file_.write(data)
        with (pos_model_dir / 'config.json').open('wb') as file_:
            data = ujson.dumps(tagger_cfg)
            if isinstance(data, unicode):
                data = data.encode('utf8')
            file_.write(data)
 </s> add         for subdir in ('deps', 'ner', 'pos'):
            if subdir not in configs:
                configs[subdir] = {}
        configs['deps']['actions'] = ArcEager.get_actions(gold_parses=gold_tuples)
        configs['ner']['actions'] = BiluoPushDown.get_actions(gold_parses=gold_tuples)

        cls.setup_directory(path, **configs) </s> remove     def end_training(self, path=None):
        if path is None:
            path = self.path
        elif isinstance(path, basestring):
            path = pathlib.Path(path)
 </s> add     def save_to_directory(self, path):
        configs = {
            'pos': self.tagger.cfg if self.tagger else {},
            'deps': self.parser.cfg if self.parser else {},
            'ner': self.entity.cfg if self.entity else {},
        } </s> remove             self.tagger.model.end_training()
 </s> add  </s> remove         strings_loc = path / 'vocab' / 'strings.json'
        with strings_loc.open('w', encoding='utf8') as file_:
            self.vocab.strings.dump(file_)
        self.vocab.dump(path / 'vocab' / 'lexemes.bin')

 </s> add     def end_training(self, path=None):
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
      Defaults = BaseDefaults
      lang = None
  
      @classmethod
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
    def setup_directory(cls, path, **configs):
        for name, config in configs.items():
            directory = path / name
            if directory.exists():
                shutil.rmtree(str(directory))
            directory.mkdir()
            with (directory / 'config.json').open('wb') as file_:
                data = ujson.dumps(config, indent=2)
                if isinstance(data, unicode):
                    data = data.encode('utf8')
                file_.write(data)
        if not (path / 'vocab').exists():
            (path / 'vocab').mkdir()
  
          if parser_cfg['pseudoprojective']:
              # preprocess training data here before ArcEager.get_labels() is called
              gold_tuples = PseudoProjectivity.preprocess_training_data(gold_tuples)
  
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Refactor Language.end_training, making new save_to_directory method 
spacy/language.py