<jupyter_start><jupyter_text>Treat gesture data* Read the gesture data* Remove files that are too short* Remove files that do not have inactivity at the end* Shorten all valid files to a length of 128 values<jupyter_code>import os
files = os.listdir()
for file in files:
    if file.find('.dat') != -1:
        infile = open(file,"r") 
        buffer = infile.readlines() 
        file_length = len(buffer) # This would give length of files.
        infile.close()
        if file_length < 128 :
            print("Short file: {}, length is {:d}".format(file,file_length))
        else :
            outfile= open("treated/"+file,"w")
            for line in range(128):
                outfile.write(buffer[line])
            outfile.close()<jupyter_output>Short file: nine_20220215-181929.dat, length is 87
Short file: four_20220215-200610.dat, length is 28
Short file: seven_20220215-181847.dat, length is 74
Short file: zero_20220215-182508.dat, length is 19
Short file: eight_20220215-184433.dat, length is 3
Short file: five_20220215-184027.dat, length is 9
Short file: two_20220215-184458.dat, length is 2
Short file: six_20220215-200642.dat, length is 16
Short file: nine_20220215-184115.dat, length is 8
Short file: five_20220215-200647.dat, length is 8
Short file: five_20220215-200638.dat, length is 75
Short file: two_20220215-184111.dat, length is 3
Short file: three_20220215-200657.dat, length is 13
Short file: six_20220215-200112.dat, length is 12
Short file: four_20220215-200429.dat, length is 40
Short file: one_20220215-184022.dat, length is 8
Short file: eight_20220215-200249.dat, length is 38
Short file: three_20220215-184502.dat, length is 91
Short file: four_20220215-200652.dat, length is 12
Short file: eight_20220215-182413.dat,[...]<jupyter_text>Get a data file and plot it<jupyter_code>import pandas as pd
df = pd.read_csv("treated/eight_20220215-182036.dat")
df.plot()
import pandas as pd
import matplotlib.pyplot as plt
def plotfile(filename):
    df = pd.read_csv(filename)
    df.plot(title=filename)
plotfile("treated/eight_20220215-182036.dat")
plotfile("eight_20220215-182036.dat")
plotfile("eight_20220215-182115.dat")
plotfile("one_20220215-182105.dat")
plotfile("seven_20220215-182017.dat")
df = pd.read_csv("treated/five_20220215-182154.dat")
df = df.drop(columns=["az"])
df.plot()
def plot_positions(df):
    vx = []
    vy = []
    sx = []
    sy = []
    sum= 0
    # integreate once to get the speed
    for i in range(len(df['ax'])) :
        if abs(df['ax'][i]) > 5 and abs(df['ay'][i]) > 5:
            sum += df['ax'][i]
        else:
            sum = 0
        vx.append(sum)
    sum = 0
    # integrate a second time to get the position
            sum += vx[i]
        sx.append(sum)
    # same for y
    sum = 0
    for i in range(len(df['ay'])) :
        if abs(df['ax'][i]) > 5 and abs(df['ay'][i]) > 5:
            sum += df['ay'][i]
        else:
            sum = 0
        vy.append(sum)
    sum = 0
    for i in range(len(vy)) :
        sum += vy[i]
        sy.append(sum)
    plt.scatter(sx,sy)
    plt.show()
df.plot()
df = pd.read_csv("treated/five_20220215-182154.dat")
plot_positions(df)
df = pd.read_csv("treated/one_20220215-182105.dat")
df = df[:65]
df.plot()
plot_positions(df)
def plotvx(df):
    vx = []
    sum= 0
    # integreate once to get the speed
    for i in range(len(df['ax'])) :
        if abs(df['ax'][i]) > 5 and abs(df['ay'][i]) > 5:
            sum += df['ax'][i]
        else:
            sum = 0
        vx.append(sum)
    plt.plot(vx)
def plotvy(df) :
    vy = []
    sum= 0
    # integreate once to get the speed
    for i in range(len(df['ay'])) :
        if abs(df['ax'][i]) > 5 and abs(df['ay'][i]) > 5:
            sum += df['ay'][i]
        else:
            sum = 0
        vy.append(sum)
    plt.plot(vy)
df = pd.read_csv("treated/one_20220215-183036.dat")
df.plot()
df = df[:65]
plot_positions(df)
plotvx(df)
plotvy(df)
df = pd.read_csv("treated/one_20220215-183409.dat")
df = df[:65]
df.plot()

plot_positions(df)
df = pd.read_csv("treated/one_20220215-183507.dat")
plot_positions(df)
df = pd.read_csv("treated/one_20220215-195803.dat")
plot_positions(df)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13876283735371386, 'fraction_numerical': 0.12586577501791257, 'mean_word_length': 3.0739299610894943, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '556801', 'license': 'MIT', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1532, 'n_words': 385, 'path': 'magic-wand/accelerometers/adxl345/gestures/newgestures/treatGesture.ipynb', 'repo_name': 'uraich/EdgeComputing', 'size': '4187'}