分裂我有2列:JavaScript的 - 比較2個陣列與空間
sentence []
keywords []
例如sentence []
:
sentence [0] = "my car is blue"
sentence [1] = "the dog is sleeping"
sentence [2] = "I am in the kitchen"
sentence [3] = "How are you"
和keywords []
:
keywords [0] = "my"
keywords [1] = " "
keywords [2] = "car"
keywords [3] = " "
keywords [4] = "is"
keywords [5] = " "
keywords [6] = "blue"
keywords [7] = "gghcxfkjc"
keywords [8] = "532jj"
keywords [9] = "How"
keywords [10] = " "
keywords [11] = "are"
keywords [12] = " "
keywords [13] = "you"
keywords [14] = " "
keywords [15] = "tech"
因此,舉例來說,我需要檢測到「我的車是藍色的」和「 你好嗎「在keywords
陣列。 請注意,關鍵字[]遵循句子的順序。
如何才能繼續比較和檢測這種信息?
[編輯]我需要知道的關鍵字匹配每個詞的索引[] 例如0,1,2,3,4的第一句話9,10,11,12,13爲另一句話。
爲了澄清,句子中的每個單詞都必須匹配關鍵字才能通過真相測試? – 2014-10-17 10:10:32
可能通過遍歷數組,而有一個標誌爲true或false – devqon 2014-10-17 10:10:38
'keywords.join('')。indexOf('sentence-to-check')!== -1'? – techfoobar 2014-10-17 10:11:31