# Path: dnsclass/tokenizer.py
# def tokenizer(domain):
# 	ret = []
# 	text = domain.lower().strip()
# 
# 	# parse the domain
# 	r = tldextract.extract(text)
# 
# 	# subdomain: only letters
# 	if len(r.subdomain):
# 		# change digits to 'N'
# 		sd = re.sub('[0-9]', 'N', r.subdomain)
# 		sd = re.sub('(N+)', '\\1.', sd)
# 
# 		for word in re.split("[^a-zN]+", sd):
# 			if len(word) == 0:
# 				continue
# 			elif word.isdigit():
# 				ret.append("N" * len(word))
# 			else:
# 				ret.extend(do_segment(word))
# 
# 	# domain: no dashes
# 	for word in r.domain.split("-"):
# 		ret.extend(do_segment(word))
# 
# 	# TLD: no dots
# 	if P.tok.tlds:
# 		for token in r.tld.split("."):
# 			if len(token) > 0: ret.append(token)
# 
# 	# flow features
# 	if P.tok.flow:
# 		ret.extend(get_flow_features(domain))
# 
# 	if P.tok.max > 0:
# 		ret = ret[-P.tok.max:]
# 
# 	#print "%s -> %s" % (domain.strip(), ret)
# 	return ret


from dnsclass.libshorttext import classifier
from dnsclass.libshorttext.classifier import learner
from dnsclass import tokenizer
#
# DNS-Class
#
# Author: Pawel Foremski <pjf@iitis.pl>
# Copyright (C) 2012-2014 IITiS PAN <http://www.iitis.pl/>
# Licensed under GNU GPL v3
#


class mod_dnsclass:
	def __init__(self, model, F=3, T=0.3):
		self.m = classifier.TextModel(model)

		self.tc = self.m.text_converter

# Path: dnsclass/tokenizer.py
# def tokenizer(domain):
# 	ret = []
# 	text = domain.lower().strip()
# 
# 	# parse the domain
# 	r = tldextract.extract(text)
# 
# 	# subdomain: only letters
# 	if len(r.subdomain):
# 		# change digits to 'N'
# 		sd = re.sub('[0-9]', 'N', r.subdomain)
# 		sd = re.sub('(N+)', '\\1.', sd)
# 
# 		for word in re.split("[^a-zN]+", sd):
# 			if len(word) == 0:
# 				continue
# 			elif word.isdigit():
# 				ret.append("N" * len(word))
# 			else:
# 				ret.extend(do_segment(word))
# 
# 	# domain: no dashes
# 	for word in r.domain.split("-"):
# 		ret.extend(do_segment(word))
# 
# 	# TLD: no dots
# 	if P.tok.tlds:
# 		for token in r.tld.split("."):
# 			if len(token) > 0: ret.append(token)
# 
# 	# flow features
# 	if P.tok.flow:
# 		ret.extend(get_flow_features(domain))
# 
# 	if P.tok.max > 0:
# 		ret = ret[-P.tok.max:]
# 
# 	#print "%s -> %s" % (domain.strip(), ret)
# 	return ret


# Path: mod_dnsclass.py
from dnsclass.libshorttext import classifier
from dnsclass.libshorttext.classifier import learner
from dnsclass import tokenizer

#
# DNS-Class
#
# Author: Pawel Foremski <pjf@iitis.pl>
# Copyright (C) 2012-2014 IITiS PAN <http://www.iitis.pl/>
# Licensed under GNU GPL v3
#


class mod_dnsclass:
	def __init__(self, model, F=3, T=0.3):
		self.m = classifier.TextModel(model)

		self.tc = self.m.text_converter

		self.tc.text_prep.tokenizer = tokenizer.tokenizer