Exemplo n.º 1
0
  @Test
  public void segmentAndTokenizeTest() throws Exception {
    TreexServerExecution tse = new TreexServerExecution();
    tse.start();

    TreexServerConnection conn = tse.getConnection();

    conn.initScenario("cs", "W2A::Segment", "W2A::Tokenize");

    Object ret = conn.analyzeText("Ahoj světe! Hallo world! Nula se píše jako 0 .");

    conn.terminateServer();

    List<Map<String, Object>> treexRet = Utils.objectArrayToGenericList(ret);
    Assert.assertEquals(treexRet.size(), 3);

    List<Object> nodes1 = Utils.objectArrayToGenericList(treexRet.get(0).get("nodes"));
    Assert.assertEquals(nodes1.size(), 3);

    List<Object> nodes2 = Utils.objectArrayToGenericList(treexRet.get(1).get("nodes"));
    Assert.assertEquals(nodes2.size(), 3);

    List<Object> nodes3 = Utils.objectArrayToGenericList(treexRet.get(2).get("nodes"));
    Assert.assertEquals(nodes3.size(), 6);

    @SuppressWarnings("unchecked")
    Map<String, Object> toc = (Map<String, Object>) nodes3.get(4);

    Assert.assertEquals(toc.get("ord"), "5");
    Assert.assertEquals(toc.get("form"), "0");
  }
Exemplo n.º 2
0
  @Test(groups = "slow")
  public void unicodeSOHTest() throws Exception {
    TreexServerExecution tse = new TreexServerExecution();
    tse.show_treex_output = false;
    tse.start();

    TreexServerConnection conn = tse.getConnection();
    conn.initScenario("en", "W2A::Segment", "W2A::Tokenize");

    for (int i = 0; i <= 255; i++) {
      String str = i + " " + Character.toString((char) i);

      try {
        conn.analyzeText(str);
      } catch (Exception e) {
        System.err.format("case %d: break;\n", i);
        /**/
        conn.terminateServer();
        throw e;
        /**/
      }
    }

    conn.terminateServer();
  }
Exemplo n.º 3
0
  @Test(groups = "slow")
  public void morceTest() throws Exception {
    TreexServerExecution tse = new TreexServerExecution();
    tse.show_treex_output = true;
    tse.start();

    TreexServerConnection conn = tse.getConnection();

    conn.initScenario("en", "W2A::EN::Segment", "W2A::EN::Tokenize", "W2A::EN::TagMorce");

    logger.debug("Before first sentence.");
    Object ret = conn.analyzeText("Hallo world!");

    logger.debug("Before second sentence.");
    ret = conn.analyzeText("Life is great, isn't it?");

    logger.debug("Second sentence finished!");

    Object ret3 = conn.analyzeText("Zero is written as 0 .");

    logger.debug("Third sentence finished!");

    conn.terminateServer();

    List<Map<String, Object>> treexRet = Utils.objectArrayToGenericList(ret);
    Assert.assertEquals(treexRet.size(), 1);

    List<Object> nodes1 = Utils.objectArrayToGenericList(treexRet.get(0).get("nodes"));
    Assert.assertEquals(nodes1.size(), 8);

    List<Map<String, Object>> treexRet3 = Utils.objectArrayToGenericList(ret3);
    Assert.assertEquals(treexRet.size(), 1);

    List<Object> nodes3 = Utils.objectArrayToGenericList(treexRet3.get(0).get("nodes"));
    Assert.assertEquals(nodes3.size(), 6);

    @SuppressWarnings("unchecked")
    Map<String, Object> toc = (Map<String, Object>) nodes3.get(4);

    Assert.assertEquals(toc.get("ord"), "5");
    Assert.assertEquals(toc.get("form"), "0");
  }