コード例 #1
0
def main():
	N2N_paths = []
	N2Npath = namedtuple('N2Npath', ['X', 'Y', 'is_linear'])

	sentences = p41.main()
	for sentence in sentences:
		noun_chunks = [(i, chunk) for i, chunk in enumerate(sentence) if chunk.include_pos('名詞')]
		if len(noun_chunks) > 1:
			for former, latter in combinations(noun_chunks, 2):
				# combinations don't cause error even if len(noun_chunks) < 2
				f_index = extract_path2root_index(former, sentence)
				l_index = extract_path2root_index(latter, sentence)
				f_i, l_i = list(zip(reversed(f_index), reversed(l_index)))[-1]
				linear_flg = (f_i == l_i)
				if linear_flg:
					f_index2 = f_index[:f_index.index(f_i)+1]
					l_index2 = l_index[:l_index.index(l_i)+1]
				else:
					f_index2 = f_index[:f_index.index(f_i)+2]
					l_index2 = l_index[:l_index.index(l_i)+2]

				X = [sentence[k] for k in f_index2]
				Y = [sentence[k] for k in l_index2]
				N2N_paths.append(N2Npath(X=X, Y=Y, is_linear=linear_flg))

	return N2N_paths
コード例 #2
0
ファイル: chp05_45.py プロジェクト: atsushikawasaki/100nlp
def main():
    sentences = p41.main()
    verbcase_pats = []

    for sentence in sentences:
        verbcase_pats.append(exreact_verbcase_pat(sentence))

    return verbcase_pats
コード例 #3
0
ファイル: chp05_45.py プロジェクト: hassyGo/NLP100knock2015
def main():
    sentences = p41.main()
    verbcase_pats = []

    for sentence in sentences:
        verbcase_pats.append(exreact_verbcase_pat(sentence))

    return verbcase_pats
コード例 #4
0
ファイル: chp05_42.py プロジェクト: atsushikawasaki/100nlp
def main():
    sentences = p41.main()

    new_sentences = []
    for sentence in sentences:
        paired_sentence = make_chunk_pair(sentence)
        new_sentences.append(paired_sentence)

    return new_sentences
コード例 #5
0
ファイル: chp05_42.py プロジェクト: hassyGo/NLP100knock2015
def main():
	sentences = p41.main()

	new_sentences = []
	for sentence in sentences:
		paired_sentence = make_chunk_pair(sentence)
		new_sentences.append(paired_sentence)

	return new_sentences
コード例 #6
0
ファイル: chp05_48.py プロジェクト: hassyGo/NLP100knock2015
def main():
	path2roots = []

	sentences = p41.main()
	for sentence in sentences:
		for chunk in sentence:
			if chunk.include_pos('名詞') and chunk.dst != -1:
				path2roots.append(extract_path2root(chunk, sentence))

	return path2roots
コード例 #7
0
ファイル: chp05_48.py プロジェクト: atsushikawasaki/100nlp
def main():
    path2roots = []

    sentences = p41.main()
    for sentence in sentences:
        for chunk in sentence:
            if chunk.include_pos('名詞') and chunk.dst != -1:
                path2roots.append(extract_path2root(chunk, sentence))

    return path2roots