# Path: general/filePath.py



import json
import unicodecsv as csv
import numpy as np
from os import path, makedirs
from general.eval import *
from general.filePath import class_name
from scipy.stats import norm
    compare with the results of melodic similarity
    find the intersection set, melodic similarity ranking > N, phonetic similarity ranking < N
    :param path_largerPyin: path of the melodic similarity csv
    :param list_lessNRank_phrase_name: ranking less than N phrase name by phonetic similarity
    :return: intersection set of the phrase name
    '''
    phrase_names_largerN = []
    with open(path_largerPyin,'r') as openfile:
        csv_reader = csv.reader(openfile,delimiter=',')
        for row in csv_reader:
            phrase_names_largerN.append(row[0])

    return set.intersection(set(phrase_names_largerN),set(list_lessNRank_phrase_name))

def resultAnalysisProcess(method, proportionality_std=0, path_json_dict_query_phrases='dummy', am='gmm', cnn_file_name=''):

    # path for storing matching ranking result csv
    results_path = path.join(currentPath, '..', 'results/'+method+'_'+class_name)

    with open(path_json_dict_query_phrases,'r') as outfile:
        dict_query_phrases = json.load(outfile)


    if method == 'lyricsRecognizerHMM':
        # best cpp = 1.0, pstd = 0.7 for dan
        # best cpp = 1.0, pstd = 1.5 for laosheng

        # pstd = 0 means no post-processor duration modelling
        if class_name == 'danAll':
            pstd_options = [0, 0.7]

# Path: general/filePath.py



# Path: phoneticSimilarity/lyricsRecognizer/resultAnalysis.py
import json
import unicodecsv as csv
import numpy as np
from os import path, makedirs
from general.eval import *
from general.filePath import class_name
from scipy.stats import norm

    compare with the results of melodic similarity
    find the intersection set, melodic similarity ranking > N, phonetic similarity ranking < N
    :param path_largerPyin: path of the melodic similarity csv
    :param list_lessNRank_phrase_name: ranking less than N phrase name by phonetic similarity
    :return: intersection set of the phrase name
    '''
    phrase_names_largerN = []
    with open(path_largerPyin,'r') as openfile:
        csv_reader = csv.reader(openfile,delimiter=',')
        for row in csv_reader:
            phrase_names_largerN.append(row[0])

    return set.intersection(set(phrase_names_largerN),set(list_lessNRank_phrase_name))

def resultAnalysisProcess(method, proportionality_std=0, path_json_dict_query_phrases='dummy', am='gmm', cnn_file_name=''):

    # path for storing matching ranking result csv
    results_path = path.join(currentPath, '..', 'results/'+method+'_'+class_name)

    with open(path_json_dict_query_phrases,'r') as outfile:
        dict_query_phrases = json.load(outfile)


    if method == 'lyricsRecognizerHMM':
        # best cpp = 1.0, pstd = 0.7 for dan
        # best cpp = 1.0, pstd = 1.5 for laosheng

        # pstd = 0 means no post-processor duration modelling
        if class_name == 'danAll':
            pstd_options = [0, 0.7]

        elif class_name == 'laosheng':