Пример #1
0
    def _setPAS(self, newstyle):
        """ 各基本句にPASを設定 """
        tag_list = self.tag_list()
        if (newstyle):
            for pinfo in self._pinfos:
                pinfo = json.loads(pinfo)

                tag_idx = pinfo.get("tid")
                if tag_idx is None:
                    end = pinfo["head_token_end"]
                    tag_idx = bisect.bisect(self.tag_positions, end) - 1

                tag = tag_list[tag_idx]
                tag.pas = Pas()
                tag.pas.cfid = pinfo["cfid"]

                for casename, args in pinfo["args"].items():
                    for arg in args:
                        arg_tag_idx = arg.get("tid")
                        if arg_tag_idx is None:
                            arg_tag_idx = bisect.bisect(
                                self.tag_positions, arg["head_token_end"]) - 1
                        arg_sid = arg.get("sid")
                        if (arg_sid is None) or (len(arg["sid"]) == 0):
                            arg_sid = self.sid

                        arg = Argument(sid=arg_sid,
                                       tid=arg_tag_idx,
                                       midasi=arg["rep"])
                        tag.pas.arguments[casename].append(arg)
        else:
            # KNPの述語項構造をparse
            for tag in tag_list:
                if ("格解析結果" in tag.features) or ("述語項構造" in tag.features):
                    tag.pas = Pas(tag.tag_id, self)
Пример #2
0
    def _setPAS(self):
        """Set PAS to BList with new format"""
        tag_list = self.tag_list()
        for pinfo in self._pinfos:
            pinfo = json.loads(pinfo)

            tag_idx = pinfo.get("tid")
            if tag_idx is None:
                end = pinfo["head_token_end"]
                tag_idx = bisect.bisect(self.tag_positions, end) - 1

            tag = tag_list[tag_idx]
            tag.features.pas = Pas()
            tag.features.pas.cfid = pinfo["cfid"]

            for casename, args in pinfo["args"].items():
                for arg in args:
                    arg_tag_idx = arg.get("tid")
                    if arg_tag_idx is None:
                        arg_tag_idx = bisect.bisect(self.tag_positions,
                                                    arg["head_token_end"]) - 1
                    arg_sid = arg.get("sid")
                    if arg_sid is None or not arg["sid"]:
                        arg_sid = self.sid

                    arg = Argument(arg_sid, arg_tag_idx, arg["rep"])
                    tag.features.pas.arguments[casename].append(arg)