Examples of Alphabet


Examples of cc.mallet.types.Alphabet

  /**
   *
   */
  public FeatureSequenceConvolution() {
    // TODO Auto-generated constructor stub
    super(new Alphabet(), null);
  }
View Full Code Here

Examples of cc.mallet.types.Alphabet

    int inputVocabSize = 4;
    int numStates = 5;
    // Create a file to store the CRF
    File f = new File("TestObject.obj");
    File f2 = new File("TestObject2.obj");
    Alphabet inputAlphabet = new Alphabet();
    for (int i = 0; i < inputVocabSize; i++)
      inputAlphabet.lookupIndex("feature" + i);
    Alphabet outputAlphabet = new Alphabet();
    // Store the dictionary
    if (outputAlphabet == null) {
      System.err.println("Output dictionary null.");
    }
    MEMM crf = new MEMM(inputAlphabet, outputAlphabet);
View Full Code Here

Examples of cc.mallet.types.Alphabet

  private PipeUtils () {}; // no instances

  public static Pipe concatenatePipes (Pipe p1, Pipe p2)
  {
    Alphabet dataDict = combinedDataDicts (p1, p2);
    Alphabet targetDict = combinedTargetDicts (p1, p2);
    Pipe ret = new SerialPipes (new Pipe[] { p1, p2 });

    if (dataDict != null) ret.dataAlphabetResolved = true;
    if (targetDict != null) ret.targetAlphabetResolved = true;
   
View Full Code Here

Examples of cc.mallet.types.Alphabet

        LinkedHashSet<Integer> stateIndices = new LinkedHashSet<Integer>();
        stateIndices.add(labelIndex);
        labelToState.put(labelIndex, stateIndices);
      }
    } else {
      stateAlphabet = new Alphabet();

      labelIter = labelAlphabet.iterator();
      while (labelIter.hasNext()) {
        String label = (String) labelIter.next();
        labelToState.put(labelAlphabet.lookupIndex(label, false),
View Full Code Here

Examples of lexer.Alphabet

import lexer.Alphabet;

class TestAlphabet {
  public static void main(String args[]) throws Exception {
    // test Alphabet()
    Alphabet alpha = new Alphabet();
    if (alpha.size() != 0) {
      throw new Exception("Alphabet() size error");
    }

    // test Alphabet(java.lang.String s)
    StringBuffer sb = new StringBuffer();
    for (char ch='a'; ch<'z'; ch++) {
      sb.append(ch);
      sb.append(ch); // each character two times in a row
    }
    String str = new String(sb);
    alpha = new Alphabet(str);
    if (alpha.size() != str.length()/2) {
      if (alpha.size() != 0) {
        throw new Exception("Alphabet(String) size error");
      }
    }
    for (int i = 0; i<str.length()/2; i++) {
      if (alpha.getSymbol(i).charValue() != str.charAt(2*i)) {
        throw new Exception("Alphabet(String) content error");
      }
    }

    // test Alphabet(Alphabet alpha)
    Alphabet alpha2 = new Alphabet(alpha);
    if (alpha2 == alpha) {
      throw new Exception("Alphabet(Alphabet) same reference");
    }
    if (!alpha2.equals(alpha)) {
      throw new Exception("Alphabet(Alphabet) not the same");
    }

    // Add symbol
    int oldSize = alpha.size();
    alpha.addSymbol(alpha.getSymbol(0).charValue()); // already in there
    if (oldSize != alpha.size()) {
      throw new Exception("addSymbol(char) addad a symbol twice");
    }
    char symbol = '+';
    alpha.addSymbol(symbol);
    if (oldSize+1 != alpha.size()) {
      throw new Exception("addSymbol(char) symbol not added");
    }
    if (symbol != alpha.getSymbol(oldSize).charValue()) {
      throw new Exception("addSymbol(char) symbol not added properly");
    }

    // Test clear
    alpha2.clear();
    if (alpha2.size() != 0) {
      throw new Exception("clear(char) size error");
    }

    // Test toString()
    System.out.println(alpha.toString());

    // Test Other
    alpha = new Alphabet("0124301");
    for (char ch = 'a'; ch<='f'; ch++) {
      alpha.addSymbol(ch);
    }
    alpha.print();
    for (char ch = 'd'; ch<='h'; ch++) {
View Full Code Here

Examples of org.jboss.test.kernel.config.support.SimpleBean.Alphabet

      Float floatValue = new Float("3.14");
      Double doubleValue = new Double("3.14e12");
      Date dateValue = createDate(2001, 1, 1);
      BigDecimal bigDecimalValue = new BigDecimal("12e4");
      BigInteger bigIntegerValue = new BigInteger("123456");
      Alphabet enumValue = Alphabet.Z;

      HashSet<PropertyMetaData> attributes = new HashSet<PropertyMetaData>();
      attributes.add(new AbstractPropertyMetaData("AString", stringValue));
      attributes.add(new AbstractPropertyMetaData("AByte", byteValue));
      attributes.add(new AbstractPropertyMetaData("ABoolean", booleanValue));
      attributes.add(new AbstractPropertyMetaData("ACharacter", characterValue));
      attributes.add(new AbstractPropertyMetaData("AShort", shortValue));
      attributes.add(new AbstractPropertyMetaData("anInt", integerValue));
      attributes.add(new AbstractPropertyMetaData("ALong", longValue));
      attributes.add(new AbstractPropertyMetaData("AFloat", floatValue));
      attributes.add(new AbstractPropertyMetaData("ADouble", doubleValue));
      attributes.add(new AbstractPropertyMetaData("ADate", dateValue));
      attributes.add(new AbstractPropertyMetaData("ABigDecimal", bigDecimalValue));
      attributes.add(new AbstractPropertyMetaData("ABigInteger", bigIntegerValue));
      attributes.add(new AbstractPropertyMetaData("abyte", byteValue));
      attributes.add(new AbstractPropertyMetaData("aboolean", booleanValue));
      attributes.add(new AbstractPropertyMetaData("achar", characterValue));
      attributes.add(new AbstractPropertyMetaData("ashort", shortValue));
      attributes.add(new AbstractPropertyMetaData("anint", integerValue));
      attributes.add(new AbstractPropertyMetaData("along", longValue));
      attributes.add(new AbstractPropertyMetaData("afloat", floatValue));
      attributes.add(new AbstractPropertyMetaData("adouble", doubleValue));
      attributes.add(new AbstractPropertyMetaData("ANumber", longValue));
      attributes.add(new AbstractPropertyMetaData("overloadedProperty", stringValue));
      attributes.add(new AbstractPropertyMetaData("enumProperty", enumValue));

      AbstractBeanMetaData metaData = new AbstractBeanMetaData(SimpleBean.class.getName());
      metaData.setProperties(attributes);

      Kernel kernel = bootstrap();
      KernelConfigurator configurator = kernel.getConfigurator();
      SimpleBean bean = (SimpleBean)instantiateAndConfigure(configurator, metaData);

      assertEquals(stringValue, bean.getAString());
      assertEquals(byteValue, bean.getAByte());
      assertEquals(booleanValue, bean.getABoolean());
      assertEquals(characterValue, bean.getACharacter());
      assertEquals(shortValue, bean.getAShort());
      assertEquals(integerValue, bean.getAnInt());
      assertEquals(longValue, bean.getALong());
      assertEquals(floatValue, bean.getAFloat());
      assertEquals(doubleValue, bean.getADouble());
      assertEquals(dateValue, bean.getADate());
      assertEquals(bigDecimalValue, bean.getABigDecimal());
      assertEquals(bigIntegerValue, bean.getABigInteger());
      assertEquals(byteValue.byteValue(), bean.getAbyte());
      assertEquals(booleanValue.booleanValue(), bean.isAboolean());
      assertEquals(characterValue.charValue(), bean.getAchar());
      assertEquals(shortValue.shortValue(), bean.getAshort());
      assertEquals(integerValue.intValue(), bean.getAnint());
      assertEquals(longValue.longValue(), bean.getAlong());
      assertEquals(floatValue.floatValue(), bean.getAfloat());
      assertEquals(doubleValue.doubleValue(), bean.getAdouble());

      Number number = bean.getANumber();
      assertEquals(Long.class, number.getClass());
      assertEquals(longValue, number);
      assertEquals(stringValue, bean.getOverloadedProperty());

      Alphabet anenum = bean.getEnumProperty();
      assertEquals(enumValue, anenum);
   }
View Full Code Here

Examples of org.jsmpp.bean.Alphabet

        super(session, config);
        this.charset = Charset.forName(config.getEncoding());
    }

    protected SmppSplitter createSplitter(Message message) {
        Alphabet alphabet = determineAlphabet(message);

        String body = message.getBody(String.class);

        SmppSplitter splitter;
        switch (alphabet) {
View Full Code Here

Examples of org.jsmpp.bean.Alphabet

    protected final byte[] getShortMessage(Message message) {
        if (has8bitDataCoding(message)) {
            return message.getBody(byte[].class);
        } else {
            byte providedAlphabet = getProvidedAlphabet(message);
            Alphabet determinedAlphabet = determineAlphabet(message);
            Charset charset = determineCharset(providedAlphabet, determinedAlphabet.value());
            String body = message.getBody(String.class);
            return body.getBytes(charset);
        }
    }
View Full Code Here

Examples of org.jsmpp.bean.Alphabet

    private Alphabet determineAlphabet(Message message) {
        String body = message.getBody(String.class);
        byte alphabet = getProvidedAlphabet(message);

        Alphabet alphabetObj;
        if (alphabet == SmppConstants.UNKNOWN_ALPHABET) {
            byte[] messageBytes = body.getBytes(charset);
            if (SmppUtils.isGsm0338Encodeable(messageBytes)) {
                alphabetObj = Alphabet.ALPHA_DEFAULT;
            } else {
View Full Code Here

Examples of org.jsmpp.bean.Alphabet

      e.printStackTrace();
    }

    // configure variables acording to if message contains national
    // characters
    Alphabet alphabet = null;
    int maximumSingleMessageSize = 0;
    int maximumMultipartMessageSegmentSize = 0;
    byte[] byteSingleMessage = null;
    if (Gsm0338.isEncodeableInGsm0338(messageBody)) {
      byteSingleMessage = messageBody.getBytes();
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.