<commit_before>-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.

local class = require('class')
local check = require('check')

local types = {}
local dissector = {}
local log = haka.log_section("dissector")
local log_lua = haka.log_section("lua")

haka.dissectors = {}
local mt = {
	__index = function(t, k)
		log.error("unknown dissector %s", k)
	end
}
setmetatable(haka.dissectors, mt)

--
-- Dissector base class
--

types.Dissector = class.class('Dissector')

local event_mt = {
	__index = function (self, name)
		check.error(string.format("unkown event '%s'", name))
	end
}

function types.Dissector.__class_init(self, cls)
	self.super:__class_init(cls)

	cls.events = {}
	setmetatable(cls.events, event_mt)
	self.inherit_events(cls)
	cls.options = {}
	cls.connections = haka.event.StaticEventConnections:new()
	cls.policies = {}
	cls.policies.next_dissector = haka.policy.new(string.format("%s next dissector", cls.name))
end

function types.Dissector.method:install_criterion()
	return {}
end<commit_msg>Add error when trying to use unknown policy<commit_after>-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.

local class = require('class')
local check = require('check')

local types = {}
local dissector = {}
local log = haka.log_section("dissector")
local log_lua = haka.log_section("lua")

haka.dissectors = {}
local mt = {
	__index = function(t, k)
		log.error("unknown dissector %s", k)
	end
}
setmetatable(haka.dissectors, mt)

--
-- Dissector base class
--

types.Dissector = class.class('Dissector')

local event_mt = {
	__index = function (self, name)
		check.error(string.format("unkown event '%s'", name))
	end
}

local policies_mt = {
	__index = function (self, name)
		check.error(string.format("unkown policy '%s'", name))
	end
}

function types.Dissector.__class_init(self, cls)
	self.super:__class_init(cls)

	cls.events = {}
	setmetatable(cls.events, event_mt)
	self.inherit_events(cls)
	cls.options = {}
	cls.connections = haka.event.StaticEventConnections:new()
	cls.policies = {}
	setmetatable(cls.policies, policies_mt)
	cls.policies.next_dissector = haka.policy.new(string.format("%s next dissector", cls.name))
end

function types.Dissector.method:install_criterion()
	return {}
end
{'fraction_non_alphanumeric': 0.13764379214597383, 'fraction_numerical': 0.0031733439111463705, 'mean_word_length': 4.530701754385965, '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': '1982178', 'n_tokens_mistral': 890, 'n_tokens_neox': 870, 'n_words': 223}