id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
889c709c-097a-4db1-b8df-aee3d504ef5a | public static void main(String[] args) {
try {
/**
* Connect to Mongo DB
*/
MongoClient mongo = new MongoClient("oceanic.mongohq.com", 10099);
/**
* Connect to DB
*/
DB db = mongo.getDB("luckypants");
if (db == null) {
System.out.println("Could not connect to Database");
}
... |
cf9400b5-6b94-4631-b4f0-0220b036d238 | public void wordMakeSets(){
System.out.println(">> AGRUPANDO PALAVRAS POR SEMELHANCA... AGUARDE.");
TreeMap<Integer, ArrayList<String>> tree = new TreeMap<Integer, ArrayList<String>>();
for (Map.Entry<String, DisjointSet> entry : this.entrySet()) {
if (tree.get(entry.getKey().length(... |
13349416-612c-4d0b-b342-2d215bbee04b | public void printSimilarities(){
System.out.println(">> IMPRIMINDO PALAVRAS POR ORDEM DE SEMELHANCA... AGUARDE.");
TreeMap<String, ArrayList<String>> treeSupport = new TreeMap<String, ArrayList<String>>();
for (Map.Entry<String, DisjointSet> entry : this.entrySet()) {
if (treeSupport... |
9bb34da8-3e85-4084-926c-b8f43f102862 | public static void main(String[] args) throws FileNotFoundException, IOException{
Scanner scan = new Scanner(System.in);
String file = "ptb-flat.txt";
WordsTree tree = new WordsTree();
boolean on = true;
while(on) {
System.out.println("BEM-VINDO AO EXTRACTDICTIONARY... |
bc86f7ca-38cb-449a-80e3-f0975df8864c | public static boolean isSimilar(String s, String s2){
if (Math.abs(s.length() - s2.length()) > 1 ) {
return false;
}
return compute(s, s2) == 1;
} |
b3ae3164-0406-4833-a39e-8d10d5ba25a8 | public static int compute(String stringOne, String stringTwo) {
stringOne = stringOne.toLowerCase();
stringTwo = stringTwo.toLowerCase();
int[] costs = new int[stringTwo.length() + 1];
for (int i = 0; i <= stringOne.length(); i++) {
int lastValue = i;
for (int j =... |
18b36056-c0ba-4e66-bf79-b7ee6d2c5a13 | @Before
public void setUp() throws Exception {
parser = new AdverbPTBParser("ptp-flat-test.txt");
} |
2da05382-1aca-4610-8a8b-8e5990d3f37f | @After
public void tearDown() throws Exception {
parser = null;
} |
22e387fc-2040-4205-adee-5bc725fb9909 | @Test
public void testParse() throws IOException{
TreeMap<String, DisjointSet> tree = new TreeMap<String, DisjointSet>();
parser.parse(tree);
assertEquals(tree.get("mistakenly").getWord(), "mistakenly");
} |
6b930e5d-3cbf-4e82-8b6a-731bc2a22004 | @Test
public void testIsWord() {
assertEquals(true, parser.isWord("word)"));
} |
5362cc9f-bf9f-444a-aa13-2aaf676b81f4 | @Test
public void testIsAdverb(){
assertEquals(true, parser.isAdverb("(RB"));
} |
5308b5e5-e4de-4d3d-9615-4d7eff958445 | @Test
public void isSimilarTest() {
boolean similar = WordSimilarity.isSimilar("bold", "bald");
assertTrue(similar);
similar = WordSimilarity.isSimilar("longerword", "shortword");
assertFalse(similar);
similar = WordSimilarity.isSimilar("loooong", "short");
assertFalse(similar);
} |
58561e31-efe7-4d81-86c9-3c477ff27b50 | @Test
public void computeTest() {
int computed = WordSimilarity.compute("bold", "bald");
assertEquals(1, computed);
} |
bdef2527-7714-4cc8-95ed-759978d4ce58 | @Before
public void setUp() throws Exception {
parser = new VerbPTBParser("ptp-flat-test.txt");
} |
592371a8-d4a2-4c51-b87a-db11862dc420 | @After
public void tearDown() throws Exception {
parser = null;
} |
a36c49fe-41b6-46ec-bc58-e8d613e7bb29 | @Test
public void testParse() throws IOException{
TreeMap<String, DisjointSet> tree = new TreeMap<String, DisjointSet>();
parser.parse(tree);
assertEquals(tree.get("plays").getWord(), "plays");
} |
498cf781-1e75-4467-8ff8-bedf35e25a3c | @Test
public void testIsWord() {
assertEquals(true, parser.isWord("word)"));
} |
11006d15-73b6-46e7-8c80-2f912a7e1777 | @Test
public void testIsSubstantive(){
assertEquals(true, parser.isVerb("V"));
} |
fc156cfc-09fd-4bb9-adee-4be4f73af60f | @Before
public void setUp() throws Exception {
parser = new AllPTBParser("ptp-flat-test.txt");
} |
96cbe073-23ca-4e1e-b433-50e39ce0469f | @After
public void tearDown() throws Exception {
parser = null;
} |
118c3251-b1c8-49e9-bcdf-fde549050a36 | @Test
public void testParse() throws IOException{
TreeMap<String, DisjointSet> tree = new TreeMap<String, DisjointSet>();
parser.parse(tree);
assertEquals(tree.get("steady").getWord(), "steady");
} |
5bcdc458-b7a3-485e-b5cd-43e9a95a12af | @Test
public void testIsWord() {
assertEquals(true, parser.isWord("word)"));
} |
f988bf6b-ce8c-47cc-888f-504d5abacedf | @Before
public void setUp() throws Exception {
parser = new AdjectivePTBParser("ptp-flat-test.txt");
} |
49f9fa7c-2c91-449b-b0ed-ab9c0ea2ce82 | @After
public void tearDown() throws Exception {
parser = null;
} |
bd8c76bb-e413-4bef-865f-9722e991eef1 | @Test
public void testParse() throws IOException{
TreeMap<String, DisjointSet> tree = new TreeMap<String, DisjointSet>();
parser.parse(tree);
assertEquals(tree.get("steady").getWord(), "steady");
} |
605f7179-fe0f-4c7b-8578-c87358bcb9c8 | @Test
public void testIsWord() {
assertEquals(true, parser.isWord("word)"));
} |
c5c62060-4967-4681-97bc-c1cd6e51244a | @Test
public void testIsSubstantive(){
assertEquals(true, parser.isAdjective("JJ"));
} |
80dba292-ee4c-4f1a-ab62-ae6406aa6715 | @Before
public void setUp() throws Exception {
parser = new SubstantivePTBParser("ptp-flat-test.txt");
} |
aa88ce6f-f94b-43ab-adbe-af850d2146cf | @After
public void tearDown() throws Exception {
parser = null;
} |
573f2697-a792-46ed-9a18-a185705d2a17 | @Test
public void testParse() throws IOException{
TreeMap<String, DisjointSet> tree = new TreeMap<String, DisjointSet>();
parser.parse(tree);
assertEquals(tree.get("Haag").getWord(), "Haag");
} |
214b97be-69a8-42a6-8598-ba16c53c850f | @Test
public void testIsWord() {
assertEquals(true, parser.isWord("word)"));
} |
8ced9187-c59a-4fde-afa8-68f363b0136f | @Test
public void testIsSubstantive(){
assertEquals(true, parser.isSubstantive("NNP"));
} |
65c3ec69-dc81-48a3-9b94-ad358079d2af | public AdjectivePTBParser(String file) throws FileNotFoundException {
this.file = new FileReader(file);
} |
17acfd86-11b4-4761-a684-1b484251123e | public void parse(TreeMap tree) throws IOException {
System.out.println(">> EXTRAINDO TODOS OS ADJETIVOS");
BufferedReader br = new BufferedReader(file);
String line = null;
while((line = br.readLine()) != null) {
String[] elements = line.split(" ");
for (int i = 0... |
39dd0449-2bb3-49be-b085-b35023195aab | public boolean isWord(String s) {
return s.contains(")") && (s.charAt(0) != '.');
} |
65b95e5c-2b6b-4b64-829d-cf2a26555309 | public boolean isAdjective(String s) {
return s.contains("JJ");
} |
1de11a77-7784-46ec-9c24-389231382be3 | public VerbPTBParser(String file) throws FileNotFoundException {
this.file = new FileReader(file);
} |
9c1c84ed-0bf2-4a17-8f0e-749efc557a9a | @Override
public void parse(TreeMap tree) throws IOException {
System.out.println(">> EXTRAINDO TODOS OS VERBOS");
BufferedReader br = new BufferedReader(file);
String line = null;
while((line = br.readLine()) != null) {
String[] elements = line.split(" ");
for ... |
38646b60-0ae3-42f1-94a1-0e3856a639f3 | public boolean isWord(String s) {
return s.contains(")") && (s.charAt(0) != '.');
} |
4d780eaa-2ce7-4c28-b681-ebd4fea8a31c | public boolean isVerb(String s) {
return s.contains("V");
} |
86a02295-8baa-4834-93a8-668d5c2c3e32 | public void parse(TreeMap tree) throws IOException; |
b445a4cc-1d9e-4265-8fa2-2a28b71a2926 | public AllPTBParser(String file) throws FileNotFoundException {
this.file = new FileReader(file);
} |
0f6a52b5-ae6a-455c-bc74-5ca8bc6e59b1 | public void parse(TreeMap tree) throws IOException {
System.out.println(">> EXTRAINDO TODAS AS PALAVRAS");
BufferedReader br = new BufferedReader(file);
String line = null;
while((line = br.readLine()) != null) {
String[] elements = line.split(" ");
for (String s : e... |
ec55ba06-8cc1-4a09-8ca2-1dd1f71e40b8 | public boolean isWord(String s) {
return s.contains(")") && (s.charAt(0) != '.');
} |
eb80ac36-63cc-419e-9d41-3765d64f30cd | public SubstantivePTBParser(String file) throws FileNotFoundException {
this.file = new FileReader(file);
} |
522b1dcb-70ec-4eff-8463-f4d58b053391 | @Override
public void parse(TreeMap tree) throws IOException {
System.out.println(">> EXTRAINDO TODOS OS SUBSTANTIVOS");
BufferedReader br = new BufferedReader(file);
String line = null;
while((line = br.readLine()) != null) {
String[] elements = line.split(" ");
fo... |
0823012e-9848-4260-910d-09947d995ede | public boolean isWord(String s) {
return s.contains(")") && (s.charAt(0) != '.');
} |
eb2d60cf-53bb-412b-a90d-ad73979cc16e | public boolean isSubstantive(String s) {
return s.contains("NN");
} |
9f02127e-0b65-48e6-afd7-5131df80759b | public AdverbPTBParser(String file) throws FileNotFoundException {
this.file = new FileReader(file);
} |
14be4745-c7d7-4ed5-81b8-3314c5553b75 | public void parse(TreeMap tree) throws IOException {
System.out.println(">> EXTRAINDO TODOS OS ADVERBIOS");
BufferedReader br = new BufferedReader(file);
String line = null;
while((line = br.readLine()) != null) {
String[] elements = line.split(" ");
for (int i = 0; ... |
4d13961e-501f-44e2-ae51-b1ebcc9cba59 | public boolean isAdverb(String s) {
return s.contentEquals("(RB");
} |
4854ba57-6194-4da8-930d-75016377a4d2 | public boolean isWord(String s) {
return s.contains(")") && (s.charAt(0) != '.');
} |
19864eea-1419-4776-a16c-7a5a43e97a26 | public DisjointSet(String word) {
this.reference = this;
this.word = word;
} |
efcdbdf5-792b-47f3-9132-faaa1fe868d4 | public DisjointSet(DisjointSet reference, String word) {
this.reference = reference;
this.word = word;
} |
16d74e69-eafd-4ce1-a14e-68bdb9668191 | public void union(DisjointSet other) {
// Se this tiver o grau maior, a referência vai para o other.
if (this.getDegree() > other.getDegree()) {
this.getReference().setReference(other.getReference());
other.getReference().setDegree(this.getDegree());
}
// Caso con... |
6bc5fb5e-a849-44b7-8094-3d829a2f2073 | public boolean findSet(DisjointSet ds, String word) {
if (ds.reference == ds) return false;
if (ds.word == word) return true;
findSet(ds.reference, word);
return false;
} |
a20d2233-2ed7-4299-9a2a-b52d89b998a8 | public boolean isSimilar(DisjointSet other) {
return WordSimilarity.isSimilar(this.word, other.getWord());
} |
2bbd4389-3760-4800-85eb-0b34d554e0d1 | private void increaseDegree() {
this.degree++;
} |
0ed7587e-8c7a-4ae9-90a1-8bf958552961 | public DisjointSet getReference() {
DisjointSet lastRef = this;
while (reference.getWord() != lastRef.getWord()) {
lastRef = reference;
setReference(reference.getReference());
}
return reference;
} |
e45dd538-8815-4785-a913-880846e2cb17 | public void setReference(DisjointSet reference) {
this.reference = reference;
} |
95a18f56-2c27-4093-a2d7-766aa73745c2 | public String getWord() {
return word;
} |
2d86b672-6318-403f-ad50-3b90e22e0a6e | public void setWord(String word) {
this.word = word;
} |
fafa52ad-6ccd-4b0c-b68e-35064ab69039 | public int getDegree() {
if (this.getReference() == this) {
return this.degree;
}
else return this.reference.getDegree();
} |
07a60db5-7b24-44fe-8cb1-a362ae95443c | public void setDegree(int degree) {
this.degree = degree;
} |
b681636b-7dde-40c5-aaf4-b3ec85adf5f4 | public static void main(String[] args) {
int length = args.length;
FixedSizeChunking fix = null;
FileBasedChunking file = null;
RabinKarpRollingHash rabin = null;
try {
if (length == 0) {
throw new RuntimeException("Keyword is needed.");
} else if (length == 1) {
throw new RuntimeException("Two ... |
1b614dce-bd7d-42e0-bdef-b717e5d693c2 | public Checksum() {
try {
md = MessageDigest.getInstance("SHA1");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
} |
e8ec0a5e-0c3c-4001-9ee4-37f73b1d22b4 | public String generateChecksum(String filepath, String filename) {
try {
fis = new FileInputStream(filepath);
byte[] dataBytes = new byte[1024];
int nread = 0;
while ((nread = fis.read(dataBytes)) != -1) {
md.update(dataBytes, 0, nread);
}
} catch (FileNotFoundException e) {
e.printStackTra... |
ed65eeea-d20c-4b4b-b967-e854a97318a3 | public String chunking(byte[] dataBytes){
md.update(dataBytes);
byte[] mdbytes = md.digest();
String result = byteToHex(mdbytes);
return result;
} |
414d2791-4d8d-4e8c-aed1-be09e955be02 | public String byteToHex(byte[] mdbytes) {
StringBuffer sb = new StringBuffer("");
for (int i = 0; i < mdbytes.length; i++) {
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16)
.substring(1));
}
return sb.toString();
} |
3aa040e8-1059-422f-9bc2-191c45eb0c54 | public FixedSizeChunking(String directory) {
indexTable = new Hashtable<String, String>();
sum = new Checksum();
// list = new FileList(Config.DIRECTORY);
list = new FileList(directory);
count = 0;
} |
bdc6f16a-fe3d-41d1-89d9-531994f52c20 | public void setAll(File[] fileList) {
// Read each file and perform fixed-size chunking
byte[] chunk = new byte[Config.FIXED_CHUNKING];
for (File f : fileList) {
count = 0;
if (f.isFile() && !f.isHidden()) {
// Read file into a byte array and use SHA-1 hash the chunk
try {
fis = new FileInputSt... |
edb0857b-9d14-4cc2-bf63-3093fd2abefb | public FileList(String path) {
this.path = path;
root = new File(path);
filelist = root.listFiles();
} |
a238071c-f908-4fab-9f1e-bdd44699d08d | public String getList() {
String files = "";
for (File f : filelist) {
if (f.isDirectory()) {
// System.out.println("Dir:" + f.getAbsoluteFile());
} else {
// System.out.println("File:" + f.getAbsoluteFile());
files += f.getName() + "\n";
}
}
return files;
} |
c05b2ce6-c229-4217-9a8d-03a54bf88f3d | public String getList(String name) {
String files = "";
for (File f : filelist) {
if (f.isDirectory()) {
// System.out.println("Dir:" + f.getAbsoluteFile());
} else {
// System.out.println("File:" + f.getAbsoluteFile());
if (f.getAbsolutePath().contains(name))
files = f.getAbsolutePath();
... |
4424f61a-9e49-402f-a436-9f13cce290e8 | public String getFile(int index) {
int length = filelist.length;
if (index < 0 || index >= length) {
System.out.println("invalid index, please check input");
return null;
}
if (filelist[index].isDirectory()) {
System.out.println("Folder is not supported, please choose a file");
return null;
}
re... |
49a46755-f307-46f8-9e9e-0c2115ce0105 | public RabinKarpRollingHash(String directory) {
indexTable = new Hashtable<String, String>();
sum = new Checksum();
// list = new FileList(Config.DIRECTORY);
list = new FileList(directory);
window = 1024; // initial window size
} |
7edab6e7-fc9c-48c3-92c5-e126392ed7df | public void initialize() {
mult = 1;
buffptr = 0;
} |
ae9f0004-6cb7-4855-801f-db18ce339c8c | public void setAll(File[] fileList) {
for (File file : fileList) {
if (file.isFile() && !file.isHidden()) {
initialize();
displayChunks(file);
}
}
} |
c58f4b76-d4aa-4d77-bad3-cd756a9d5603 | public void displayChunks(File filelocation) {
int mask = 1 << 13;
mask--; // 13 bit of '1's
File f = filelocation;
FileInputStream fs = null; // For sliding window
FileInputStream fsChunk = null; // For chunking the input stream
BufferedInputStream bis = null;
try {
fs = new FileInputStream(f);
fs... |
21376fd4-440d-4d27-89f9-d0a983c5ef3c | public int nexthash(int prevhash) throws IOException {
int c = is.read(); // next byte from stream
prevhash -= mult * buffer[buffptr]; // remove the last value
prevhash *= hconst; // multiply the whole chain with prime
prevhash += c; // add the new value
buffer[buffptr] = c; // circular buffer, 1st pos == la... |
49f7c632-4fa0-4c41-a042-fe56beaeb95e | public int inithash(int length) throws IOException {
buffer = new int[length]; // create circular buffer
int hash = 0;
// calculate the hash sum of p^n * a[x]
for (int i = 0; i < length; i++) {
int c = is.read();
if (c == -1) // file is shorter than the required window size
break;
// store byte ... |
f89f2e3d-d526-4822-b0ba-9d6cd4c7e3bc | public FileBasedChunking(String directory) {
indexTable = new Hashtable<String, String>();
sum = new Checksum();
// list = new FileList(Config.DIRECTORY);
list = new FileList(directory);
count = 0;
} |
c75d80fd-bb66-4d18-8c3a-5c1fbe8dcf11 | public void setAll(File[] fileList) {
for (File f : fileList) {
count = 0;
if (f.isFile() && !f.isHidden()) {
String checksum = sum.generateChecksum(f.getAbsolutePath(),
f.getName());
if (duplicateDetection(checksum)) {
System.out.println(++count + " duplicate files found: "
+ f.getNam... |
e36ed8a6-598b-4c54-b5f8-4177804fe2eb | public boolean duplicateDetection(String hashvalue) {
return indexTable.containsKey(hashvalue);
} |
ffb4b96a-e1b0-4530-b388-41c07de2464b | public static void main(String[] args) {
// TODO code application logic here
long startTime = 0, elapsedTime = 0;
// Parses the command line arguments and collects all data in memory
Util sudoku = new Util(args);
// Constructs Sudoku Boards and stores them in an array
Sudoku... |
f977a69f-f3fb-40f1-bca8-dcd4f5cf3102 | public FileIO() {
pathLocation = null;
fileReader = null;
buffer = null;
file = null;
} |
5aceffcd-55bc-4a83-989a-e744326b350e | public FileIO(String pathLocation) {
file = new File(pathLocation);
if (!file.exists()) {
System.out.println("File or Directory not found. Loading default Folder SudokuBoards/");
loadPathLocation("SudokuBoards/");
}
else {
this.pathLocation = pathLocation;
}
} |
76734688-5fc3-4edc-b29b-cda886874732 | public void loadPathLocation(String pathLocation) {
file = new File(pathLocation);
if (!file.exists()) {
System.out.println("File or Directory not found. Path not Loaded");
try {
System.out.println("Put boards in " + new java.io.File(".").getCanonicalPath() + "/SudokuBoards/");
} catch (IOException ... |
141cb66e-0bd2-4334-bc36-1ca6fcdb85eb | public String[] loadAllBoardData() {
if (pathLocation == null) {
System.out.println("No loaded Path Location");
return new String[1];
}
// Ensures the filename matches the sudoku format //
String[] loadedData = null;
String[] parseFiles = pathLocation.split("\\.");
if (parseFiles.length == 2 ... |
23ff256d-b7f4-42b5-a96b-c87aeab1861d | private String rawBoardData() {
return rawBoardData(pathLocation);
} |
6d9928af-3691-4ab6-998c-69a84fb0987b | private String rawBoardData(String pathname) {
dataBuilder = new StringBuilder();
try {
fileReader = new FileReader(pathname);
buffer = new BufferedReader(fileReader);
String dataline = new String();
while ((dataline = buffer.readLine()) != null) {
dataBuilder.append(dataline + hyphen);
}
... |
564d73a8-aaf0-4720-8c9f-c5b4fdf95bb6 | public static void Seed(SudokuBoard board) {
switch (board.size) {
case 2:
Seedby2(board);
break;
case 3:
Seedby3(board);
break;
case 4:
Seedby4(board);
break;
case 5:
Seedby5(board);
break;
default:
System.out.println("Improper program path");
System.exit(0);
break;
}
... |
a02057d9-f427-48aa-99ab-931771b27515 | private static void Seedby2(SudokuBoard board) {
} |
41faff3b-1014-48b4-a56b-5ef5e2efa380 | private static void Seedby3(SudokuBoard board) {
board.setValue(0, 2, String.valueOf(7));
board.setValue(0, 3, String.valueOf(9));
board.setValue(0, 5, String.valueOf(6));
board.setValue(0, 6, String.valueOf(3));
board.setValue(1, 0, String.valueOf(3));
board.setValue(1, 8, String.valueOf(4));
board.se... |
5d0af92e-ba2d-44d2-bf9c-dac0779ac17d | private static void Seedby4(SudokuBoard board) {
} |
00ab52e6-0af1-4fb7-9e12-31e9a866f80c | private static void Seedby5(SudokuBoard board) {
} |
cb46e8f6-4983-4801-9dd8-420614974eae | public Solver() {} |
2fdff34f-ad69-4c21-b4c0-b0efd2f79a7d | public Solver(SudokuBoard board) {
solved = board.isSolved();
this.board = board;
} |
3be530ec-9782-48c6-85cc-61a80a56f76d | public void loadSudokuPuzzle(SudokuBoard board) {
solved = board.isSolved();
this.board = board;
} |
feb65256-7e0d-49f2-a9de-0ec4c374a925 | public void solve() {
if (solved) {
System.out.println("Sudoku Puzzle already Solved!");
return;
}
if (board == null) {
System.out.println("No Puzzle Loaded");
return;
}
extractCandidates();
solved = (solved) ? solved : nakedQuadSolver(new LinkedList<NakedCandidates>(), new LinkedList... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.