<commit_before>#!/usr/bin/env python

# convert.py
# move <chart>.sm to "<title> - <artist>"

import os
import regex as re
import sys

from simfile import SMParser

pattern = re.compile(r'([\p{IsHan}\p{IsBopo}\p{IsHira}\p{IsKatakana}]+)', re.UNICODE)

def main():
    try:
        simfile = sys.argv[1]
    except IndexError:
        print "usage: %s /path/to/simfile.sm" % sys.argv[0]
        sys.exit(1)

    base = os.path.dirname(os.path.abspath(simfile))
    parsed = SMParser(open(simfile).read())
    title = parsed.TITLE.decode('utf-8')

    if pattern.match(title):
        romanized_title = simfile[:-3]
        new_title = (parsed.TITLE +
                     " (" + romanized_title.strip('.') + ") " +
                     " - " +
                     parsed.ARTIST).replace('/', '')
    else:
        new_title = (parsed.TITLE + " - " + parsed.ARTIST).replace('/', '')

    new_simfile = base + '/' + new_title

    print "moving %s to %s" % (simfile, new_simfile)
    os.rename(simfile, new_simfile)

if __name__ == "__main__":
    sys.exit(main())
<commit_msg>convert.py: only use the file's basename in the romanized title<commit_after>#!/usr/bin/env python

# convert.py
# move <chart>.sm to "<title> - <artist>"

import os
import regex as re
import sys

from simfile import SMParser

pattern = re.compile(r'([\p{IsHan}\p{IsBopo}\p{IsHira}\p{IsKatakana}]+)', re.UNICODE)

def main():
    try:
        simfile = sys.argv[1]
    except IndexError:
        print "usage: %s /path/to/simfile.sm" % sys.argv[0]
        sys.exit(1)

    base = os.path.dirname(os.path.abspath(simfile))
    parsed = SMParser(open(simfile).read())
    title = parsed.TITLE.decode('utf-8')

    if pattern.match(title):
        romanized_title = os.path.basename(simfile)[:-3]
        new_title = (parsed.TITLE +
                     " (" + romanized_title.strip('.') + ") " +
                     " - " +
                     parsed.ARTIST).replace('/', '')
    else:
        new_title = (parsed.TITLE + " - " + parsed.ARTIST).replace('/', '')

    new_simfile = base + '/' + new_title

    print "moving %s to %s" % (simfile, new_simfile)
    os.rename(simfile, new_simfile)

if __name__ == "__main__":
    sys.exit(main())

{'fraction_non_alphanumeric': 0.1708746618575293, 'fraction_numerical': 0.004508566275924256, 'mean_word_length': 2.44031007751938, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5640473', 'n_tokens_mistral': 825, 'n_tokens_neox': 799, 'n_words': 149}