TAG in Pattern Recognition with Applications