フィルターのクリア

Clustering sequences of data with different lengths using ngrams.

2 ビュー (過去 30 日間)
SOPAE YI
SOPAE YI 2020 年 3 月 16 日
編集済み: SOPAE YI 2020 年 3 月 21 日
I am trying to cluster sequences of data that have different lengths.
I am treating the element of my sequence as a word. In other words, a list is a sentence.
To be able to achive this I am thinking of extracting ngrams like my code below.
However, I keep getting following error message:
“Arguments to IMPORT must either end with ".*" or else specify a fully qualified class name: "nltk" fails this test.”
1. How can I solve this error?
2. Am I going toward right direction?
I am a novice Matlab user and I hope I am not asking too basic questions.
Following is my Matlab code:
-------------------------------------------------------
A = [1.2,1.5; 2.4,0.5; 3.2,1.5];
B = [1.0,1.0; 2.0,0; 3.0,1.0; 4.0,0.5];
C = [1.1,1.2; 2.2,1.3; 3.3,1.5];
D = [1.3,1.3; 2.1,1.4; 3.2,1.7; 4.3, 2.0];
E = [1.3,1.8; 2.3,0.4; 3.1,1.6; 4.3,0.8];
figure()
plot(A(:,1), A(:,2)) % first column is the time-values
hold on;
plot(B(:,1), B(:,2))
hold on;
plot(E(:,1), E(:,2))
figure()
plot(C(:,1), C(:,2)) % first column is the time-values
hold on;
plot(D(:,1), D(:,2))
import nltk
from nltk import ngrams
aa = A(:)'
bb = B(:)'
cc = C(:)'
dd = D(:)'
ee = E(:)'
bb = list()
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in aa])))
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in bb])))
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in cc])))
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in dd])))
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in ee])))
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(bb)
X.toarray()

回答 (1 件)

Prabhanjan Mentla
Prabhanjan Mentla 2020 年 3 月 20 日
NLTK is not supported in MATLAB however one can run python functions in MATLAB by following this. There is also text analytics toolbox in MATLAB which deals text data.
  1 件のコメント
SOPAE YI
SOPAE YI 2020 年 3 月 20 日
編集済み: SOPAE YI 2020 年 3 月 21 日
Thank you so much for crrecting me, sir.
My data is not text.
I am working on spoken sentence (or an utterance) especialy, pitch of a sentence.
Can I use NLTK to cluster sequences of (pitch) data that have different lengths?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInstall Products についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by