Recently I was looking at some code related to a deep learning paper, repo here: https://github.com/wuyifan18/DeepLog/blob/master/LogKeyModel_predict.py
This has more to do with python so I will not mention anything else about it. Below is a file we need to parse:
5 5 5 22 11 9 11 9 11 9 26 26 26 23 23 23 21 21 21 
5 5 22 5 11 9 11 9 11 9 26 26 26 
5 22 5 5 11 9 11 9 11 9 26 26 26 
5 22 5 5 11 9 11 9 11 9 26 26 26 
5 22 5 5 11 9 11 9 11 9 26 26 26 23 23 23 21 21 21 
22 5 5 5 11 9 11 9 11 9 26 26 26 23 23 23 21 21 21 
5 22 5 5 11 9 11 9 11 9 26 26 26 23 23 23 21 21 21 
5 5 5 22 11 9 11 9 11 9 26 26 26 2 23 23 23 21 21 21 
5 22 5 5 11 9 11 9 11 9 26 26 26
The following function is supposed to parse it. First, we take each line, and make a list with the elements being the numbers in that line separated by spaces. Then we subtract said numbers by one at line ###.
What happens next?
def generate(name):
    hdfs = set()
    # hdfs = []
    with open('data/' + name, 'r') as f:
        for ln in f.readlines():
            ln = list(map(lambda n: n - 1, map(int, ln.strip().split()))) ###
            ln = ln + [-1] * (window_size + 1 - len(ln))
            # print(ln)
            hdfs.add(tuple(ln))
    print('Number of sessions({}): {}'.format(name, len(hdfs)))
    return hdfs
I am not sure what the purpose of ln = ln + [-1] * (window_size + 1 - len(ln)) is exactly. What is it doing? I have not seen list multiplication being used in many places before, so I am not sure. When I try and print out more of it, it seems that -1 is not present in ln at all. Anyone have some idea?
 
    