Przykład (python) użycia notacji lpmn

Zmiana wykonywanego zadania polega na podmianie łańcucha

urlzip("http://ws.clarin-pl.eu/public/teksty/ksiazki.zip")|any2txt|wcrft2
na inny.

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import json
import urllib2
import glob   
import os
import time
url="http://ws.clarin-pl.eu/nlprest2/base" 

def upload(id,file):
    content = urllib2.urlopen(urllib2.Request(url+'/download'+id)).read();    
        with open (file, "w") as outfile:
                outfile.write(content)  

def process(lpmn):    
        start_time = time.time()
        data={};
        data['user']=podaj@swoj.adres #zamienić na e-mail w ''
        data['lpmn']=lpmn;
        doc=json.dumps(data)
        taskid = urllib2.urlopen(urllib2.Request(url+'/startTask/',doc,{'Content-Type': 'application/json'})).read();
        time.sleep(0.05);
        resp = urllib2.urlopen(urllib2.Request(url+'/getStatus/'+taskid));
        data=json.load(resp)
        #print data;
        while data["status"] == "QUEUE" or data["status"] == "PROCESSING" :
            time.sleep(0.01);
            resp = urllib2.urlopen(urllib2.Request(url+'/getStatus/'+taskid));
            data=json.load(resp)
        if data["status"]=="ERROR":
            print("Error "+data["value"]);
            return None;
        print("   processing      %s seconds ---" % (time.time() - start_time))    
        return data["value"]

def main():

    global_time = time.time()
    res=process('urlzip("http://ws.clarin-pl.eu/public/teksty/ksiazki.zip")|any2txt|wcrft2);    
    for el in res:
        upload(el["fileID"],"out/"+el["name"]);

    print("GLOBAL %s seconds ---" % (time.time() - global_time))    

main();