Package net.sf.collabreview.repository

Examples of net.sf.collabreview.repository.TokenIndex


        new HashSet<ArtifactIdentifier>(Arrays.asList(ai[1], ai[6])),
        new HashSet<ArtifactIdentifier>(Arrays.asList(ai[0], ai[1], ai[2], ai[6])),
    };
    // do the test
    repository.setTrivialTokenFilter(new TrivialTokenFilter.NoneTrivialFilter());
    TokenIndex tokenIndex = repository.getTokenIndex();
    TokenOriginSearch tos = new TokenOriginSearch(repository);
    for (int i = 0; i < artifacts.length; i++) {
      Tokenizer tokenizer = new LineTokenizer(artifacts[i].getContent());
      assertEquals("Set " + i, expectedResults[i], new HashSet<ArtifactIdentifier>(tos.listRelatedArtifacts(tokenizer)));
      repository.addArtifact(ai[i], new Date(), artifacts[i].getContent(), artifactAuthor[i]);
      tokenIndex.addTokensFromArtifact(artifacts[i]);
      repository.getArtifact(ai[i]).setObsoleteDate(new Date(i));
    }
  }
View Full Code Here


  public void configure(ConfigurationData configuration) {
  }

  public OriginSearch create() throws Exception {
    assert owner != null;
    final TokenIndex li = owner.getTokenIndex();
    return new TokenOriginSearch(owner);
  }
View Full Code Here

    return true;
  }

  protected Collection<ArtifactIdentifier> listRelatedArtifacts(Tokenizer tokenizer) {
    assert repository.getTokenIndex() != null;
    TokenIndex tokenIndex = repository.getTokenIndex();
    TrivialTokenFilter filter = repository.getTrivialTokenFilter();
    Collection<ArtifactIdentifier> related = new HashSet<ArtifactIdentifier>();
    int trivialCount = 0;
    for (Token token : tokenizer.listTokens()) {
      if (!tokenIndex.isTrivialToken(token)) {
        //if (!filter.isTrivialToken(token)) {
        related.addAll(tokenIndex.getPossibleOccurrences(token));
      } else {
        trivialCount++;
      }
    }
    logger.debug("Related artifacts: " + related.size() + " (Trivial tokens: " + trivialCount + " out of " + tokenizer.listTokens().size() + " total)");
View Full Code Here

    for (int i = 0; i < 8; i++) {
      repository.addArtifact(ai[i], null, artifactContent[i], artifactAuthor[0]);
      repository.getArtifact(ai[i]).setObsoleteDate(new Date(i));
    }
    repository.commit();
    TokenIndex li = repository.getTokenIndex();
    assertEquals(new HashSet<ArtifactIdentifier>(Arrays.asList(ai[4])), new HashSet<ArtifactIdentifier>(li.getPossibleOccurrences(new IndexedTokenCore("Hello World!"))));
    assertEquals(new HashSet<ArtifactIdentifier>(Arrays.asList(ai[1], ai[6], ai[7])), new HashSet<ArtifactIdentifier>(li.getPossibleOccurrences(new IndexedTokenCore("World"))));
    assertEquals(new HashSet<ArtifactIdentifier>(Arrays.asList(ai[0], ai[1], ai[2], ai[6])), new HashSet<ArtifactIdentifier>(li.getPossibleOccurrences(new IndexedTokenCore("Hello"))));
  }
View Full Code Here

  public void testLineCertainty() throws Exception {
    for (int i = 0; i < 8; i++) {
      repository.addArtifact(ai[i], null, artifactContent[i], artifactAuthor[i]);
    }
    repository.commit();
    TokenIndex tokenIndex = repository.getTokenIndex();
    assertTrue("p(x)=" + tokenIndex.getCertainty(new IndexedTokenCore("Hello World!")), Math.abs(tokenIndex.getCertainty(new IndexedTokenCore("Hello World!")) - 0.917) < 0.125);
    assertTrue("p(x)=" + tokenIndex.getCertainty(new IndexedTokenCore("World")), Math.abs(tokenIndex.getCertainty(new IndexedTokenCore("World!")) - 0.794) < 0.0125);
    assertTrue("p(x)=" + tokenIndex.getCertainty(new IndexedTokenCore("Hello")), Math.abs(tokenIndex.getCertainty(new IndexedTokenCore("Hello")) - 0.735) < 0.0125);
  }
View Full Code Here

  public void testLineCertaintyOrder() throws Exception {
    for (int i = 0; i < 8; i++) {
      repository.addArtifact(ai[i], null, artifactContent[i], artifactAuthor[i]);
    }
    repository.commit();
    TokenIndex tokenIndex = repository.getTokenIndex();
    List<Token> results = tokenIndex.listMostCertainTokens(artifactContent[6], 7);
    // this test should print to the command line the following output:
    //  Results:
    // p("IndexedTokenCore(-1,-1,Yay!)")=0.917004
    // p("IndexedTokenCore(-1,-1,a)")=0.917004
    // p("IndexedTokenCore(-1,-1,test)")=0.917004
    // p("IndexedTokenCore(-1,-1,this)")=0.840896
    // p("IndexedTokenCore(-1,-1,is)")=0.840896
    // p("IndexedTokenCore(-1,-1,World)")=0.771105
    // p("IndexedTokenCore(-1,-1,Hello)")=0.707107
    System.out.println("Results: ");
    for (Token token : results) {
      System.out.println(String.format("p(\"%s\")=%f", token, tokenIndex.getCertainty(token)));
    }
    assertEquals(7, results.size());
    Token token = results.get(5);
    assertEquals(new IndexedTokenCore("World"), token);
    token = results.get(6);
View Full Code Here

TOP

Related Classes of net.sf.collabreview.repository.TokenIndex

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.