Exemple #1
0
def main():
	all_chunk_list = nlp_41.make_chunk()
	for line in all_chunk_list:
		for chunk_element in line:
			sentence = ""
			for morph in chunk_element.morphs:
				sentence += morph.surface
			sentence += ":"
			# 係り受け先の出力:chunk_element.dst
			if chunk_element.dst == -1:
				sentence += "<NONE>"
			else:
				for mor in line[chunk_element.dst].morphs:
					if mor.surface == "。" or mor.surface == "、":
						pass
					else:
						sentence += mor.surface

			sentence += "\t"
			# 係り受け元の出力:chuk_element.srcs
			if len(chunk_element.srcs) == 0:
				sentence += "<NONE>"
			else:
				for num in chunk_element.srcs:
					for mor in line[num].morphs:
						if mor.surface == "。" or mor.surface == "、":
							pass
						else:
							sentence += mor.surface
					sentence += " "
			print sentence
Exemple #2
0
def main():
	all_chunk_list = nlp_41.make_chunk()
	for chunk_list in all_chunk_list:
		for chunk_element in chunk_list:
			verb = "";particle = ""
			for mor in chunk_element.morphs:
				if mor.pos == "動詞":
					verb += mor.base
					break # 最左の動詞の基本形を述語とするため
			# 動詞にかかる文節の助詞(格)の出力
			for num in chunk_element.srcs:
				for mor in chunk_list[num].morphs:
					if mor.pos == "助詞":
						particle += mor.surface
						particle += " "
			if verb != "" and particle != "":
				print verb,"\t",particle
Exemple #3
0
def main():
	all_chunk_list = nlp_41.make_chunk()
	for line in all_chunk_list:
		for chunk_element in line:
			sentence = "";dst_sentence = ""
			pos_list = [];dst_pos_list = []
			for mor in chunk_element.morphs:
				pos_list.append(mor.pos)
				if mor.surface == "。" or mor.surface == "、":
					pass
				else:
					sentence += mor.surface
			if chunk_element.dst != -1:
				for dst_mor in line[chunk_element.dst].morphs:
					dst_pos_list.append(dst_mor.pos)
					if dst_mor.surface == "。" or dst_mor.surface == "、":
						pass
					else:
						dst_sentence += dst_mor.surface
			if "名詞" in pos_list and "動詞" in dst_pos_list:
				print sentence,"\t",dst_sentence
Exemple #4
0
# -*- coding: utf-8 -*-
import nlp_41
l = nlp_41.make_chunk()
text = []
for s in l:
    for c in s:
        if c.is_ntov(s[c.dst], 'サ変接続') and c.is_jo('を'):
            sub = []
            jo = []
            jo_c = []
            sub.append(c.mtoc(c))
            sub.append(s[c.dst].verb())
            for i in c.srcs:
                if s[int(i)].is_jo() is not None:
                    jo.append(s[int(i)].is_jo())
                    jo.append(' ')
                    jo_c.append(s[int(i)].jo())
                    jo_c.append(' ')
            for i in s[c.dst].srcs:
                if s[int(i)].is_jo() is not None and c != s[int(i)]:
                    jo.append(s[int(i)].is_jo())
                    jo.append(' ')
                    jo_c.append(s[int(i)].jo())
                    jo_c.append(' ')
            if len(jo) != 0 and len(sub) != 0:
                jo.append('\t')
                sub.append('\t')
                jo_c.append('\n')
                text.append(''.join(sub) + ''.join(jo) + ''.join(jo_c))
print(''.join(text))