(original_train, train_file, dev_file, split_rate)
Split train and dev data set.
Split train and dev data set.
Split train and dev data set .
def split_train_dev(original_train, train_file, dev_file, split_rate):
  """Split train and dev data set."""
  with open(original_train, encoding="utf-8") as original_train_f, \
    open(train_file, "w", encoding="utf-8") as train_f, \
    open(dev_file, "w", encoding="utf-8") as dev_f:
    lines = original_train_f.readlines()
    lines_train, lines_dev = train_test_split(
        lines, test_size=split_rate, random_state=2019)

    logging.info("Save train file to {}".format(train_file))
    for line in lines_train:
      train_f.write(line)

    logging.info("Save train file to {}".format(dev_file))
    for line in lines_dev:
      dev_f.write(line)
def split_train_dev ( original_train , train_file , dev_file , split_rate ) : with open ( original_train , encoding = "utf-8" ) as original_train_f , open ( train_file , "w" , encoding = "utf-8" ) as train_f , open ( dev_file , "w" , encoding = "utf-8" ) as dev_f : lines = original_train_f . readlines ( ) lines_train , lines_dev = train_test_split ( lines , test_size = split_rate , random_state = 2019 ) logging . info ( "Save train file to {}" . format ( train_file ) ) for line in lines_train : train_f . write ( line ) logging . info ( "Save train file to {}" . format ( dev_file ) ) for line in lines_dev : dev_f . write ( line )