Package com.ontology2.bakemono.bloom

Examples of com.ontology2.bakemono.bloom.BloomReducerTest


    }
   
    @Test
    public void parsesALiteralTripleWithNoSpaceBeforeTerminalPeriod() {
        String in=X+"\t"+Y+"\t "+L1+".";
        PrimitiveTriple out=codec.decode(in);
        assertEquals(X,out.getSubject());
        assertEquals(Y,out.getPredicate());
        assertEquals(L1,out.getObject());
    }
View Full Code Here


    }
   
    @Test
    public void parsesALiteralValueWithSpaces() {
        String in=X+"\t"+Y+"\t "+L2+"\t.";
        PrimitiveTriple out=codec.decode(in);
        assertEquals(X,out.getSubject());
        assertEquals(Y,out.getPredicate());
        assertEquals(L2,out.getObject());
    }
View Full Code Here

        );
    }
   
    @Test
    public void ordinaryTriplesPassThrough() {
       PrimitiveTriple p1=new PrimitiveTriple("<http://example.com/ats>","<http://example.com/unlocksWithNumber>","\"true\"^^xsd:boolean");
       PrimitiveTriple p2=rewriter.apply(p1);
       assertEquals(p1,p2);
    }
View Full Code Here

       assertEquals(p1,p2);
    }
   
    @Test
    public void datetimeIsRewritten() {
       PrimitiveTriple p1=new PrimitiveTriple("<http://example.com/ats>","<http://example.com/oxygenSensorBurnedOutOn>","\"true\"^^xsd:datetime");
       PrimitiveTriple p2=rewriter.apply(p1);
       assertNotEquals(p1,p2);
    }
View Full Code Here

        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

    }

    @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

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

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

        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

    @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

TOP

Related Classes of com.ontology2.bakemono.bloom.BloomReducerTest

Copyright © 2018 www.massapicom. 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.