def test_preprocessing(self):
        test_cases = [
            'This sentence should be converted to lowercase.',
            'Twitter url should be removed! http://t.co/ba784',
            'Stopwords like: me myself and i should be removed! :)',
            '#Hashtag mentions will be deleted by preprocessing',
            'Special characters like: $[ ] ( }{-.- :( >_< +.+ should be removed',
            '@mentions to other users should be removed',
            'Year numbers like 2014 will be remain in text'
        ]

        target_results = [
            'sentenc convert lowercas', 'twitter url remov',
            'stopword like remov', 'mention delet preprocess',
            'special charact like remov', 'user remov',
            'year number like 2014 remain text'
        ]

        processed_results = []

        for sentence in test_cases:
            processed_results.append(preprocessing.preprocessing(sentence))

        message = 'Sentences of test cases are processed otherwise than desired'
        self.assertEqual(target_results, processed_results, message)
示例#2
0
targetfn = xray_dir + "/data/LL/" + filenum + ".jpg"
target_arr = filename2arr(targetfn)
# TODO: crop up ROI from target_arr
filenum = "1"
modelfn = xray_dir + "/data/train/L3/" + filenum + ".jpg"
model_arr = filename2arr(modelfn)

"""
###################################
preprocessing
###################################
"""

from src.utils.preprocessing import preprocessing

target = preprocessing(target_arr)
model = preprocessing(model_arr)


"""
###################################
constructing pyramids and use
sliding windows to match features.
###################################
"""
from src.utils.features import sift_descriptor

m_kp, m_des = sift_descriptor(model, show=False)
from skimage.transform import pyramid_gaussian
from src.utils.util import sliding_window
示例#3
0
import os
import sys
import inspect
from src.utils.io import filename2arr
"""
###############################
set env path
###############################
"""
tests_dir =  os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # script directory src/
src_dir = os.path.dirname(tests_dir)
xray_dir = os.path.dirname(src_dir) #xray directory
os.chdir(xray_dir)
sys.path.append(src_dir)
filenum = '1'
targetfn =  xray_dir+ '/data/LL/' + filenum + '.jpg'
target_arr = filename2arr(targetfn)
from src.utils.preprocessing import preprocessing
target = preprocessing(target_arr)
from src.utils.features import sift_descriptor
t_kp, t_des = sift_descriptor(target,show=True)