<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Here is how you load the "bali" module
Step1:  Now we make a FileReader
Step2:  More useful Object
The FileParser is more useful than the file reader.
Step3:  Now we have all the taught patterns! Yay!
Let's get the first taught pattern
Step4:  How many strokes total are there in the whole taught set?
Step5:  Create a list of all the taught patterns that contain "lanang"
Step6:  Find percentage of strokes that are on a particular beat subdivision in patterns for a given drum
Step7:  Find the same as above, but eliminate all double strokes.
<ASSISTANT_TASK:>
Python Code:
import bali
Explanation: Here is how you load the "bali" module
End of explanation
fileReader = bali.FileReader()
fileReader.taught
fileReader.transcribed
Explanation: Now we make a FileReader
End of explanation
fp = bali.FileParser()
fp.taught
Explanation: More useful Object
The FileParser is more useful than the file reader.
End of explanation
firstPattern = fp.taught[0]
print(firstPattern)
firstPattern.title
firstPattern.drumPattern
firstPattern.gongPattern
firstPattern.beatLength()
firstPattern.strokes
for taughtPattern in fp.taught:
    if taughtPattern.beatLength() == 4:
        print(taughtPattern.title, " ::: ", taughtPattern.beatLength())
        print(taughtPattern.gongPattern)
        print(taughtPattern.drumPattern)
        print("")
for taughtPattern in fp.taught:
    print(taughtPattern.getStrokeByBeat(4), taughtPattern.title)
Explanation: Now we have all the taught patterns! Yay!
Let's get the first taught pattern
End of explanation
total = 0
for pattern in fp.taught:
    total += len(pattern.strokes)
print(total)
Explanation: How many strokes total are there in the whole taught set?
End of explanation
lanang = [p for p in fp.taught if 'lanang' in p.title.lower()]
lanang
from music21 import *
ld = text.LanguageDetector()
ld
ld.trigrams
english = ld.trigrams['en']
english.lut
english.lut['be']
ld.trigrams['fr'].lut['be']
ld.mostLikelyLanguage("Das geht so gut heute!")
other = [p for p in fp.taught if 'lanang' not in p.title.lower() and 'wadon' not in p.title.lower()]
other
for p in fp.taught:
    print(p.drumType, p.gongPattern)
    print(p.drumType, p.drumPattern)
for i in [0.25, 0.75, 1.25, 1.75, 2.25, 2.75, 3.25, 3.75]:
    for tp in fp.taught:
        if tp.drumType != 'wadon':
            continue
        print(tp.getStrokeByBeat(i), end=' ')
    print()
patt = fp.taught[9]
patt
patt.strokes
beat = 0
for stroke in patt.strokes:
    print(beat, stroke)
    beat = beat + 0.25
5 is 5.0
patt
Explanation: Create a list of all the taught patterns that contain "lanang"
End of explanation
subdivisionSearch = (0, 2)
strokeSearch = ('o', 'l')
for patt in fp.taught:
    totalOff = 0
    totalAll = 0
    if patt.drumType != 'wadon':
        continue
    for b, s in patt.iterateStrokes():
        if b == 0:
            continue
        if ((b*4) % 4) in subdivisionSearch and s in strokeSearch:
            totalOff += 1
        if s in strokeSearch:
            totalAll += 1
    if totalAll > 0:
        perc = int(100*(totalOff/totalAll))
    else:
        perc = 0
    print(totalAll, perc, " -- ", patt.title)
for patt in fp.taught:
    if patt.title == 'Pak Dewa Wadon 0a with Dag delay':
        print(patt.gongPattern)
        print(patt.drumPattern)
        print(patt.beatLength())
Explanation: Find percentage of strokes that are on a particular beat subdivision in patterns for a given drum
End of explanation
subdivisionSearch = (0, 2)
strokeSearch = ('o', 'l')
for patt in fp.taught:
    totalOff = 0
    totalAll = 0
    if patt.drumType != 'lanang':
        continue
    for b, s in patt.iterateStrokes():
        if b == 0:
            continue
        previousStrokeBeat = b - 0.25
        if previousStrokeBeat >= 0:
            previousStroke = patt.getStrokeByBeat(previousStrokeBeat)
            if previousStroke == s:
                continue
        nextStrokeBeat = b + 0.25
        if nextStrokeBeat <= patt.beatLength():
            nextStroke = patt.getStrokeByBeat(nextStrokeBeat)
            if nextStroke == s:
                continue
        if ((b*4) % 4) in subdivisionSearch and s in strokeSearch:
            totalOff += 1
        if s in strokeSearch:
            totalAll += 1
        
        
    if totalAll > 0:
        perc = int(100*(totalOff/totalAll))
    else:
        perc = 0
    print(totalAll, perc, " -- ", patt.title)
import re
re.match('(Pak\s\w+)\s', 'Pak Cok Lanang 7').group(1)
for patt in fp.taught:
    print(patt.teacher, '--', patt.title)
Explanation: Find the same as above, but eliminate all double strokes.
End of explanation
<END_TASK>