def substiSentence(morphs, poses, substi, only):
    """명사와 동사를 찾아 기호로 변환하고, 명사,동사,조사,어미만 붙여 연결한다"""
    noun_list = []
    verb_list = []
    nouns = ''
    verbs = ''
    morph_idx = 0
    noun_idx = 0
    verb_idx = 0
    if substi:
        for pos in poses:
            if pos == 'NNG' or pos == 'NNP':
                noun_list.append(morphs[morph_idx])
                morphs[morph_idx] = 'NOUN' + str(noun_idx)
                noun_idx += 1
            elif pos == 'VV' or pos == 'VA' or pos == 'VX' or pos == 'XR':
                verb_list.append(morphs[morph_idx])
                morphs[morph_idx] = 'VERB' + str(verb_idx)
                verb_idx += 1
            morph_idx += 1
    new_data = ''
    if only:
        pos_idx = 0
        for morph in morphs:
            if poses[pos_idx] == 'NNG' or poses[pos_idx] == 'NNP' or poses[
                pos_idx] == 'VV' or poses[pos_idx] == 'VA' or poses[pos_idx
                ] == 'VX' or poses[pos_idx] == 'XR' or poses[pos_idx
                ].startswith('J') or poses[pos_idx].startswith('E'):
                new_data += ' ' + morph + ' '
            pos_idx += 1
    else:
        for morph in morphs:
            new_data += ' ' + morph + ' '
    for noun_each in noun_list:
        nouns += noun_each + ','
    for verb_each in verb_list:
        verbs += verb_each + ','
    return new_data, nouns, verbs
