Git Product home page Git Product logo

Comments (2)

waltbai avatar waltbai commented on May 30, 2024 1

Entity和Relation要通过parseDelimitedFrom方法解析

from nre.

wudapeng268 avatar wudapeng268 commented on May 30, 2024

你好
你是怎么从 那个网址解析数据的,我用 java 解析 protocol 数据,下面是我的代码

package cc.refectorie.proj.relation.protobuf;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import cc.refectorie.proj.relation.protobuf.DocumentProtos.Relation;

public class Main {
public static void main(String[] args) throws IOException {
//File file = new File("/home/wup/re_data/heldout_relations/trainPositive.pb");
FileInputStream fileInputStream = new FileInputStream("heldout_relations/testNegative.pb");
Relation relation=DocumentProtos.Relation.parseFrom(fileInputStream);
System.out.println(relation.getDestGuid());
}
}
但是编译运行后,回报这种错误
Exception in thread "main" com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
at com.google.protobuf.InvalidProtocolBufferException.invalidEndTag(InvalidProtocolBufferException.java:110)
at com.google.protobuf.CodedInputStream$StreamDecoder.checkLastTagWas(CodedInputStream.java:2128)
at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:223)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:239)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:244)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
at com.google.protobuf.GeneratedMessageV3.parseWithIOException(GeneratedMessageV3.java:311)
at cc.refectorie.proj.relation.protobuf.DocumentProtos$Relation.parseFrom(DocumentProtos.java:7693)
at cc.refectorie.proj.relation.protobuf.Main.main(Main.java:13)

而且当我读取trainPositive.pb 时,报的错误还不一样。
Exception in thread "main" com.google.protobuf.InvalidProtocolBufferException$InvalidWireTypeException: Protocol message tag had invalid wire type.
at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:115)
at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:551)
at com.google.protobuf.GeneratedMessageV3.parseUnknownField(GeneratedMessageV3.java:293)
at cc.refectorie.proj.relation.protobuf.DocumentProtos$Relation.(DocumentProtos.java:6200)
at cc.refectorie.proj.relation.protobuf.DocumentProtos$Relation.(DocumentProtos.java:6132)
at cc.refectorie.proj.relation.protobuf.DocumentProtos$Relation$1.parsePartialFrom(DocumentProtos.java:8482)
at cc.refectorie.proj.relation.protobuf.DocumentProtos$Relation$1.parsePartialFrom(DocumentProtos.java:8476)
at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:221)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:239)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:244)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
at com.google.protobuf.GeneratedMessageV3.parseWithIOException(GeneratedMessageV3.java:311)
at cc.refectorie.proj.relation.protobuf.DocumentProtos$Relation.parseFrom(DocumentProtos.java:7693)
at cc.refectorie.proj.relation.protobuf.Main.main(Main.java:13)
你遇到过这种问题吗?
谢谢

from nre.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.