考慮到我有:重新排列列表項目,以適應一個函數曲線
- 話
- 點/分表示「簡約」爲每個單詞
- 難度級別的列表每個字的:
例如
>>> words = ['apple', 'pear', 'car', 'man', 'average', 'older', 'values', 'coefficient', 'exponential']
>>> points = ['9999', '9231', '8231', '5123', '4712', '3242', '500', '10', '5']
>>> bins = [0, 0, 0, 0, 1, 1, 1, 2, 2]
目前,單詞列表是由簡單points
訂購。
如果我想將簡單模型化爲「二次曲線」,該怎麼辦?,從最高即一個低點,然後返回到高,即產生一個單詞列表,看起來像這樣與對應點:
['apple', 'pear', 'average', 'coefficient', 'exponential', 'older', 'values', 'apple', 'pear']
我都試過,但它的痛苦瘋狂:
>>> from collections import Counter
>>> Counter(bins)[0]
4
>>> num_easy, num_mid, num_hard = Counter(bins)[0], Counter(bins)[1], Counter(bins)[2]
>>> num_easy
4
>>> easy_words = words[:num_easy]
>>> mid_words = words[num_easy:num_easy+num_mid]
>>> hard_words = words[-num_hard:]
>>> easy_words, mid_words, hard_words
(['apple', 'pear', 'car', 'man'], ['average', 'older', 'values'], ['coefficient', 'exponential'])
>>> easy_1 = easy_words[:int(num_easy/2)]
>>> easy_2 = easy_words[len(easy_1):]
>>> mid_1 = mid_words[:int(num_mid/2)]
>>> mid_2 = mid_words[len(mid_1):]
>>> new_words = easy_1 + mid_1 + hard_words + mid_2 + easy_1
>>> new_words
['apple', 'pear', 'average', 'coefficient', 'exponential', 'older', 'values', 'apple', 'pear']
想象一下沒有。的箱子大於3,或者我想「點」這些詞來適應正弦曲線。
請注意,這並不完全是一個nlp
的問題,也沒有任何與'zipf'分配和創建的東西來匹配或重新排序單詞的排序。
想象一下,您有一個整數列表,您有一個對象(在這種情況下是一個單詞)映射到每個整數,並且您想重新排列對象列表以適合二次曲線。
是'points'無關或爲'bin'值派生的點? – schwobaseggl
箱子是從點派生的。 – alvas
你提到「單詞列表是按照簡單的'points'排序的,」但是'points'在你的例子中看起來沒有排序,因爲它有子序列'5123','3242','4712'。我的理解有什麼不對嗎? – Rohanil