10.1 歌詞頻率與歌詞雲

對於同樣的歌手/樂團, 若搜集其一系列的專輯之後, 有一定的機會可以發現其用詞會有一定的傾象, 這部分就可以透過NLP來看, 下面這隻程式會去處理五月天(中文)跟Aimer(英文)的幾首歌詞, 並且分析其用詞頻率最高的前幾名, 然後透過歌詞雲顯示出來.

歌詞內容(MayDay.json):

{
  "步步": "空無一人的大街 闖入無人婚紗店 為你披上雪白誓言 世界已灰飛煙滅 而愛矗立高樓間 你是真的或是我的 幻覺 時光遺忘的背面 獨坐殘破的臺階 哪個亂世沒有離別 天空和我的中間 只剩傾盆的思念 如果相識 不能相戀 是不是還不如擦肩 在失去你的風景裡面 你卻佔據了每一條街 一步步曾經 一步步想念 在腳下蔓延 在充滿你的回憶裡面 我獨自流浪海角天邊 一步步走過 當時心願 格林威治大鐘前 歸零超載的傷悲 揹著我和我的諾言 一起計畫的路線 對照孤單的旅店 一聲晚安 卻又喚醒 淚腺 時代廣場的跨年 頤和花季的藍天 數著願望在你指尖 當時有多少心願 就有多少的殘缺 如果後悔 不能後退 是不是就只能往前 在失去你的風景裡面 你卻佔據了每一條街 一步步曾經 一步步想念 在腳下蔓延 在充滿你的回憶裡面 我獨自流浪海角天邊 一步步走過 當時心願 生如浮萍般卑微 愛卻蒼穹般壯烈 我要為你爬上最險山嶽 走過最崎嶇眷戀 一步一步穿越 在失去你的風景裡面 你卻佔據了整個世界 每一張相片 每一個房間 每一滴眼淚 在充滿你的回憶裡面 我獨自一人和眼淚周旋 一步步走向 孤單的明天 也許在來生的某個明天 我們能再寫新的情節 一步步完成 當時心願 一步步完成 最美殘缺",
  "擁抱": "脫下長日的假面 奔向夢幻的疆界 南瓜馬車的午夜 換上童話的玻璃鞋 讓我享受這感覺 我是孤傲的薔薇 讓我品嚐這滋味 紛亂世界的不瞭解 昨天太近 明天太遠 默默聆聽那黑夜 晚風吻盡 荷花葉 任我醉倒在池邊 等你清楚看見我的美 月光曬乾眼淚 哪一個人 愛我 將我的手 緊握 抱緊我 吻我 喔 愛 別走 隱藏自己的疲倦 表達自己的狼狽 放縱自己的狂野 找尋自己的明天 向你要求的誓言 就算是你的謊言 我需要愛的慰藉 就算那愛已如潮水",
  "傷心的人別聽慢歌": "你哭的太累了 你傷的太深了 你愛的 太傻了 你哭的就像 是末日要來了 OH~ OH~ 所以你聽慢歌 很慢很慢的歌 聽得 心如刀割 是不是應該 換一種節奏了 OH~ OH~ 不要再問 誰是對的 誰是錯的 誰是誰非 誰又虧欠誰了 反正錯了 反正輸了 反正自己 陪自己快樂 我不管 你是誰的 誰是你的 我是我的 讓心跳 動次 動次 動次 動次 感覺活著 我不管 站著坐著 躺著趴著 都要快樂 讓音樂 動次 動次 動次 動次 快要聾了 不管了 不想了 不等了 不要不快樂 傷心的人 別聽慢歌 人生分分合合 愛情拉拉扯扯 一路 曲曲折折 我還是期待 明日的新景色 OH~ OH~ 憤青都釋懷了 光棍都戀愛了 悲劇 都圓滿了 每一段爭執 都飛出和平鴿 OH~ OH~ 不要再問 誰是對的 誰是錯的 誰是誰非 誰又虧欠誰了 反正錯了 反正輸了 反正自己 陪自己快樂 我不管 你是誰的 誰是你的 我是我的 讓心跳 動次 動次 動次 動次 感覺活著 我不管 站著坐著 躺著趴著 都要快樂 讓音樂 動次 動次 動次 動次 快要聾了 不管了 不想了 不等了 不要不快樂 傷心的人 別聽慢歌 我不管 你是誰的 誰是你的 我是我的 讓心跳 動次 動次 動次 動次 感覺活著 我不管 站著坐著 躺著趴著 都要快樂 讓音樂 動次 動次 動次 動次 快要聾了 不管了 不想了 不等了 此時和此刻 不得不去 貫徹快樂 不管了 不想了 不等了 不要不快樂 傷心的人 別聽慢歌",
  "洋蔥": "如果你眼神能夠為我 片刻的降臨 如果你能聽到 心碎的聲音 沉默的守護著你 沉默的等奇蹟 沉默的讓自己 像是空氣 大家都吃著聊著笑著 今晚多開心 最角落裡的我 笑得多合群 盤底的洋蔥像我 永遠是調味品 偷偷的看著你 偷偷的隱藏著自己 如果你願意一層一層一層 的剝開我的心 你會發現 你會訝異 你是我 最壓抑 最深處的秘密 如果你願意一層一層一層 的剝開我的心 你會鼻酸 你會流淚 只要你能 聽到我 看到我的全心全意 聽妳說妳和妳的他們 曖昧的空氣 我和我的絕望 裝得很風趣 我就像一顆洋蔥 永遠是配角戲 多希望能與妳 有一秒 專屬的劇情",
  "乾杯": "會不會 有一天 時間真的能倒退 退回 你的我的 回不去的 悠悠的歲月 也許會 有一天 世界真的有終點 也要和你舉起回憶釀的甜 和你再乾一杯 如果說 要我選出 代表青春 那個畫面 浮現了 那滴眼淚 那片藍天 那年畢業 那一張 邊哭邊笑 還要擁抱 是你的臉 想起來 可愛可憐 可歌可泣 可是多懷念 懷念總是 突然懷念 不談條件 當回憶 衝破考卷 衝出歲月 在我眼前 我和你 留著汗水 喝著汽水 在操場邊 說好了 無論如何 一起走到 未來的世界 現在就是 那個未來 那個世界 為什麼 你的身邊 我的身邊 不是同一邊 友情曾像 諾亞方舟 堅強誓言 只是我 望著海面 等著永遠 模糊了視線 會不會 有一天 時間真的能倒退 退回 你的我的 回不去的 悠悠的歲月 也許會 有一天 世界真的有終點 也要和你舉起回憶釀的甜 和你再乾一杯 這些年 買了四輪 買了手錶 買了單眼 卻發現 追不到的 停不了的 還是那些 人生是 只有認命 只能宿命 只好宿醉 只剩下 高的笑點 低的哭點 卻沒成熟點 成熟就是 幻想幻滅 一場磨鍊 為什麼 只有夢想 越磨越小 小到不見 有時候 好想流淚 好想流淚 卻沒眼淚 期待會 你會不會 他會不會 開個同學會 他在等你 你在等我 我在等誰 又是誰 孩子沒睡 電話沒電 心情沒準備 天空不斷 黑了又亮 亮了又黑 那光陰 滄海桑田 遠走高飛 再沒力氣追 會不會 有一天 時間真的能倒退 退回 你的我的 回不去的 悠悠的歲月 也許會 有一天 世界真的有終點 也要和你舉起回憶釀的甜 和你再乾一杯 會不會 有一天 時間真的能倒退 退回 你的我的 回不去的 悠悠的歲月 也許會 有一天 世界真的有終點 也要和你舉起回憶釀的甜 和你再乾一杯 終究會 有一天 我們都變成昨天 是你 陪我走過 一生一回 匆匆的人間 有一天 就是今天 今天就是有一天 說出一直沒說 對你的感謝 和你再乾一杯 再乾一杯永遠 喝了就能萬歲 歲歲和年年 時間都停了 他們都回來了 懷念的人阿 等你的來到",
  "入陣曲": "當一座城牆 只為了阻擋 所有自由渴望 當一份信仰 再不能抵抗 遍地戰亂饑荒 蘭陵撩亂茫 天地離人忘 無畏孤塚葬 只怕蒼生殤 夜未央 天未亮 我在倖存的沙場 只盼望 此生再 奔向思念的臉龐 淚未乾 心未涼 是什麼依然在滾燙 入陣曲 伴我無悔的狂妄 當一份真相 隻手能隱藏 直到人們遺忘 寫一頁莽撞 我們的篇章 曾經如此輝煌 丹青千秋釀 一醉解愁腸 無悔少年枉 只願壯志狂 夜未央 天未亮 我在倖存的沙場 只盼望 此生再 奔向思念的臉龐 淚未乾 心未涼 是什麼依然在滾燙 入陣曲 伴我無悔的狂妄 忘不記 原不諒 憤恨無疆 肅不清 除不盡 魑魅魍魎 幼無糧 民無房 誰在分贓 千年後 你我都 仍被豢養 夜未央 天未亮 我在倖存的沙場 只盼望 此生再 奔向思念的臉龐 淚未乾 心未涼 是什麼依然在滾燙 入陣曲 四面楚歌誰獨唱 夜已央 天已亮 白晝隱沒了星光 像我們 都終將 葬身歷史的洪荒 當世人 都遺忘 我血液曾為誰滾燙 入陣曲 伴我無悔的狂妄 入陣去 只因 恨鐵不成鋼",
  "倔強": "當 我和世界不一樣 那就讓我不一樣 堅持對我來說 就是以剛克剛 我 如果對自己妥協 如果對自己說謊 即使別人原諒 我也不能原諒 最美的願望 一定最瘋狂 我就是我自己的神 在我活的地方 我和我最後的倔強 握緊雙手絕對不放 下一站是不是天堂 就算失望不能絕望 我和我驕傲的倔強 我在風中大聲的唱 這一次為自己瘋狂 就這一次 我和我的倔強 對 愛我的人別緊張 我的固執很善良 我的手越骯髒 眼神越是發光 你 不在乎我的過往 看到了我的翅膀 你說被火燒過 才能出現鳳凰 逆風的方向 更適合飛翔 我不怕千萬人阻擋 只怕自己投降 我和我最後的倔強 握緊雙手絕對不放 下一站是不是天堂 就算失望不能絕望 我和我驕傲的倔強 我在風中大聲的唱 這一次為自己瘋狂 就這一次 我和我的倔強 我和我最後的倔強 握緊雙手絕對不放 下一站是不是天堂 就算失望不能絕望 我和我驕傲的倔強 我在風中大聲的唱 這一次為自己瘋狂 就這一次 我和我的倔強 就這一次 讓我大聲唱 啦啦啦...就算失望 不能絕望 啦啦啦...就這一次 我和我的倔強",
  "突然好想你": "最怕空氣突然安靜 最怕朋友突然的關心 最怕回憶 突然翻滾絞痛著不平息 最怕突然 聽到你的消息 想念如果會有聲音 不願那是悲傷的哭泣 事到如今 終於讓自己屬於我自己 只剩眼淚 還騙不過自己 突然好想你 你會在哪裡 過得快樂或委屈 突然好想你 突然鋒利的回憶 突然模糊的眼睛 我們像一首最美麗的歌曲 變成兩部悲傷的電影 為什麼你 帶我走過最難忘的旅行 然後留下 最痛的紀念品 我們 那麼甜那麼美那麼相信 那麼瘋那麼熱烈的曾經 為何我們還是要奔向各自的幸福和遺憾中老去 突然好想你 你會在哪裡 過得快樂或委屈 突然好想你 突然鋒利的回憶 突然模糊的眼睛 最怕空氣突然安靜 最怕朋友突然的關心 最怕回憶 突然翻滾絞痛著不平息 最怕突然 聽到你的消息 最怕此生 已經決心自己過沒有你 卻又突然 聽到你的消息",
  "戀愛ing": "陪你熬夜 聊天到爆肝也沒關係 陪你逛街 逛成扁平足也沒關係 超感謝你 讓我重生 整個O-R-Z 讓我重新認識 L-O-V-E! (L-O-V-E!L-OVE!) 戀愛ing happy ing 心情就像是 坐上一台噴射機 戀愛ing 改變 ing 改變了黃昏 黎明 有你 都心跳到不行 你是空氣 但是好聞勝過了空氣 你是陽光 但是卻能照進半夜裡 水能載舟 也能煮粥 餵飽了生命 你就是維他命 L-O-V-E! (L-O-V-E!L-OVE!) 未來某年某月 某日某時 某分某秒 某人某地 某種永遠的心情 不會忘記此刻 L-O-V-E! (L-O-V-E!L-O-V-E! L-O-V-E!L-OVE!)",
  "離開地球表面": "丟掉手錶 丟外套 丟掉背包 再丟嘮叨 丟掉電視 丟電腦 丟掉大腦 再丟煩惱 衝啥大 衝啥小 衝啥都有人唱反調 恨的多 愛的少 只想越跳越瘋 越跳越高 把地球甩掉 一顆心噗通噗通的狂跳 一瞬間煩惱煩惱煩惱全忘掉 我再也不要 再也不要 委屈自己一秒 一顆心噗通噗通的狂跳 一瞬間煩惱煩惱煩惱全忘掉 我甩掉地球 地球甩掉 只要越跳越高 丟掉手錶 丟外套 丟掉背包 再丟嘮叨 丟掉電視 丟電腦 丟掉大腦 再丟煩惱 野心大 膽子小 跳舞還要靠別人教 恨得多 愛的少 只想 越跳越瘋 越跳越高 把地球甩掉 一顆心噗通噗通的狂跳 一瞬間煩惱煩惱煩惱全忘掉 我再也不要 再也不要 委屈自己一秒 一顆心噗通噗通的狂跳 一瞬間煩惱煩惱煩惱全忘掉 我甩掉地球 地球甩掉 只要越跳越高 我甩掉地球 地球甩掉 只要越跳越高 Come on(jump) 一顆心噗通噗通的狂跳 一瞬間煩惱煩惱煩惱全忘掉 我再也不要 再也不要 委屈自己一秒 一顆心噗通噗通的狂跳 一瞬間煩惱煩惱煩惱全忘掉 我甩掉地球 地球甩掉 只要越跳越高 我甩掉地球 地球甩掉 只要越跳越高 Come on(jump)",
  "如果我們不曾相遇": "如果我們不曾相遇 我會是在哪裡? 如果我們從不曾相識 不存在這首歌曲 每秒都活著 每秒都死去 每秒都問著自己 誰不曾找尋 誰不曾懷疑 茫茫人生奔向何地? 那一天 那一刻 那個場景 你出現在我生命 從此後 從人生 重新定義 從我故事裡甦醒 如果我們不曾相遇 你又會在哪裡? 如果我們從不曾相識 人間又如何運行? 曬傷的脫皮 意外的雪景 與你相依的四季 蒼狗又白雲 身旁有了你 匆匆輪迴又有何懼? 那一天 那一刻 那個場景 你出現在我生命 每一分 每一秒 每個表情 故事都充滿驚奇 偶然與巧合 舞動了蝶翼 誰的心頭風起 前仆而後繼 萬千人追尋 荒漠唯一菩提 是擦身相遇 或擦肩而去 命運猶如險棋 無數時間線 無盡可能性 終於交織向你 那一天 那一刻 那個場景 你出現在我生命 未知的 未來裡 未定機率 然而此刻擁有你 某一天 某一刻 某次呼吸 我們終將再分離 而我的 自傳裡 曾經有你 沒有遺憾的詩句 詩句裡 充滿感激 如果我們不曾相遇 我會是在哪裡? 如果我們從不曾相識 不存在這首歌曲",
  "任意門": "行天宮後 二樓前座 那個小房間 日夜排練 我們聽著唱片 唱片來自 那唱片行 叫 搖滾萬歲 和駐唱小店 都在士林邊緣 我們都想 離開這邊 追尋另一邊 苗栗孩子 搬到台北求學 水手之子 重考擠進 信義路校園 和高雄學弟 當時看不順眼 我們曾走過 無數地方 和無盡歲月 搭著肩環遊 無法遺忘 的光輝世界 那年我們都 衝出南陽街 任意門通向了音樂 任意門外我們都任意的飛 是自由的滋味 七號公園 初次登場 是那個三月 自強隧道 漫長的像永遠 椰林大道 誰放棄了 律師的家業 頭也不回地 越來越唱越遠 外灘風光 躍出課本 是那麼新鮮 從回民街 再飛到尖沙咀 男兒立志 成名在望 不論多遙遠 一離開台北 卻又想念台北 我們曾走過 無數地方 和無盡歲月 搭著肩環遊 無法遺忘 的光輝世界 無名高地到 鳥巢的十年 一路鋪滿汗水淚水 任意門外我們用盡全力飛 管他有多遙遠 我們曾走過 無數地方 和無盡歲月 搭著肩環遊 無法遺忘 的光輝世界 那個唱片行 何時已不見? 是誰說過 搖滾萬歲 ? 任意門裡我們偶爾也疲倦 平凡的我們 也將回到 平凡的世界 生活中充滿 孩子哭聲 柴米和油鹽 曾和你走過 麥迪遜花園 任意門外繞一大圈 你問我全世界是哪裡最美? 答案是 你身邊 只要是你身邊 行天宮後 二樓前座 那個小房間 獸媽準備 宵夜是大雞腿 每個夢都 像任意門 往不同世界 而你的故事 現在正是起點"
}

