Examples of TypeAttribute


Examples of org.apache.lucene.analysis.tokenattributes.TypeAttribute

  private static void displayTokensWithFullDetails(TokenStream stream) throws IOException {
    final CharTermAttribute term = stream.addAttribute(CharTermAttribute.class);
    final PositionIncrementAttribute posIncr = stream.addAttribute(PositionIncrementAttribute.class);
    final OffsetAttribute offset = stream.addAttribute(OffsetAttribute.class);
    final TypeAttribute type = stream.addAttribute(TypeAttribute.class);
    int position = 0;
    while (stream.incrementToken()) {
      final int increment = posIncr.getPositionIncrement();
      if (increment > 0) {
        position = position + increment;
        System.out.println();
        System.out.print(position + ": ");
      }
      System.out.print("[" + term.toString() + ":" + offset.startOffset() + "->"
          + offset.endOffset() + ":" + type.type() + "] ");
    }
    System.out.println();
  }
View Full Code Here

Examples of org.apache.lucene.analysis.tokenattributes.TypeAttribute

        Analyzer a = getAnalyzer();
        TokenStream ts = a.tokenStream(field, new StringReader(termStr));
        int count = 0;
        boolean isCJ = false;
        try {
            TypeAttribute t = ts.addAttribute(TypeAttribute.class);
            ts.reset();
            while (ts.incrementToken()) {
                count++;
                isCJ = StandardTokenizer.TOKEN_TYPES[StandardTokenizer.CJ].equals(t.type());
            }
            ts.end();
        } catch (IOException e) {
            throw new ParseException(e.getMessage());
        } finally {
View Full Code Here

Examples of org.apache.lucene.analysis.tokenattributes.TypeAttribute

      record.put( "flags", narrowedAttr.getFlags() );
      return record;
    }
    else if ( attr instanceof TypeAttribute ) {
      GenericRecord record = new GenericData.Record( protocol.getType( "TypeAttribute" ) );
      TypeAttribute narrowedAttr = (TypeAttribute) attr;
      record.put( "type", narrowedAttr.type() );
      return record;
    }
    else if ( attr instanceof OffsetAttribute ) {
      GenericRecord record = new GenericData.Record( protocol.getType( "OffsetAttribute" ) );
      OffsetAttribute narrowedAttr = (OffsetAttribute) attr;
      record.put( "startOffset", narrowedAttr.startOffset() );
      record.put( "endOffset", narrowedAttr.endOffset() );
      return record;
    }
    else if ( attr instanceof Serializable ) {
      return ByteBuffer.wrap( toByteArray( (Serializable) attr ) );
    }
View Full Code Here

Examples of org.apache.lucene.analysis.tokenattributes.TypeAttribute

        Analyzer a = getAnalyzer();
        TokenStream ts = a.tokenStream(field, new StringReader(termStr));
        int count = 0;
        boolean isCJ = false;
        try {
            TypeAttribute t = ts.addAttribute(TypeAttribute.class);
            ts.reset();
            while (ts.incrementToken()) {
                count++;
                isCJ = StandardTokenizer.TOKEN_TYPES[StandardTokenizer.CJ].equals(t.type());
            }
            ts.end();
        } catch (IOException e) {
            throw new ParseException(e.getMessage());
        } finally {
View Full Code Here

Examples of org.apache.lucene.analysis.tokenattributes.TypeAttribute

 
  public void testFilterTokens() throws Exception {
    SnowballFilter filter = new SnowballFilter(new TestTokenStream(), "English");
    CharTermAttribute termAtt = filter.getAttribute(CharTermAttribute.class);
    OffsetAttribute offsetAtt = filter.getAttribute(OffsetAttribute.class);
    TypeAttribute typeAtt = filter.getAttribute(TypeAttribute.class);
    PayloadAttribute payloadAtt = filter.getAttribute(PayloadAttribute.class);
    PositionIncrementAttribute posIncAtt = filter.getAttribute(PositionIncrementAttribute.class);
    FlagsAttribute flagsAtt = filter.getAttribute(FlagsAttribute.class);
   
    filter.incrementToken();

    assertEquals("accent", termAtt.toString());
    assertEquals(2, offsetAtt.startOffset());
    assertEquals(7, offsetAtt.endOffset());
    assertEquals("wrd", typeAtt.type());
    assertEquals(3, posIncAtt.getPositionIncrement());
    assertEquals(77, flagsAtt.getFlags());
    assertEquals(new BytesRef(new byte[]{0,1,2,3}), payloadAtt.getPayload());
  }
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.optional.junit.FormatterElement.TypeAttribute

    BatchTest batchTest = junit.createBatchTest();
    batchTest.setFork(true);
    batchTest.setTodir(mxtest.getUnitTestOutputDir());
    batchTest.addFileSet(mxtest.getUnitTests());
   
    TypeAttribute xml = (TypeAttribute) TypeAttribute.getInstance(TypeAttribute.class, "xml");
    FormatterElement formatter = new FormatterElement();
    formatter.setProject(mxtest.getProject());
    formatter.setType(xml);
    junit.addFormatter(formatter);
View Full Code Here

Examples of ptolemy.actor.TypeAttribute

                if (actualPort instanceof TypedIOPort) {
                    TypedIOPort tiop = (TypedIOPort) actualPort;

                    if (_columnNames.contains(ColumnNames.COL_TYPE)) {
                        String _type = null;
                        TypeAttribute _typeAttribute = (TypeAttribute) tiop
                                .getAttribute("_type");

                        if (_typeAttribute != null) {
                            _type = _typeAttribute.getExpression();
                        }

                        String tableValue = (String) portInfo
                                .get(ColumnNames.COL_TYPE);
View Full Code Here

Examples of ptolemy.actor.TypeAttribute

                if (p instanceof TypedIOPort) {
                    TypedIOPort tiop = (TypedIOPort) p;

                    if (_columnNames.contains(ColumnNames.COL_TYPE)) {
                        TypeAttribute _type = (TypeAttribute) (tiop
                                .getAttribute("_type"));

                        if (_type != null) {
                            portInfo.put(ColumnNames.COL_TYPE, _type
                                    .getExpression());
                        } else {
                            portInfo.put(ColumnNames.COL_TYPE, "");
                        }
                    }
View Full Code Here

Examples of ptolemy.actor.TypeAttribute

        output = new WirelessIOPort(this, "output", false, true);
        output.outsideChannel.setExpression("$outputChannelName");

        // Since this actor sources the data at this port, we have to
        // declare the type.
        TypeAttribute portType = new TypeAttribute(output, "type");
        portType.setExpression("{location={double}, time=double, depth=int}");

        // Create an icon for this sensor node.
        EditorIcon node_icon = new EditorIcon(this, "_icon");

        // The icon has two parts: a circle and an antenna.
View Full Code Here

Examples of ptolemy.actor.TypeAttribute

        output = new WirelessIOPort(this, "output", false, true);
        output.outsideChannel.setExpression("$outputChannelName");

        // Since this actor sources the data at this port, we have to
        // declare the type.
        TypeAttribute portType = new TypeAttribute(output, "type");
        portType.setExpression("{location={double}, time=double}");
    }
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.