<commit_before>from twisted.internet import protocol
from twisted.application import internet, service

from opennsa import jsonrpc

PORT = 4321


def add(*args):
    return sum(args)



class JSONRPCFactory(protocol.Factory):

    protocol = jsonrpc.JSONRPCService

    def buildProtocol(self, addr):

        p = self.protocol()
        p.registerFunction('add', add)
        p.factory = self
        return p


factory = JSONRPCFactory()


application = service.Application("OpenNSA")

internet.TCPServer(PORT, factory, interface='localhost').setServiceParent(application)

<commit_msg>update tac file to simple nsi service<commit_after>#!/usr/bin/env python # syntax highlightning

from twisted.internet import protocol
from twisted.application import internet, service

from opennsa import jsonrpc, nsirouter
from opennsa.backends import dud

PORT = 4321


dud_backend = dud.DUDNSIBackend('DUD NSI Backend')
nsi_router  = nsirouter.NSIRouterAdaptor('dudnetwork', dud_backend)

class OpenNSAJSONRPCFactory(protocol.Factory):

    protocol = jsonrpc.JSONRPCService

    def buildProtocol(self, addr):

        p = self.protocol()
        p.factory = self
        jsonrpc.JSONRPCNSIServiceAdaptor(p, nsi_router)
        return p



factory = OpenNSAJSONRPCFactory()

application = service.Application("OpenNSA")

internet.TCPServer(PORT, factory, interface='localhost').setServiceParent(application)


{'fraction_non_alphanumeric': 0.08766928011404133, 'fraction_numerical': 0.005702066999287242, 'mean_word_length': 4.441860465116279, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '2581570', 'n_tokens_mistral': 427, 'n_tokens_neox': 406, 'n_words': 100}