-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_lstm.py
36 lines (24 loc) · 1.02 KB
/
generate_lstm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from __future__ import print_function
import pandas as pd
from sklearn.model_selection import train_test_split
from lstm_seq2seq.library.utility.plot_utils import plot_and_save_history
from lstm_seq2seq.library.seq2seq import Seq2SeqSummarizer
import numpy as np
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--abstract", "-a", help="path to you abstract.txt",type = str)
args = parser.parse_args()
np.random.seed(170110)
data_dir_path = './data'
model_dir_path = './models'
config = np.load(Seq2SeqSummarizer.get_config_file_path(model_dir_path=model_dir_path),allow_pickle=True).item()
summarizer = Seq2SeqSummarizer(config)
summarizer.load_weights(weight_file_path=Seq2SeqSummarizer.get_weight_file_path(model_dir_path=model_dir_path))
with open(args.abstract) as f:
data = f.read()
headline = summarizer.summarize(data)
print('Generated Tile: ')
print(headline)
name = args.abstract.split('/')[-1]
with open('./docs/titles/'+"title_"+name,"w") as output:
print('{}'.format(headline), file=output)