Package com.ontology2.haruhi.flows

Examples of com.ontology2.haruhi.flows.ForeachStep


        }

        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


    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

    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

    // 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

    @Override
    public void reduce(TaggedTextItem key, Iterable<TaggedTextItem> values, Context context) throws IOException, InterruptedException {
        String newSubject=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>"))
                        newSubject=t.getObject();
                break;
                default:
                    if(newSubject!=null)
                        context.write(
                                new Text(newSubject),
                                new Text(t.getPredicate()+"\t"+t.getObject()+"\t.")
                        );
            }
        }
    }
View Full Code Here

    public Map.Entry<Text, Text> splitValue(Writable value, VIntWritable tag) {
        switch(tag.get()) {
            case 1:
                return Maps.immutableEntry((Text) value, EMPTY);
            case 2:
                PrimitiveTriple triple=ptc.decode(value.toString());
                return Maps.immutableEntry(new Text(triple.getObject()),(Text) value);
        }

        return Maps.immutableEntry((Text) value, (Text) value);
    }
View Full Code Here

    private PrimitiveTripleCodec codec;

    @Before
    public void setup() {
        codec=new PrimitiveTripleCodec();
    }
View Full Code Here

                        "<http://rdf.basekb.com/ns/type.permission.controls>"
                        ,"<http://rdf.basekb.com/ns/m.0j2r9sk>")
                ,new PrimitiveTripleReverser(
                        "<http://rdf.basekb.com/ns/dataworld.gardening_hint.replaced_by>"
                        ,"<http://rdf.basekb.com/ns/m.0j2r8t8>"))
                ,new PrimitiveTriplePredicateRewriter(
                        "<http://rdf.basekb.com/ns/type.object.type>",
                        "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>"))
                ,new PrimitiveTripleTypeRewriter(
                        "xsd:datetime",
                        "<http://rdf.ontology2.com/freebaseDate>"
View Full Code Here

    }


    public static Function<PrimitiveTriple, PrimitiveTriple> tripleRewritingFunction() {
        return Functions.compose(Functions.compose(Functions.compose(
                new PrimitiveTripleReverser(
                        "<http://rdf.basekb.com/ns/type.permission.controls>"
                        ,"<http://rdf.basekb.com/ns/m.0j2r9sk>")
                ,new PrimitiveTripleReverser(
                        "<http://rdf.basekb.com/ns/dataworld.gardening_hint.replaced_by>"
                        ,"<http://rdf.basekb.com/ns/m.0j2r8t8>"))
                ,new PrimitiveTriplePredicateRewriter(
                        "<http://rdf.basekb.com/ns/type.object.type>",
                        "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>"))
View Full Code Here

    private Function<PrimitiveTriple,PrimitiveTriple> rewriter;

    @Before
    public void setup() {
        rewriter = new PrimitiveTripleTypeRewriter(
                "xsd:datetime",
                "<http://rdf.ontology2.com/freebaseDate>"
        );
    }
View Full Code Here

TOP

Related Classes of com.ontology2.haruhi.flows.ForeachStep

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.