Examples of PrimitiveTriple


Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

        super.setup(context);
    }

    @Override
    protected void map(LongWritable key, Text value, Mapper.Context context) throws IOException, InterruptedException {
        PrimitiveTriple pt=codec.decode(value.toString());
        final String prefix = "/wikipedia/en_title/";

        if(pt.getPredicate().equals("<http://rdf.basekb.com/ns/type.object.key>")) {
            String fbKey=pt.getObject();
            if (fbKey.startsWith("\"") || fbKey.endsWith("\"")) {
                fbKey=fbKey.substring(1,fbKey.length()-1);

                if(fbKey.startsWith(prefix)) {
                    String wikiKey=fbKey.substring(prefix.length());
                    String dbpediaURI="http://dbpedia.org/resource/"+mapKey(wikiKey);
                    context.write(
                            new Text(pt.getSubject()),
                            new Text("<http://www.w3.org/2002/07/owl#sameAs>\t<"+dbpediaURI+">\t.")
                    );
                }
            }
        }
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

    }

    @Override
    protected boolean matches(Text subject, Iterable<Text> facts) {
        for(Text fact:facts) {
            PrimitiveTriple pt=codec.decode(fact.toString());
            if (A.equals(pt.getPredicate()) && typeList.contains(pt.getObject()) ) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

public class EntityCentricMapper extends Mapper<LongWritable,Text,Text,Text> {
    static final PrimitiveTripleCodec codec=new PrimitiveTripleCodec();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        PrimitiveTriple t=codec.decode(value.toString());
        context.write(new Text(t.getSubject()),value);
    }
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

public class SmushObjectMapper extends GeneralTextJoinMapper {

    PrimitiveTripleCodec ptc=new PrimitiveTripleCodec();
    @Override
    public Map.Entry<Text, Text> splitValue(Writable value, VIntWritable tag) {
        PrimitiveTriple t=ptc.decode(value.toString());
        if (tag.get()==1) {
            return immutableEntry(new Text(t.getSubject()), (Text) value);
        }
        return immutableEntry(new Text(t.getObject()), (Text) value);
    }
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

        super.setup(context);
    }

    @Override
    public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        PrimitiveTriple pt=codec.decode(value.toString());
        if(pt.getPredicate().equals("<http://rdf.basekb.com/ns/type.object.key>")) {
            String fbKey=pt.getObject();
            if (fbKey.startsWith("\"") || fbKey.endsWith("\"")) {
                fbKey=fbKey.substring(1,fbKey.length()-1);
                if(fbKey.startsWith("/wikipedia/en/")) {
                    String wikiKey=fbKey.substring("/wikipedia/en/".length());
                    String dbpediaURI="http://dbpedia.org/resource/"+mapKey(wikiKey);
                    context.write(
                            new Text("<"+dbpediaURI+">"),
                            new Text("<http://www.w3.org/2002/07/owl#sameAs>\t"+pt.getSubject()+"\t.")
                    );
                }
            }
        }
    }
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

    @Override
    public void reduce(TaggedTextItem key, Iterable<TaggedTextItem> values, Context context) throws IOException, InterruptedException {
        String newObject=null;
        for(TaggedTextItem value:values) {
            int tag=value.getTag().get();
            PrimitiveTriple t=ptc.decode(value.getKey().toString());
            switch(tag) {
                case 1:
                    if(t.getPredicate().equals("<http://www.w3.org/2002/07/owl#sameAs>"))
                        newObject=t.getObject();
                    break;
                default:
                    if(newObject!=null)
                        context.write(
                                new Text(t.getSubject()),
                                new Text(t.getPredicate()+"\t"+newObject+"\t.")
                        );
            }
        }
    }
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

        }

        try {
            List<String> parts = expandTripleParts(line);
            line.getBytes();
            PrimitiveTriple triple=new PrimitiveTriple(parts.get(0),parts.get(1),parts.get(2));


            if(tripleFilter.apply(triple)) {
                triple=rewritingFunction.apply(triple);
                accept(c,triple);
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

    Function<String,String> nodePreprocessor=new Unescape$();
    int myCnt=0;
    WritableTriple writableTriple;
    @Override
    public void map(LongWritable arg0, Text arg1, Context c) throws IOException, InterruptedException {
        PrimitiveTriple row3=p3Codec.decode(arg1.toString());
        try {
            String rawSubject = nodePreprocessor.apply(row3.getSubject());
            String rawPredicate = nodePreprocessor.apply(row3.getPredicate());
            String rawObject = nodePreprocessor.apply(row3.getObject());
           
            Node_URI subject=(Node_URI) nodeParser.get(rawSubject);
            Node_URI predicate=(Node_URI) nodeParser.get(rawPredicate);
            Node object=nodeParser.get(rawObject);
           
            Triple realTriple=new Triple(subject,predicate,object);
            writableTriple = new WritableTriple(realTriple);
        } catch(Throwable e) {
            String factString=row3.getSubject()+"\t"+row3.getPredicate()+"\t"+row3.getSubject()+"\t.";
            logger.warn("Caught exception while parsing fact ["+factString+"]",e);
            reject(c, row3);
            return;
        }
        accepted.write(writableTriple,writableTriple,c);
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

    PrimitiveTripleCodec ptc=new PrimitiveTripleCodec();
    private final String activePredicate="<http://www.yahoo.com/>";

    @Override
    protected void map(LongWritable key,Text value,Context context) throws IOException,InterruptedException {
        PrimitiveTriple t=ptc.decode(value.toString());
        if(t.getPredicate().equals("<http://rdf.basekb.com/public/subjectiveEye3D>")) {
            String number=getQuoteContents(t.getObject());
            if(number!=null) {
                float numericValue=Float.parseFloat(number);
                context.write(new Text(t.getSubject()),new FloatWritable(numericValue));
            }
        }
    }
View Full Code Here

Examples of com.ontology2.bakemono.primitiveTriples.PrimitiveTriple

    // issuing the subject field as a key so it is very simple
    PrimitiveTripleCodec ptc=new PrimitiveTripleCodec();

    @Override
    public Map.Entry<Text, Text> splitValue(Writable value, VIntWritable tag) {
        PrimitiveTriple t=ptc.decode(value.toString());
        return immutableEntry(new Text(t.getSubject()), (Text) value);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.