Пример #1
0
def main():
    fw = open("45copy.txt", "w")
    sys.stdout = fw

    document = exp40.read('neko.txt.cabocha')
    sentences = exp41.make_chunk_list(document)

    particle = []
    frame = []
    VP = []
    
    for i in sentences:
        for j in i:
            if j.srcs == 'none':
                continue
            else:
                VP = []
                for k in j.morphs:
                    if k.pos == '動詞':
                        VP.append(k.base)
                        break
                for k in j.srcs:
                    for l in i[int(k)].morphs[::-1]:
                        if l.pos == '助詞':
                            particle.append(l.surface)
                            break
                VP.append(particle)
                particle = []
                frame.append(VP)

    for i in frame:
        if len(i) == 2:
            if len(i[1]) == 0:
                continue
            else:
                i[1].sort()
                print i[0], '\t', " ".join(i[1])


    fw.close()
Пример #2
0
            self.srcs = "none"        
"""

if __name__ == '__main__':
    #f = open("neko.txt.cabocha", "r")
    fw = open("42copy.txt", "w")
    sys.stdout = fw

    subset = []
    all = []
    chunks = []
    sentence = []
    phrase = {0:[0]}
    pairs = []

    document = exp40.read('neko.txt.cabocha')

    for line in document:
        match = exp40.search_sentence(line)
        
        if line == "EOS":
            all.append(sentence)
            sentence = []
            phrase = {}
        elif match:
            c = exp41.Chunk(line)
            sentence.append(c)
        else:
            sentence[-1].morphs.append(exp40.Morph(line))

    for i in all:
Пример #3
0
# !/usr/bin/python
# coding:UTF-8
# 4-(47)copy

import sys
import re
import exp40
import exp41

if __name__ == '__main__':
    fw = open("47copy.txt", "w")
    sys.stdout = fw

    document = exp40.read('neko.txt.cabocha')
    sentences = exp41.make_chunk_list(document)

    VP = []
    particle = []
    word = []
    noun = []
    frame = []

    for i in sentences:
        flag = 0
        p1 = 0
        p2 = 0
        for j in i:
            if j.srcs == 'none':
                continue
            else:
                VP = []