1. 程式人生 > >NER 中word數量和tag數量不一致解決方案以及tf.string_split用法

NER 中word數量和tag數量不一致解決方案以及tf.string_split用法

句子中有中文空格
而tf.string_split(source, delimiter=’ ‘)預設是英文空格
導致NER 中word數量和tag數量不一致。

tf.string_split(source, delimiter=' ')

source是一維陣列,用於將一組字串按照delimiter拆分為多個元素,返回值為一個SparseTensor。

假如有兩個字串,source[0]是“hello world”,source[1]是“a b c”,那麼輸出結果如下:

 st.indices: [0, 0; 0, 1; 1, 0; 1, 1; 1, 2]

 st.values
: ['hello', 'world', 'a', 'b', 'c'] st.dense_shape:[2, 3]