"""
The system is currently working on a small number of files,
because the data is saved on disk.
The next feature will save the data in an file(Probably of the json type)
"""

from offline import init
from utils import format_line
from online import get_best_k_completions

if __name__ == '__main__':
    STOP_INPUT = '#'
    print("Loading the file and preparing the system....")
    init()
    string_to_complete = input("The system is ready. Enter your text:")

    while string_to_complete:
        if string_to_complete[-1] != STOP_INPUT:
            string_to_complete = format_line(string_to_complete)
            suggestions = get_best_k_completions(string_to_complete)

            if suggestions:
                print(f"There are {len(suggestions)} suggestions")

                for i in range(len(suggestions)):
                    print(
                        f'{i + 1}. {suggestions[i].get_complete_sentence()} , path = {suggestions[i].get_source_text()}'
                    )

            else:
                print("There are'nt suggestions")
示例#2
0
def save(np, path):
    lines = np[:,:,0]
    lines[lines>0] = 255
    alpha = lines.copy()
    lines[:] = 0

    im = Image.fromarray(lines, mode='L')
    im.putalpha(Image.fromarray(alpha, mode='L'))
    im.save(path)

for side in 'ABCD':
    print side

    params = getattr(vinyl, side)
    player = offline.init(params)
    player.scale = scale
    player.thick = thick

    # Set to high-resolution
    base = player._get_base_frame()#scale=scale,thick=thick)

    # numm.np2image(base, '%s-base.png' % (side))
    save(base, '%s-base.png' % (side))

    # describe the initial conditions as a same-sized set of circles

    initial = base.copy()
    initial[:] = 0

    def s(pt):
示例#3
0
#!/usr/bin/env python2

import sys

import numm
import offline

params = {"target": 10,
          "speed": 20,
          "sounds": "final_material_tt_bearbeit_2nd_order_NEUER_(450)"}
p = offline.init(params)
scale = 0.5
base = p._get_base_frame(scale=scale)

def video_out(v):
    v[:] = p.draw()
def audio_out(a):
    a[:] = p.next(len(a))
def mouse_in(type, px, py, button):
    if type == 'mouse-button-press':
        pt = (px*base.shape[1]/scale, py*base.shape[0]/scale)
        node = p.graph.nearest(*pt)
        print node
        p.trigger(node)

NW = numm.Run(
    video_out=video_out,
    audio_out=audio_out,
    mouse_in=mouse_in,
    width=base.shape[1],
    height=base.shape[0],