0
私は簡単なやり方でしようとしている文のリストを与え、リストから構造体(ベクトルのリスト)の文字列を取得します。文字列:Pythonのベクトルリストへのループ
sentence_list = ['I want this',' It hurts','Life is too short as it is' ]
structure = [(1,'I want this. Not that. Right now.'), (2,'When I think about what you are doing, I wonder if you realize the effect you are having on me. It hurts. A lot.'),(3,'Life is too short as it is. In short, she had a cushion job.')]
結果は、ベクトルの位置0の値を持つリストになります。
私の最初の試み:
result = []
for s in sentence_list:
for i in structure:
if s in i[1].split('.'):
result.append(i[0])
ターゲットは、単純なラインでそれを行うための方法でそれを改善することです。
result
[1, 2, 3] # the result is giving the first value of the vector if the string is there..
あなたの質問は正確ですか? –
私は分離プロセスでこの機能を使用していますが、問題なく機能していますが、短期間で改善したいと思います。 – PeCaDe
一方で、あなたは 'split'を必要としません –