歌詞內容(Aimer-eng.json):

{
  "Next 2 U": "Have a little break We're running through the lights, out of breath Our will made us right here, didn't it so? Is this feeling fake? We're happier far than we've ever known Maybe we'll make it finally I had to be the Queen anywhere I went, anytime I talked It's been a while since I've not pretended to be a grownup Cuz you make my makeup's off Take off my dress and crown Then I can fall sound asleep We had paced back and forth all that time You do never know that love I felt I can be an ordinary girl While I've been right next to you Have I still been cared? We've been together after all these days No much time talking over day and night When I feel your stare My heart's like flying high above the phase Maybe we'll overcome the scars You want me to be free Free from legacies, free like meteors That's why I cried since I've been attended to so kindly You're who make my makeup's off Take off my heels and gown Then I can breathe in so deep We had paced back and forth all that time You do never know that love I felt I can be an ordinary girl While I've been right next to you Won't you promise me? No matter how far apart Always keep thinking of me We must be heart to heart Baby...twinkle, twinkle! My little fortunate star Are you with me? Take off my dress and crown Then I can fall sound asleep We had paced back and forth all that time You do never know that love I felt I can see the dream of you and I Take off my heels and gown Then I can breathe in so deep We had paced back and forth all that time You do never know that love I felt I can be an ordinary girl While I've been right next to you",
  "StarRingChild -English ver.-": "Think in about the moment while we'd strayed from the right path We've might misplaced the seed of smile but we were not spontaneous There's a lump in my throat I ain't ready to recover it Was too young to grasp I thought it must be no business of mine They ought to try rewriting our life like as she has been done We've struggled to break loose from this metempsychosis Got mature too much to hear our voice within Star Ring Child Give me your hands to see What noble galaxy That we've been fighting for I'm by your side I'll give you all of me To track who we used to be While the stars sync with my heart beat The story will go on I'm gonna lose my reasons while I'd sink in deep complacence Without your hope, I can't reboot from myself in repentance My body's hurt and shaking Even now while we are in freedom I receive the truth whenever I catch your footsteps and rhythm We survive and stand on here at the huge sacrifice of their life We've struggled to break loose from this metempsychosis But we'd chosen then to play out such a roll When the sun hides in the cosmic clouds Under the dark night shrouds The silence will wraple us You're by my side You share the fate with me I could let my heart be free Now, I'll wake from my delusion Star Ring Child Give me your hands to see What noble galaxy That we've been fighting for I'm by your side I'll give you all of me To track who we used to be While the stars sync with my heart beat The story will go on Soar beyond the noise We'll live in harmony And strive against the destiny We're charging up enough to make our brand new flow Standing back now from all sorts of agony There's no meaning to seek any reason Everything starts off in a second Right behind the worst The daybreak was reserved For the people who're confined We're charging up enough to make our brand new flow Standing back now from all sorts of agony There's no meaning to seek any reason Everything starts shining so bright to draw the new age",
  "A LETTER": "All my friends have gone away I need myself to sing this song But you always passed away. But It seems to be o.k. All my wish and powers They would take me to the gate Should I really find my problem? Do I really want to know about? I'm writing a letter for me Is there anything I would say?  I don't have to throw my life away Everything goes wrong― ―to turn into the way of life This could take so long to find the way All those people cry in vain Now I see the light in pain I can find the way of love  You don't have to throw your life away  Everything goes wrong― ―to turn into the way of life This could take so long to find the way All those people cry in vain Now you see the light in pain You can find the way of love  All my friends have gone away I need myself to sing this song But you always passed away. But It seems to be o.k. All my wish and powers They would take me to the gate Should I really find my problem? Do I really want to know about? I'm writing a letter for me Is there anything I would say?  Say good bye into the perfect sky But it's your love can be the real life line",
  "REMIND YOU": "Who passed away each one in the fight There was no doubt we started for pride And your grief stays too long Then the war brings it worst Tell me why? we're stuck in this deep black hole  Count it from me No one knows our day'll be Don't be afraid everyone will reach for last Nothing but without you I can not go on Now I'm touching to the core of the light Sharing with you for a while tiny moment All I can give you for some help Just reminds you  Who passed away each one for the fight There was no doubt we dreamt of the ride And your grief stays too long Then the war brings it worst Now we searching for under the hope with you  Count it from me My heart beat get slower  Don't be surprise everyone will die at last Nothing but without you I can not go on Now I'm looking for the place to belong  Past to the present Slave to the power  Into my brain From top to the bottom all over my skin All of me is lashed with high fever Don't say just yes, Oh no matrer what they have made up All the things must fix them by your self  Past to the present Slave to the power But is our Bravely from desire Quest for the future",
  "RE:I AM -English ver.-": "Please hear me I want to tell you Please sing to me I wanna hear your voice  I wonder why we have to kill each other so long? And We've been through the fights And now we will have to sacrifice I can't ignore this matter I can't think of you for now All of my life It's been up and down for me  It seems our road through life hasn't got any better And We need to find the way We will put an end to this I've been hold these feeling everyday heartache when I think of you I need some help I can rely on you  Many lives were lost but we're still alive We can make ourself better But I don't cry for destiny We must find out how to live and die Truth is never everything that you can see  I'll never let you go You are the only one Forever but it's come to own me For anyone can hold my hand Oh you can trust in me Could hear the siren And the sky is crying loud as ever I can sense the vibe between you and me  I wonder why we have to kill each other so long? And We've been through the fights Now we will have to sacrifice Can I ignore this situation? I can't think of you for now all of my life It's been up and down for me   Many lives were lost but we're still alive We can make ourself better But I don't cry for destiny We must find out how to live and die Truth is never everything that you can see  I'll never let you go You are the only one Forever but it's come to own me For anyone can hold my hand Oh you can trust in me Could hear the siren And the sky is crying loud as ever I can sense the vibe between you and me  freezing cold shatters my sorrow scorching sand puts it together again freezing cold shatters my sorrow scorching sand puts it together again  Oh It's more than anything That you are on my side The hands of time won't stop I wonder where you are Then it's more than everything That you are the best for me All of our life Every piece Heaven's peace  We'll never forget you You are the only one Forever but it's come to own me For anyone can hold my hand Oh you can trust in me Could hear the siren And the sky is crying loud as ever I can feel this bond between you and me  Please hear me I want to tell you Please sing to me I wanna hear your voice",
  "But still...": "There was a pity boy lapsed into apathy and doubt But he got a chance to change Somehow you bumped into his range He's just a normal boy longing for happiness And now you see what I mean In fact, He was who I used to be I was reborn with your sacred love  I don't know what to do in my mind But I believe in your mighty heart Whenever I lose control, your soul always brings me back Even if I got lost or went blind Monoceros, take me to the Seventh star Open the door to the peaceful world  I was a tiny boy, vanished in the mazes of stardust Why do we gotta spend our lives only for hurting each other? I could just cry for them cursed at, I'm powerless What worth is this fighting for? We'll never find out anymore  No one knows, even the Gods above  I can't draw any schemes of my mind But I believe in your mighty heart Whenever I lose control, your soul always brings me back Even if I got lost or went blind Monoceros, take me to the Seventh star Open the door to the peaceful world  Do you see the lights of life? They are ready to shine I do swear, I'll keep telling them “But still...” forever Because you bring me to life I could fly toward your sign through the jeweled universe  I don't know what to do in my mind But I believe in your mighty heart Whenever I lose control, your soul always brings me back Even if I got lost or went blind Monoceros, take me to the Seventh star Open the door to the peaceful world"
}

