TextTokenizer Example: Japanese Tokenization | Teradata Vantage - TextTokenizer Example: Japanese Tokenization - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantage™

To run queries that include non-Latin characters, you must set SESSION CHARSET to UTF-8. For more information, see Basic Teradata® Query Reference, B035-2414.

Input

Input Table: jp_input
id txt
t1 総務省は28日、全国の主要51市を対象に2013年の物価水準を比較した消費者物価地域差指数を発表した。
t2 ソチ五輪6位の浅田真央(23)=中京大=はSP女子世界最高の78・66点で首位に立った。
Dict: jp_dict
word
地域差指数,地域差指数,チイキサシスウ,カスタム名詞

User dictionary file user_dict_jp.txt:

SP女子,SP女子,エスピージョシ,カスタム名詞

SQL Call 1

SELECT * FROM TextTokenizer (
  ON jp_input PARTITION BY ANY
  ON jp_dict AS dict DIMENSION
  USING
  InputLanguage ('jp')
  OutputByWord ('false')
  Accumulate ('id')
  TextColumn ('txt')
  UserDictionaryFile ('user_dict_jp.txt')
) AS dt ORDER BY id;

Output 1

 id |                                                            token                                                            
----+-----------------------------------------------------------------------------------------------------------------------------
 t1 | 総務省/は/28/日/、/全国/の/主要/51/市/を/対象/に/2013/年/の/物価水準/を/比較/し/た/消費者/物/価地域差/指数/を/発表/し/た/。
 t2 | ソチ五輪/6/位/の/浅田真央/(/2/3/)/=/中京大/=/は/S/P/女子世界最高/の/7/8/・/6/6/点/で/首位/に/立っ/た/。
(2 rows)

SQL Call 2

SELECT * FROM TextTokenizer (
  ON jp_input PARTITION BY ANY
  ON jp_dict AS dict DIMENSION
  USING
  InputLanguage ('jp')
  OutputByWord ('true')
  Accumulate ('id')
  TextColumn ('txt')
  UserDictionaryFile ('user_dict_jp.txt')
) AS dt ORDER BY id;

Output 2

 id sn token  
 -- -- ------ 
 t1  1 総務省   
 t1  2 は     
 t1  3 28    
 t1  4 日     
 t1  5 、     
 t1  6 全国    
 t1  7 の     
 t1  8 主要    
 t1  9 51    
 t1 10 市     
 t1 11 を     
 t1 12 対象    
 t1 13 に     
 t1 14 2013  
 t1 15 年     
 t1 16 の     
 t1 17 物価水準  
 t1 18 を     
 t1 19 比較    
 t1 20 し     
 t1 21 た     
 t1 22 消費者   
 t1 23 物     
 t1 24 価     
 t1 25 地域差指数 
 t1 26 を     
 t1 27 発表    
 t1 28 し     
 t1 29 た     
 t1 30 。     
 t2  1 ソチ五輪  
 t2  2 6     
 t2  3 位     
 t2  4 の     
 t2  5 浅田真央  
 t2  6 (     
 t2  7 2     
 t2  8 3     
 t2  9 )     
 t2 10 =     
 t2 11 中京大   
 t2 12 =     
 t2 13 は     
 t2 14 S     
 t2 15 P     
 t2 16 女子世界最高
 t2 17 の     
 t2 18 7     
 t2 19 8     
 t2 20 ・     
 t2 21 6     
 t2 22 6     
 t2 23 点     
 t2 24 で     
 t2 25 首位    
 t2 26 に     
 t2 27 立っ    
 t2 28 た     
 t2 29 。

Download a zip file of all examples and a SQL script file that creates their input tables.