Package lupos.datastructures.items

Examples of lupos.datastructures.items.Triple


      final Collection<HyperTriple> result2 = new LinkedList<HyperTriple>();
      final HashMap<HyperNode, List<HyperTriple>> predicatesMap = new HashMap<HyperNode, List<HyperTriple>>();
      for (final HyperTriple ht : this.originalresultlevel0) {
        if (ht.getPos(0).size() == 1 && ht.getPos(1).size() == 1
            && ht.getPos(2).size() == 1) {
          final Triple triple = new Triple(
              (Literal) ht.getPos(0).items.iterator().next(),
              (Literal) ht.getPos(1).items.iterator().next(),
              (Literal) ht.getPos(2).items.iterator().next());
          if (this.subjects.get(triple) != null) {
            result2.add(ht);
          } else {
            if (((triple.getObject() instanceof AnonymousLiteral || triple
                .getObject() instanceof URILiteral) && this.objects
                .get(triple.getObject()).size() > 1)) {
              result2.add(ht);
            } else {
              List<HyperTriple> lht = predicatesMap.get(ht
                  .getPos(1));
              if (lht == null) {
View Full Code Here


        this.commentLabelElement = new CommentLabelElement(
            this.operatorGraphViewer.getOperatorGraph(),
            stepContainer.getFrom(), stepContainer.getTo(), data,
            columnNames, stepContainer.isDeleteStep());
      } else if (stepContainer.getObject() instanceof Triple) {
        final Triple t = (Triple) stepContainer.getObject();
        final Vector<String> columns = new Vector<String>();
        columns.add(t.getSubject()
            .toString(
                this.operatorGraphViewer.getOperatorGraph()
                .getPrefix()));
        columns.add(t.getPredicate()
            .toString(
                this.operatorGraphViewer.getOperatorGraph()
                .getPrefix()));
        columns.add(t.getObject()
            .toString(
                this.operatorGraphViewer.getOperatorGraph()
                .getPrefix()));
        columnNames.add("Subject");
        columnNames.add("Predicate");
View Full Code Here

      //check how many entries  are in the first result of the xpathQuery and
      //go through each result
      for (int k = 0; k < queryList.get(0).getLength(); k++) {
        Literal subject = LiteralFactory.createAnonymousLiteral("<" + id + ">");
        Triple typeTriple = new Triple(subject, Literals.RDF.TYPE, this.TYPE)
        res.add(typeTriple);

        //check how many XPath expressions were submitted and go trough each result
        //add all entries to the res = (intermediate) result
        for (int i = 0; i < queryList.size(); i++) {
          //get data out of the XPath result node list
          String data = queryList.get(i).item(k).getTextContent().trim();

          // evaluate regex for information selection
          boolean addValues=true;
          // if regex given
          if (this.regexString.get(i).length()>0) {
            final Pattern pattern = Pattern.compile(this.regexString.get(i));
            final Matcher matcher = pattern.matcher(data);
            // if regex valid, extract information
            if (matcher.find() == true) {

              //the last regex value in parentheses is chosen as group             
              if(matcher.groupCount()!=0){
                data = matcher.group(matcher.groupCount());
              } else { // otherwise group 0 is chosen as complete expression
                data = matcher.group(0);             
                String buffer = data;
                data="";

                // the whole result string is checked for digits which will remain in result
                // others symbols are removed
                for(int j=0;j<buffer.length();j++){
                  Character c= buffer.charAt(j);
                  if(Character.isDigit(c)){
                    data=data+c;
                  }
                }
              }

            } else { // if regex invalid ignore data             
              addValues = false;
           
          }
          // create triple out of selected data
          if (addValues){
            System.out.println(data);
            Literal obj = Literals.createTyped(data, this.dataString.get(i));
            Triple genTriple = new Triple(subject, this.literalList.get(i), obj);
            res.add(genTriple);
          }       
        }
        //increase counter for individual subject generation
        id++;
View Full Code Here

      final Literal object = (this.termParams.get(1) instanceof Constant)?
          ((Constant) this.termParams.get(1)).getLiteral():
          (Literal)((External) this.termParams.get(1)).evaluate(new BindingsMap());

      return new Triple(subject, predicate, object);
    } else {
      final Predicate pred = new Predicate();
      pred.setName(((Constant) this.termName).getLiteral());
      for (final IExpression expr : this.termParams) {
        pred.getParameters().add(  (expr instanceof Constant)?
View Full Code Here

          @Override
          public Entry<TripleKey, Triple> next() {
            if(this.triple==null){
              return null;
            }
            final Triple t = new Triple(new LazyLiteral(this.triple[GeneratorFromFinalRun.this.primaryMap]),
                new LazyLiteral(this.triple[GeneratorFromFinalRun.this.secondaryMap]),
                new LazyLiteral(this.triple[GeneratorFromFinalRun.this.tertiaryMap]));

            final TripleKey key = new TripleKey(t, GeneratorFromFinalRun.this.order);
View Full Code Here

    private void handleRun(final TrieSet searchtree,
        final Collection<Triple> triples, final TripleConsumer tc) {
      final int[] map = this.getMap(searchtree);

      for (final Triple triple : triples) {
        final Triple dummy = new Triple(triple.getPos(0),
            triple.getPos(1), triple.getPos(2));
        for (int pos = 0; pos < 3; pos++) {
          if (triple.getPos(pos).originalStringDiffers()) {
            dummy.setPos(
                pos,
                new LazyLiteralOriginalContent(
                    map[searchtree.getIndex(triple.getPos(
                        pos).toString())],
                        map[searchtree.getIndex(triple.getPos(
                            pos).originalString())]));
          } else {
            dummy.setPos(
                pos,
                new LazyLiteral(map[searchtree.getIndex(triple
                    .getPos(pos).toString())]));
          }
        }
View Full Code Here

    return null;
  }
 
  @Override
  public Message postProcessMessage(final StartOfEvaluationMessage msg) {
    Triple dummyTriple = new Triple();
    for(TripleConsumer to: this.getOperators()){
      if(!(to instanceof TriplePattern)){
        to.consume(dummyTriple);
      }
    }
View Full Code Here

    return msg;
  }
 
  @Override
  public Message postProcessMessageDebug(final StartOfEvaluationMessage msg, DebugStep debugstep) {
    Triple dummyTriple = new Triple();
    for(TripleConsumer to: this.getOperators()){
      if(!(to instanceof TriplePattern)){
        debugstep.step(this,(BasicOperator)to, dummyTriple);
        ((TripleConsumerDebug)to).consumeDebug(dummyTriple, debugstep);
      }
View Full Code Here

      number++;
      if (number % 1000000 == 0){
        System.err.println("#triples:" + number);
      }
      try {
        tc.consume(new Triple(transformToLiteral(ns[0]),
            transformToLiteral(ns[1]),
            transformToLiteral(ns[2])));
      } catch (URISyntaxException e) {
        System.err.println(e);
        e.printStackTrace();
View Full Code Here

            if (this.triplePatterns.size() != 1) {
              System.err.println("Can only process one triple pattern!");
            }
            final TriplePattern tp = this.triplePatterns.iterator()
                .next();
            final Triple key = getKey(tp, null);
            final Triple keyMinimum = this.getKeyMinimum(tp, null);
            final Triple keyMaximum = this.getKeyMaximum(tp, null);

            final IndicesTripleIterator[] ita = new IndicesTripleIterator[indicesC
                .size()];
            int id = 0;
            for (final Indices indices : indicesC) {
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.Triple

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.