原始碼:

import json
import jieba
import matplotlib.pyplot as plt
from collections import Counter
from wordcloud import WordCloud


MAYDAY_LYRICS_LIB = 'MayDay.json'
AIMER_ENGLISH_LIB = 'Aimer-eng.json'


def analyze_lyrics(lyrics_file):
    print('Analyzing %s...' % lyrics_file)
    with open('./lyrics_lib/%s' % lyrics_file, 'r', encoding='UTF-8') as lyrics:
        data = json.load(lyrics)
    words = list()
    for song in data.values():
        words += [word for word in jieba.cut(song) if word.split() and len(word) > 1]

    counter = Counter(words)
    print(counter.most_common(10))

    word_cloud = WordCloud(font_path='./fonts/NotoSansMonoCJKtc-Regular.otf').generate(' '.join(words))
    plt.imshow(word_cloud)
    plt.axis('off')
    plt.show()
    print('Analyze finished.')


if __name__ == '__main__':
    jieba.set_dictionary('./dictionary/dict.txt.big')
    analyze_lyrics(MAYDAY_LYRICS_LIB)
    analyze_lyrics(AIMER_ENGLISH_LIB)

輸出如下:

Analyzing MayDay.json...
[('自己', 25), ('我們', 24), ('動次', 24), ('煩惱', 20), ('突然', 18), ('世界', 15), ('如果', 15), ('一天', 15), ('回憶', 12), ('地球', 12)]
Analyze finished.
Analyzing Aimer-eng.json...
[('the', 77), ('to', 72), ('you', 42), ('me', 40), ('my', 33), ('can', 33), ('of', 27), ('We', 25), ('in', 25), ('and', 23)]
Analyze finished.

Process finished with exit code 0

歌詞雲:

原始碼點我

Last updated