Package it.unimi.dsi.lang

Examples of it.unimi.dsi.lang.MutableString


     * @return An alignment iterator restricted to the sequence [start end] interval.
     */
    public final CloseableIterator<Alignment> query(String sequence, int start, int end, boolean contained) {
        LOG.debug(String.format("query %s %d %d %b%n", sequence, start, end, contained));

        final MutableString id = new MutableString(sequence);
        int referenceIndex = targetIdentifiers.getIndex(id);
        if (referenceIndex == -1) {
            // try again removing a chr prefix:
            referenceIndex = targetIdentifiers.getIndex(id.replace("chr", ""));
        }
        try {
            if (referenceIndex == -1) {
                // the reference could not be found in the Goby alignment, probably a wrong reference choice. Not sure how
                // to inform the end user, but we send no results here:
View Full Code Here


    }


    public String getValueString(double position, WindowFunction windowFunction) {
        //  //LOG.info("getValueString");
        MutableString buffer = new MutableString();

        buffer.append(entry.toString());
        buffer.replace("\n", "<br>");

        if (this.isPaired()) {
            buffer.append("----------------------" + "<br>");
            buffer.append("Mate start = " + getMate().positionString() + "<br>");
            buffer.append("Mate is mapped = " + (getMate().isMapped() ? "yes" : "no") + "<br>");
            //buf.append("Pair is proper = " + (getProperPairFlag() ? "yes" : "no") + "<br>");
            if (getChr().equals(getMate().getChr())) {
                buffer.append("Insert size = " + getInferredInsertSize() + "<br>");
            }
            if (getPairOrientation().length() > 0) {
                buffer.append("Pair orientation = " + getPairOrientation() + "<br>");
            }
            if (isFirstOfPair()) {
                buffer.append("First of pair <br>");
            }
            if (isSecondOfPair()) {
                buffer.append("Second of pair <br>");
            }
        }
        return buffer.toString();
    }
View Full Code Here

    BulletParser bulletParser = new BulletParser(
        TRECParsingFactory.INSTANCE);

    bulletParser.setCallback(new DefaultCallback() {
      TRECTopic topic = null;
      MutableString curText = new MutableString();
      Element curElement;

      @Override
      public boolean characters(char[] text, int offset, int length,
          boolean flowBroken) {
        curText.append(text, offset, length);
        return true;
      }

      @Override
      public boolean startElement(Element element,
          Map<Attribute, MutableString> attrMapUnused) {

        // --- New tag
        if (topic != null)
          process();

        // ---
        if (element == TRECParsingFactory.ELEMENT_TOP) {
          topic = new TRECTopic();
        }
        curElement = element;
        return true;
      }

      void removePrefix(String prefix, MutableString text) {
        if (text.startsWith(prefix))
          text.delete(0, prefix.length());

      }

      private void process() {
        curText.trim();
        curText.replace('\n', ' ');
        curText.squeezeSpaces(false);

        if (curElement == TRECParsingFactory.ELEMENT_TITLE) {
          removePrefix("Topic: ", curText);
          if (quoteCommas) {
            StringBuilder builder = new StringBuilder();
            boolean first = true;
            for (String part : curText.toString()
                .split("\\s*,\\s*")) {
              if (first)
                first = false;
              else
                builder.append(' ');

              if (part.indexOf(' ') >= 0) {
                builder.append('"');
                builder.append(part);
                builder.append('"');
              } else
                builder.append(part);
            }

            topic.title = builder.toString();
          } else
            topic.title = curText.toString();
        } else if (curElement == TRECParsingFactory.ELEMENT_NUM) {
          removePrefix("Number: ", curText);
          // Normalise the number
          topic.id = new Integer(curText.toString()).toString();
        } else if (curElement == TRECParsingFactory.ELEMENT_DESC) {
          removePrefix("Description: ", curText);
          topic.description = curText.toString();
        } else if (curElement == TRECParsingFactory.ELEMENT_NARR) {
          // TREC
          removePrefix("Narrative: ", curText);
          topic.narrative = curText.toString();
        } else if (curElement == TRECParsingFactory.ELEMENT_SMRY) {
          removePrefix("Summary: ", curText);
          topic.summary = curText.toString();
        } else if (curElement == TRECParsingFactory.ELEMENT_CON) {
          // TREC 1
          removePrefix("Concepts: ", curText);
          topic.concepts = curText.toString();
        } else if (curElement == TRECParsingFactory.ELEMENT_DEF) {
          // TREC 1
          removePrefix("Definition(s): ", curText);
          removePrefix("Definition: ", curText);
          topic.definitions = curText.toString();
        }
        curElement = null;
        curText.delete(0, curText.length());
      }

      @Override
      public boolean endElement(Element element) {
        if (topic != null)
View Full Code Here

        // FIXME: uses the same default reader as MG4J, but should be
        // adapted!
        FastBufferedReader reader = new FastBufferedReader();
        SimpleQuery.Term term = (SimpleQuery.Term) c;
        reader.setReader(new StringReader(term.getTerm()));
        MutableString word = new MutableString();
        MutableString nonWord = new MutableString();
        try {
          while (reader.next(word, nonWord)) {
            if (word.length() > 0)
              terms.add(new Term(term.getOperator(), word
                  .toString()));
View Full Code Here

   * @param text
   * @param terms
   */
  static private void addTerm(String text, Map<String, MutableInt> terms,
      TermProcessor processor, IndexConfiguration index) {
    MutableString word = new MutableString(text);
    // TODO: Annalina - when the query transformer is implemented, remove
    // the following and just keep the "update" line
    if (processor.processTerm(word)) {
      if (index.getTermId(word) != -1) {
        update(terms, word.toString());
        return;
      }
    }

    String[] array = text.split("-");
View Full Code Here

        public boolean startElement(Element element, Map<Attribute, MutableString> attributes) {
            if (charset[0] != null)
                return true;

            if (element == Element.META) {
                final MutableString httpEquiv = attributes.get(Attribute.HTTP_EQUIV);
                final MutableString content = attributes.get(Attribute.CONTENT);
                if (content != null && httpEquiv != null && httpEquiv.toLowerCase().equals("content-type")) {
                    charset[0] = retrieveCharsetFromContentType(content.toString());
//                    return charset[0] == null;
                    return true;
                }

                final MutableString metaCharset = attributes.get(Attribute.CHARSET);
                if  (metaCharset != null) {
                    charset[0] = getCharset(metaCharset.toUpperCase().toString());
                    return true;
//                    return charset[0] == null;
                }
            }
View Full Code Here

        BulletParser bulletParser = new BulletParser(
                TRECParsingFactory.INSTANCE);

        bulletParser.setCallback(new DefaultCallback() {
            TRECTopic topic = null;
            MutableString curText = new MutableString();
            Element curElement;

            @Override
            public boolean characters(char[] text, int offset, int length,
                                      boolean flowBroken) {
                curText.append(text, offset, length);
                return true;
            }

            @Override
            public boolean startElement(Element element,
                                        Map<Attribute, MutableString> attrMapUnused) {

                // --- New tag
                if (topic != null)
                    process();

                // ---
                if (element == ELEMENT_TOP) {
                    topic = new TRECTopic();
                }
                curElement = element;
                return true;
            }

            void removePrefix(String prefix, MutableString text) {
                if (text.startsWith(prefix))
                    text.delete(0, prefix.length());

            }

            private void process() {
                curText.trim();
                curText.replace('\n', ' ');
                curText.squeezeSpaces(false);

                if (curElement == ELEMENT_TITLE) {
                    removePrefix("Topic: ", curText);
                    if (quoteCommas) {
                        StringBuilder builder = new StringBuilder();
                        boolean first = true;
                        for (String part : curText.toString()
                                .split("\\s*,\\s*")) {
                            if (first)
                                first = false;
                            else
                                builder.append(' ');

                            if (part.indexOf(' ') >= 0) {
                                builder.append('"');
                                builder.append(part);
                                builder.append('"');
                            } else
                                builder.append(part);
                        }

                        topic.title = builder.toString();
                    } else
                        topic.title = curText.toString();
                } else if (curElement == ELEMENT_NUM) {
                    removePrefix("Number: ", curText);
                    // Normalise the number
                    topic.id = new Integer(curText.toString()).toString();
                } else if (curElement == ELEMENT_DESC) {
                    removePrefix("Description: ", curText);
                    topic.description = curText.toString();
                } else if (curElement == ELEMENT_NARR) {
                    // TREC
                    removePrefix("Narrative: ", curText);
                    topic.narrative = curText.toString();
                } else if (curElement == ELEMENT_SMRY) {
                    removePrefix("Summary: ", curText);
                    topic.summary = curText.toString();
                } else if (curElement == ELEMENT_CON) {
                    // TREC 1
                    removePrefix("Concepts: ", curText);
                    topic.concepts = curText.toString();
                } else if (curElement == ELEMENT_DEF) {
                    // TREC 1
                    removePrefix("Definition(s): ", curText);
                    removePrefix("Definition: ", curText);
                    topic.definitions = curText.toString();
                }
                curElement = null;
                curText.delete(0, curText.length());
            }

            @Override
            public boolean endElement(Element element) {
                if (topic != null)
View Full Code Here

              .document(results.get(i).document);
          Reader reader = (Reader) document.content(fieldIndex);
          WordReader wordReader = document.wordReader(fieldIndex);
          wordReader.setReader(reader);

          MutableString word = new MutableString();
          MutableString nonWord = new MutableString();
          final LongRBTreeSet set = new LongRBTreeSet();

          while (wordReader.next(word, nonWord)) {
            if (processor.processTerm(word)) {
              long termId = index.getTermId(word);
View Full Code Here

    private Result method1(Collection<MG4JRelevanceFeedback.MG4JDocument> feedback, ObjectArrayList<DocumentScoreInfo<Reference2ObjectMap<Index, SelectedInterval[]>>> results, int[] contents, long[] queryTerms) throws IOException {
        // Collect all words from documents and estimate P(w|R) and P(w|N)

        // Compute P(w q1 .. qn)
        MutableString separator = new MutableString();
        MutableString token = new MutableString();

        // Probability of P(w q1 ... qn) - Eq. 9 (model iid) and 12 (conditional)
        Long2DoubleLinkedOpenHashMap p_w_q = new Long2DoubleLinkedOpenHashMap();
        p_w_q.defaultReturnValue(0.);
View Full Code Here

     * @param document The document ID to read
     * @return A multiset containing the frequencies of the contained terms
     * @throws IOException
     */
    private Multiset<Long> readDocument(int[] contents, long document) throws IOException {
        MutableString separator = new MutableString();
        MutableString token = new MutableString();

        final Document doc = collection.document(document);
        long unknown = index.getUnknownTermId();

        Multiset<Long> words = HashMultiset.create();
View Full Code Here

TOP

Related Classes of it.unimi.dsi.lang.MutableString

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.