Skip to content

Commit

Permalink
Added nodeCounts.
Browse files Browse the repository at this point in the history
  • Loading branch information
antononcube committed Jan 9, 2017
1 parent 3f64a18 commit 173da1c
Showing 1 changed file with 49 additions and 45 deletions.
94 changes: 49 additions & 45 deletions Java/TriesWithFrequencies/src/Experiments.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@

public class Experiments {

public static void main( String args[] ) {
public static void main( String args[] ) {

basic();
}
basic();
}

public static void basic() {
public static void basic() {

// List<String> sampleSeq = new ArrayList<String>() {{
// add("arm"); add("arms"); add("arc"); add("bar"); add("bark"); add("barman"); add("arcola"); }};

List<String> sampleSeq = new ArrayList<String>() {{
add("a;r;m"); add("a;r;m;s"); add("a;r;c"); add("b;a;r"); add("b;a;r;k"); add("b;a;r;m;a;n"); add("a;r;c;o;l;a"); }};
List<String> sampleSeq = new ArrayList<String>() {{
add("a;r;m"); add("a;r;m;s"); add("a;r;c"); add("b;a;r"); add("b;a;r;k"); add("b;a;r;m;a;n"); add("a;r;c;o;l;a"); }};


// List< List<String> > sampleSeqList = new ArrayList<>();
Expand All @@ -69,58 +69,62 @@ public static void basic() {
//
// Trie strie = TrieFunctions.create( sampleSeqList );

Trie strie = TrieFunctions.createBySplit( sampleSeq, ";");
Trie strie = TrieFunctions.createBySplit( sampleSeq, ";");

System.out.println("strie = ");
System.out.println( strie );
System.out.println();
System.out.println("strie = ");
System.out.println( strie );
System.out.println();

sampleSeq = new ArrayList<String>() {{
add("bark"); add("barkeeper"); add("barkeepers"); add("barkeep"); add("barks");
add("barking"); add("barked"); add("barker"); add("barkers"); }};
sampleSeq = new ArrayList<String>() {{
add("bark"); add("barkeeper"); add("barkeepers"); add("barkeep"); add("barks");
add("barking"); add("barked"); add("barker"); add("barkers"); }};

strie = TrieFunctions.createBySplit( sampleSeq, "");
strie = TrieFunctions.createBySplit( sampleSeq, "");

System.out.println( "shrink trie:");
System.out.println( TrieFunctions.shrink( strie, ":" ) );
System.out.println();
System.out.println( "shrink trie:");
System.out.println( TrieFunctions.shrink( strie, ":" ) );
System.out.println();

List<String> sword = new ArrayList() {{ add("a"); add("r"); add("m"); add("e"); add("d"); }};
System.out.println("For " + sword );
System.out.println( "contains: " + TrieFunctions.contains( strie, sword ) );
System.out.println( "position: " + TrieFunctions.position( strie, sword ) );
System.out.println( "complete match: " + TrieFunctions.completeMatch( strie, sword ));
System.out.println();
List<String> sword = new ArrayList() {{ add("a"); add("r"); add("m"); add("e"); add("d"); }};
System.out.println("For " + sword );
System.out.println( "contains: " + TrieFunctions.contains( strie, sword ) );
System.out.println( "position: " + TrieFunctions.position( strie, sword ) );
System.out.println( "complete match: " + TrieFunctions.completeMatch( strie, sword ));
System.out.println();

sword = new ArrayList() {{ add("a"); add("r"); add("m"); }};
sword = new ArrayList() {{ add("a"); add("r"); add("m"); }};

System.out.println("For " + sword );
System.out.println( "contains: " + TrieFunctions.contains( strie, sword ) );
System.out.println( "position: " + TrieFunctions.position( strie, sword ) );
System.out.println( "complete match: " + TrieFunctions.completeMatch( strie, sword ));
System.out.println();
System.out.println("For " + sword );
System.out.println( "contains: " + TrieFunctions.contains( strie, sword ) );
System.out.println( "position: " + TrieFunctions.position( strie, sword ) );
System.out.println( "complete match: " + TrieFunctions.completeMatch( strie, sword ));
System.out.println();

Trie ftrie = TrieFunctions.retrieve( strie, sword );
System.out.println("ftrie = ");
System.out.println( ftrie + "\n" );
Trie ftrie = TrieFunctions.retrieve( strie, sword );
System.out.println("ftrie = ");
System.out.println( ftrie + "\n" );

Trie pstrie = TrieFunctions.nodeProbabilities( strie );
Trie pstrie = TrieFunctions.nodeProbabilities( strie );

System.out.println("pstrie = ");
System.out.println( pstrie + "\n" );
System.out.println("pstrie = ");
System.out.println( pstrie + "\n" );


System.out.println("strie = ");
System.out.println( strie + "\n" );
System.out.println("strie = ");
System.out.println( strie + "\n" );

sword = new ArrayList() {{ add("a"); add("r"); }};
System.out.println( "words for:" + sword );
System.out.println( TrieFunctions.getWords( strie, sword ) );
System.out.println();
sword = new ArrayList() {{ add("a"); add("r"); }};
System.out.println( "words for:" + sword );
System.out.println( TrieFunctions.getWords( strie, sword ) );
System.out.println();

System.out.println( "paths to JSON:");
System.out.println( TrieFunctions.pathsToJSON( TrieFunctions.rootToLeafPaths( strie) ) );
System.out.println();
System.out.println( "paths to JSON:");
System.out.println( TrieFunctions.pathsToJSON( TrieFunctions.rootToLeafPaths( strie) ) );
System.out.println();

System.out.println( "node counts:");
System.out.println( TrieFunctions.nodeCounts( strie) );
System.out.println();

// sampleSeq = new ArrayList<String>() {{ add("ar"); add("as"); }};
// List< List<String> > sampleSeqList = new ArrayList<>();
Expand All @@ -131,6 +135,6 @@ public static void basic() {
// strie = TrieFunctions.create( sampleSeqList );
//
// System.out.println( strie.toJSON() );
}
}

}

0 comments on commit 173da1c

Please sign in to comment.