Ruby on rails 如何模拟说唱音乐的诠释
我刚开始在一个网站上工作,这个网站将帮助人们了解说唱歌手在谈论什么。用户将看到说唱歌曲的歌词,他们将能够单击某些歌词以查看解释。这是一个屏幕截图(您也可以查看网站本身): (原创歌词审查;查看) 无论如何,我的问题是如何在我的应用程序中建模这些注释。现在,我将歌词和注释存储为一大块HTML格式:Ruby on rails 如何模拟说唱音乐的诠释,ruby-on-rails,activerecord,model,Ruby On Rails,Activerecord,Model,我刚开始在一个网站上工作,这个网站将帮助人们了解说唱歌手在谈论什么。用户将看到说唱歌曲的歌词,他们将能够单击某些歌词以查看解释。这是一个屏幕截图(您也可以查看网站本身): (原创歌词审查;查看) 无论如何,我的问题是如何在我的应用程序中建模这些注释。现在,我将歌词和注释存储为一大块HTML格式: <div class="lyrics"> With the goons I spy <a href="#note1">Stay in tune with ma</
<div class="lyrics">
With the goons I spy
<a href="#note1">Stay in tune with ma</a>
<a href="#note2">She like damn
This the realest since 'Kumbaya'</a>
Kumbayay Killa Cam my lord
</div>
<div class="annotations">
<div id="note1">
"Ma" refers to ladies, generally, and specifically also the woman singing the hook; "Stay in tune" is a musical metaphor: he literally stays in tune with the singer and also in the sense that he has game.
</div>
<div id="note2">
Kumbaya is a campfire singalong.
</div>
</div>
我和那些暴徒一起侦察
Kumbayay Killa Cam大人
“马”一般指淑女,特别是唱钩子的女人;“保持一致”是一个音乐隐喻:他字面上与歌手保持一致,也就是说,他有游戏感。
Kumbaya是新加坡的营火。
然后用这种方法进行处理,输出:
class Song < ActiveRecord::Base
include ActionView::Helpers
def annotated_lyrics
lyrics = read_attribute('annotated_lyrics')
return if lyrics.blank?
require 'hpricot'
doc = Hpricot lyrics
doc.at('.lyrics').inner_html = doc.at('.lyrics').inner_html.strip
doc.search("a[@href^='#note']").set('class', 'tooltip').each do |t|
t.inner_html = t.inner_html.strip
end
doc.search("div[@id^='note']").set('class', 'annotation').each do |a|
a.inner_html = auto_link(a.inner_html.strip, :all, :target => '_blank')
end
simple_format doc.html.strip
end
end
classsong“\u blank”)
结束
简单格式doc.html.strip
结束
结束
剩下的我用jQuery和神奇的插件做
这对于显示来说很好,但是由于我的应用程序不知道注释和歌词之间的关系,所以很难(比如)添加一个接口来内联更新单个注释(或者根本不知道)
另一方面,我真的不知道在ActiveRecord中表示这一点的最佳方式。我想一首歌可能有“很多”注释,但我如何表示注释了哪些歌词?我可以存储起始词和结束词索引,但这似乎很痛苦,而且对歌词中的细微变化也很敏感。你的第一反应是与一首有许多注释的歌曲建立关联,这肯定会奏效。存储开始和停止注释索引的两种可能方法:
您可能对语言学家非常熟悉的注释工具的(xml)数据模型感兴趣:例如MMAX2和Callisto。这些很容易转换为数据库模型。至于链接注释和歌词,您可以有几种方法:
像这样呈现歌词怎么样(感谢人民冠军) 是来自德克萨斯州休斯顿的[谷物夹钳][1] 那个酒吧,西帕,那个酒吧,没有丛 我直接从那[游泳馆][2] 其中G.Dash填写所有支票 所以[检查脖子,检查手腕][3] 我从头到脚都是巴拉 [1] 指豪华车常见的木纹方向盘 [2] Swisha House是Paul Wall records的唱片公司 [3] “看我的手表和项链,因为它们很贵” 这只是一个想法,我受到了在这个网站上添加评论的标记的启发 因此,对于数据库,创建Lyric、LyricLine和Annotation表。注释具有LyricLineId、StartChar和EndChar值以及含义或描述字段。LyricLines是每行的文本,通过LyricId与歌词实体相关。歌词存储歌曲信息,语言信息,无论什么 这种格式应该很容易从数据库中生成,并且比XML更易于“人类阅读”,并且可以就地编辑,因此在开发整个UI之前,您可以更轻松地对其进行测试
我有这个问题,并期待着观看网站的进展。有趣的工作 XML也是一个很好的模型
<song>
<title>...</title>
<lyrics>
<verse>
<line>Well it's that <dd>grain grippa</dd><dt>Referring to the wood grain steering wheel common to luxury cars</dt> from Houston, Tex</line>
<line>That bar sippa, that bar no plex</line>
<line>I'm straight up outta that <dd>Swishahouse</dd><dt>Swisha House is the record label Paul Wall records for</dt></line>
<line>Where G. Dash write all the checks</line>
<line>So <dd>check the neck, check the wrist</dd><dt>"Look at my watch and necklace because they are expensive"</dt></line>
<line>I'm balla status from head to toe</line>
</verse>
<chorus>
<line>...</line>
</chorus>
<verse>...</verse>
<repeat-chorus/>
</lyrics>
</song>
...
嗯,正是这种谷物夹钳被转移到了木质谷物方向盘上,这是德克萨斯州休斯顿的豪华汽车所共有的
那个酒吧,西帕,那个酒吧,没有丛
我直接离开了Swishahouse Swisha House是Paul Wall records的唱片公司
其中G.Dash填写所有支票
所以检查脖子,检查手腕“看看我的手表和项链,因为它们很贵”
我从头到脚都是巴拉
...
...
很容易编辑和更新。为它创建UI可能并不困难
<song>
<title>...</title>
<lyrics>
<verse>
<line>Well it's that <dd>grain grippa</dd><dt>Referring to the wood grain steering wheel common to luxury cars</dt> from Houston, Tex</line>
<line>That bar sippa, that bar no plex</line>
<line>I'm straight up outta that <dd>Swishahouse</dd><dt>Swisha House is the record label Paul Wall records for</dt></line>
<line>Where G. Dash write all the checks</line>
<line>So <dd>check the neck, check the wrist</dd><dt>"Look at my watch and necklace because they are expensive"</dt></line>
<line>I'm balla status from head to toe</line>
</verse>
<chorus>
<line>...</line>
</chorus>
<verse>...</verse>
<repeat-chorus/>
</lyrics>
</song>