Skip to content

Commit

Permalink
Restructured subpackages
Browse files Browse the repository at this point in the history
  • Loading branch information
tdaneyko committed Dec 13, 2019
1 parent 8b69565 commit a386340
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 83 deletions.
55 changes: 0 additions & 55 deletions src/main/java/de/tuebingen/sfs/jfst/Demo.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.alphabet;

import java.util.*;

Expand All @@ -20,23 +20,23 @@ public class Alphabet {
/**
* Create an empty Alphabet.
*/
Alphabet() {
public Alphabet() {
alphabet = new ArrayList<>();
id2sym = new ArrayList<>();
}

/**
* Create an Alphabet with symbols.
*/
Alphabet(String[] symbols) {
public Alphabet(String[] symbols) {
this();
addSymbols(symbols);
}

/**
* Create an Alphabet with symbols.
*/
Alphabet(Iterable<String> symbols) {
public Alphabet(Iterable<String> symbols) {
this();
addSymbols(symbols);
}
Expand All @@ -46,7 +46,7 @@ public class Alphabet {
* @param symbol A char symbol
* @return True if this Alphabet already contains the symbol
*/
boolean contains(char symbol) {
public boolean contains(char symbol) {
return Collections.binarySearch(alphabet, symbol) >= 0;
}

Expand All @@ -55,7 +55,7 @@ boolean contains(char symbol) {
* @param symbol A string symbol
* @return True if this Alphabet already contains the symbol
*/
boolean contains(String symbol) {
public boolean contains(String symbol) {
return Collections.binarySearch(alphabet, symbol) >= 0;
}

Expand All @@ -65,7 +65,7 @@ boolean contains(String symbol) {
* @param symbol A string symbol
* @return The Symbol object associated with this string
*/
Symbol getSymbol(String symbol) {
public Symbol getSymbol(String symbol) {
int i = Collections.binarySearch(alphabet, symbol);
if (i < 0) {
i = -(i+1);
Expand All @@ -80,14 +80,14 @@ Symbol getSymbol(String symbol) {
* @param id An id
* @return The symbol with this id or null if there is no such symbol
*/
Symbol getSymbol(int id) {
public Symbol getSymbol(int id) {
if (id < id2sym.size())
return id2sym.get(id);
else
return null;
}

void setSymbol(int id, String symbol) {
private void setSymbol(int id, String symbol) {
if (id >= id2sym.size())
addSymbol(symbol);
else {
Expand All @@ -99,7 +99,7 @@ void setSymbol(int id, String symbol) {
}
}

List<Symbol> getPrefixes(String s, int start) {
public List<Symbol> getPrefixes(String s, int start) {
List<Symbol> prefixes = new ArrayList<>();
char c = s.charAt(start);
// int i = Collections.binarySearch(alphabet, c);
Expand All @@ -121,15 +121,15 @@ List<Symbol> getPrefixes(String s, int start) {
* Add a symbol to the alphabet. Calls getSymbol() internally.
* @param symbol A symbol
*/
void addSymbol(String symbol) {
public void addSymbol(String symbol) {
getSymbol(symbol);
}

/**
* Add multiple symbols to the alphabet. Calls getSymbol() internally.
* @param symbols An array of symbols
*/
void addSymbols(String[] symbols) {
public void addSymbols(String[] symbols) {
int i = 0;
for (String sym : symbols) {
if (sym == null)
Expand All @@ -143,7 +143,7 @@ void addSymbols(String[] symbols) {
* Add multiple symbols to the alphabet. Calls getSymbol() internally.
* @param symbols A list of symbols
*/
void addSymbols(Iterable<String> symbols) {
public void addSymbols(Iterable<String> symbols) {
for (String sym : symbols) {
if (sym == null)
addSymbol("NULL");
Expand Down Expand Up @@ -174,7 +174,7 @@ private Symbol createSymbol(String symbol, int id) {
* Get the string representations of all symbols in this alphabet as an array, ordered according to their id.
* @return An array with all symols in this alphabet
*/
String[] getSymbols() {
public String[] getSymbols() {
return id2sym.stream().map(Symbol::asString).toArray(String[]::new);
}

Expand All @@ -183,15 +183,15 @@ String[] getSymbols() {
* @param symbol A string symbol
* @return The id of the symbol in this alphabet, or -1 if it is not contained
*/
int idOf(String symbol) {
public int idOf(String symbol) {
return (contains(symbol)) ? getSymbol(symbol).getId() : -1;
}

/**
* Get the total number of symbols in this alphabet.
* @return The size of this alphabet
*/
int size() {
public int size() {
return alphabet.size();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.alphabet;

/**
* A symbol consisting of a single character.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.alphabet;

/**
* A symbol consisting of multiple characters.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.alphabet;

/**
* A symbol in the alphabet of an FST.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.fst;

import de.tuebingen.sfs.jfst.alphabet.Alphabet;
import de.tuebingen.sfs.jfst.alphabet.Symbol;
import de.tuebingen.sfs.jfst.io.*;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.fst;

import java.io.IOException;
import java.io.OutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.fst;

import de.tuebingen.sfs.jfst.alphabet.Alphabet;

/**
* An iterator over the states and transitions of an FST.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.fst;

import de.tuebingen.sfs.jfst.io.FSTProducer;
import de.tuebingen.sfs.jfst.alphabet.Alphabet;
import de.tuebingen.sfs.jfst.alphabet.Symbol;
import de.tuebingen.sfs.jfst.io.BinaryFSTWriter;
import de.tuebingen.sfs.util.string.StringUtils;
import de.tuebingen.sfs.util.bin.BufferedByteReader;
import de.tuebingen.sfs.util.bin.IOUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.io;

import de.tuebingen.sfs.jfst.fst.FST;
import de.tuebingen.sfs.jfst.fst.FSTStateIterator;
import de.tuebingen.sfs.util.bin.IOUtils;
import gnu.trove.list.TIntList;
import gnu.trove.list.array.TIntArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.io;

import de.tuebingen.sfs.jfst.fst.FSTStateIterator;

public interface FSTFileStateIterator extends FSTStateIterator {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.io;

import de.tuebingen.sfs.jfst.alphabet.Symbol;

/**
* The original producer of a file. Currently supports SFST, HFST and JFST.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.io;

import de.tuebingen.sfs.jfst.alphabet.Alphabet;
import de.tuebingen.sfs.jfst.alphabet.Symbol;
import de.tuebingen.sfs.util.bin.BufferedByteReader;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.tuebingen.sfs.jfst;
package de.tuebingen.sfs.jfst.io;

import de.tuebingen.sfs.jfst.alphabet.Alphabet;
import de.tuebingen.sfs.jfst.alphabet.Symbol;
import de.tuebingen.sfs.util.bin.BufferedByteReader;
import de.tuebingen.sfs.util.bin.IOUtils;
import gnu.trove.list.TIntList;
Expand Down

0 comments on commit a386340

Please sign in to comment.