Closed SylvainDe closed 4 years ago
Code to collect data grouped by similar values to try to see a pattern. Resulting analysis is at the end.
diff --git a/wip.py b/wip.py
index a5b9bda..41a7cad 100644
--- a/wip.py
+++ b/wip.py
@@ -119,22 +119,26 @@ class Chords(object):
return "%s<a href=\"#chord%s\">%s</a>: %s<br />\n" % (padding, self.html_anchor, self.name, self.details[0]['id'])
+strum_configs = dict()
+
class Strumming(object):
- def __init__(self, part, measures, bpm, is_triplet, denuminator):
+ def __init__(self, part, measures, bpm, is_triplet, denuminator, context):
self.part = part
self.measures = measures
self.bpm = bpm
self.is_triplet = is_triplet
self.denuminator = denuminator
+ self.context = context
@classmethod
- def from_raw_data(cls, data):
+ def from_raw_data(cls, data, url):
return [cls(part=s['part'],
measures=s['measures'],
bpm=s['bpm'],
is_triplet=s['is_triplet'],
- denuminator=s['denuminator']) for s in data]
+ denuminator=s['denuminator'],
+ context=(url, i)) for i, s in enumerate(data)]
def get_html_content(self):
strum_values = {
@@ -153,6 +157,7 @@ class Strumming(object):
if pattern0:
pattern0 += "\n"
pattern1 = "".join(strum_values[v][1].ljust(2, " ") for v in values).rstrip()
+ strum_configs.setdefault((len(values), self.denuminator, self.is_triplet), []).append(self.context)
# TODO: how to count ? how to display lines ? how to handle triplets ?
#coef = 2 # how to compute this ?
#beg, end = ("╘═", "╛ ") if coef == 2 else ("└─", "┘ ")
@@ -221,7 +226,7 @@ class GuitarTab(object):
tuning = tab_view_meta.get('tuning', dict()).get('name', None),
tab_content = tab_view['wiki_tab']['content'],
chords = Chords.from_raw_data(tab_view['applicature']),
- strummings = Strumming.from_raw_data(tab_view['strummings']),
+ strummings = Strumming.from_raw_data(tab_view['strummings'], url),
html_anchor = str(tab['id']) + "-" + string_to_html_id(tab['song_name']),
)
@@ -367,3 +372,78 @@ def make_book(urls, htmlfile="wip_book.html", make_mobi=True):
subprocess.call([KINDLEGEN_PATH, '-verbose', '-dont_append_source', htmlfile])
make_book(URLS)
+for k, v in strum_configs.items():
+ print(k)
+ for c in v:
+ print(c)
+
+
+# (24, 8, 1) - 8 fois 3 - simple trait avec un trait 3 en dessous
+# ('https://tabs.ultimate-guitar.com/tab/america/a-horse-with-no-name-chords-59609', 0)
+
+# (12, 8, 1) - 4 fois 3 - simple trait avec un trait 3 en dessous
+# ('https://tabs.ultimate-guitar.com/tab/r-e-m-/everybody-hurts-chords-37519', 0)
+# ('https://tabs.ultimate-guitar.com/tab/jeff-buckley/hallelujah-chords-198052', 0)
+# ('https://tabs.ultimate-guitar.com/tab/jeff-buckley/hallelujah-chords-198052', 1)
+# ('https://tabs.ultimate-guitar.com/tab/jeff-buckley/hallelujah-chords-198052', 2)
+
+# (8, 8, 0) - 4 fois 2 (1& 2& 3& 4&) - simple trait
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/across-the-universe-chords-202167', 0)
+# ('https://tabs.ultimate-guitar.com/tab/depeche-mode/enjoy-the-silence-chords-891725', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-handsome-family/far-from-any-road-chords-1457192', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/here-comes-the-sun-chords-1738813', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/here-there-and-everywhere-chords-17273', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/i-want-to-hold-your-hand-chords-457088', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/i-want-to-hold-your-hand-chords-457088', 1)
+# ('https://tabs.ultimate-guitar.com/tab/john-lennon/imagine-chords-9306', 3)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/let-it-be-chords-60690', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/let-it-be-chords-17427', 0)
+# ('https://tabs.ultimate-guitar.com/tab/queen/love-of-my-life-chords-340088', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/something-chords-335727', 0)
+# ('https://tabs.ultimate-guitar.com/tab/nirvana/the-man-who-sold-the-world-chords-651988', 0)
+# ('https://tabs.ultimate-guitar.com/tab/nirvana/the-man-who-sold-the-world-chords-651988', 1)
+# ('https://tabs.ultimate-guitar.com/tab/nirvana/the-man-who-sold-the-world-chords-841325', 0)
+# ('https://tabs.ultimate-guitar.com/tab/simon-garfunkel/the-sound-of-silence-chords-159157', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/while-my-guitar-gently-weeps-chords-17446', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/yesterday-chords-17450', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/yesterday-chords-887610', 0)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/yesterday-chords-887610', 1)
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/yesterday-chords-887610', 2)
+
+# (16, 16, 0) - 8 fois 2 (1_ &_ 2_ &_ 3_ &_ 4_ &_) - double trait
+# ('https://tabs.ultimate-guitar.com/tab/the-beatles/across-the-universe-chords-202167', 1)
+# ('https://tabs.ultimate-guitar.com/tab/oasis/dont-look-back-in-anger-chords-6097', 0)
+# ('https://tabs.ultimate-guitar.com/tab/eagles/hotel-california-chords-46190', 1)
+# ('https://tabs.ultimate-guitar.com/tab/john-lennon/imagine-chords-9306', 0)
+# ('https://tabs.ultimate-guitar.com/tab/radiohead/karma-police-chords-103398', 0)
+# ('https://tabs.ultimate-guitar.com/tab/elton-john/rocket-man-chords-10744', 0)
+# ('https://tabs.ultimate-guitar.com/tab/adele/someone-like-you-chords-1006751', 0)
+# ('https://tabs.ultimate-guitar.com/tab/adele/someone-like-you-chords-1006751', 1)
+# ('https://tabs.ultimate-guitar.com/tab/david-bowie/space-oddity-chords-105869', 0)
+# ('https://tabs.ultimate-guitar.com/tab/david-bowie/space-oddity-chords-105869', 1)
+# ('https://tabs.ultimate-guitar.com/tab/david-bowie/space-oddity-chords-105869', 2)
+# ('https://tabs.ultimate-guitar.com/tab/coldplay/the-scientist-chords-180849', 0)
+# ('https://tabs.ultimate-guitar.com/tab/pink-floyd/wish-you-were-here-chords-44555', 1)
+# ('https://tabs.ultimate-guitar.com/tab/pink-floyd/wish-you-were-here-chords-44555', 2)
+# ('https://tabs.ultimate-guitar.com/tab/elton-john/your-song-chords-29113', 0)
+
+# (32, 16, 0) - 16 fois 2 (1_ &_ 2_ &_ 3_ &_ 4_ &_ 5_ &_ 6_ &_ 7_ &_ 8_ &_) - double trait
+# ('https://tabs.ultimate-guitar.com/tab/neil-young/heart-of-gold-chords-56555', 0)
+# ('https://tabs.ultimate-guitar.com/tab/eagles/hotel-california-chords-46190', 0)
+# ('https://tabs.ultimate-guitar.com/tab/john-lennon/imagine-chords-9306', 1)
+# ('https://tabs.ultimate-guitar.com/tab/pink-floyd/wish-you-were-here-chords-44555', 0)
+# ('https://tabs.ultimate-guitar.com/tab/oasis/wonderwall-chords-27596', 0)
+
+# (32, 8, 0) - 16 fois 2 (1_ &_ 2_ &_ 3_ &_ 4_ &_ 5_ &_ 6_ &_ 7_ &_ 8_ &_) - simple trait
+# ('https://tabs.ultimate-guitar.com/tab/john-lennon/imagine-chords-9306', 2)
+
+# (16, 8, 0) - 8 fois 2 (1_ &_ 2_ &_ 3_ &_ 4_ &_) - simple trait
+# ('https://tabs.ultimate-guitar.com/tab/r-e-m-/losing-my-religion-chords-114345', 0)
+# ('https://tabs.ultimate-guitar.com/tab/r-e-m-/losing-my-religion-chords-114345', 1)
+# ('https://tabs.ultimate-guitar.com/tab/r-e-m-/losing-my-religion-chords-114345', 2)
+# ('https://tabs.ultimate-guitar.com/tab/simon-garfunkel/the-sound-of-silence-chords-159157', 1)
+
+# (4, 8, 0) - 2 fois 2 (1& 2&) - simple trait
+# ('https://tabs.ultimate-guitar.com/tab/israel-kamakawiwoole/over-the-rainbow-chords-2135261', 0)
+# ('https://tabs.ultimate-guitar.com/tab/nirvana/the-man-who-sold-the-world-chords-841325', 1)
+
Current result is pretty satisfying.
The strumming pattern is described via a list of values, a denuminator integer and a is_triplet flag. On the ultimateguitar website, this is rendered in different ways that would be nice to emulate somehow.
First step is to collect data and see how they are displayed on the original website.