id
stringlengths
36
36
text
stringlengths
1
1.25M
73f97b5e-e571-452e-89cb-90bebf8a0e1c
public static void main (String[] args) throws IOException { long startTime = System.currentTimeMillis(); if(args.length == 2){ trainingDirectory = args[0]; testingDirectory = args[1]; } else if (args.length == 0){ //trainingDirectory = "D:/cs571data...
5a880465-c18c-4a58-b9fd-64d4e1d4e804
public SimpleLabelNERdata2TokenSequence () { super (null, new LabelAlphabet()); }
d346105f-baf2-4bf6-831d-61a8bac9fc32
public SimpleLabelNERdata2TokenSequence (boolean extraFeatures) { super (null, new LabelAlphabet()); if (!extraFeatures) { doDigitCollapses = doConjunctions = doSpelling = doPhrases = doTags = false; doDowncasing = true; } }
f60cfb6d-8bcb-4c0f-af1b-87a1625fcb3c
public Instance pipe (Instance carrier) { String sentenceLines = carrier.getData().toString(); String[] tokens = sentenceLines.split ("\n"); TokenSequence data = new TokenSequence (tokens.length); LabelSequence target = new LabelSequence ((LabelAlphabet)getTargetAlphabet(), tokens.length); boolean [][] en...
95043c1c-3a82-43f7-be57-dd8a4b7f32f0
public static String labelSimplifier(String label){ if(label.toLowerCase().contains("Peo".toLowerCase())) { return "PER"; } else if(label.toLowerCase().contains("Loc".toLowerCase())) { return "LOC"; } else if(label.toLowerCase().contains("Org".toLowerCase())) { return "ORG"; } else { return "O"; ...
885185d1-8524-4d05-beda-14ebc85759b9
public ImprovedSimpleLabelNERdata2TokenSequence () { super (null, new LabelAlphabet()); }
075f04d6-17bc-41db-b676-ee626b83a79e
public ImprovedSimpleLabelNERdata2TokenSequence (boolean extraFeatures) { super (null, new LabelAlphabet()); if (!extraFeatures) { doDigitCollapses = doConjunctions = doSpelling = doPhrases = doTags = false; doDowncasing = true; } }
0252dced-26d1-41c2-9743-e21584414bf5
public Instance pipe (Instance carrier) { String sentenceLines = carrier.getData().toString(); String[] tokens = sentenceLines.split ("\n"); TokenSequence data = new TokenSequence (tokens.length); LabelSequence target = new LabelSequence ((LabelAlphabet)getTargetAlphabet(), tokens.length); boolean [][] en...
b8441233-4d00-48db-ad6e-9646c17568f6
public static String labelSimplifier(String label){ if(label.toLowerCase().contains("Peo".toLowerCase())) { return "PER"; } else if(label.toLowerCase().contains("Loc".toLowerCase())) { return "LOC"; } else if(label.toLowerCase().contains("Org".toLowerCase())) { return "ORG"; } else { return "O"; ...
65c67975-cd96-4210-9174-1d818132e545
public static void main (String[] args) throws IOException { String address = "F:/cs571data/project2/data/train"; File[] files = new File(address).listFiles(); for (File file : files){ Scanner sc = new Scanner(file); //loop thru lines while (sc.hasNext()) { String line = sc.nextLine(); Str...
dc8b5000-5df6-453c-80b9-c38280901604
public TrainDetailedCRF(String trainingFileFolder, String testingFileFolder) throws IOException { ArrayList<Pipe> pipeList = new ArrayList<Pipe>(); // Construct pipes pipeList.add(new Input2CharSequence("UTF-8")); pipeList.add(new ImprovedDetailedLabelNERdata2TokenSequence(true)); // tr...
81c8ea8f-f172-43e4-b0ad-25256606bdc8
public ImprovedDetailedLabelNERdata2TokenSequence () { super (null, new LabelAlphabet()); }
d4866958-fc31-4ef2-81a5-253bfbfb8d57
public ImprovedDetailedLabelNERdata2TokenSequence (boolean extraFeatures) { super (null, new LabelAlphabet()); if (!extraFeatures) { doDigitCollapses = doConjunctions = doSpelling = doPhrases = doTags = false; doDowncasing = true; } }
4033195d-66b3-46c8-a7a3-ae90e49ecb6d
public Instance pipe (Instance carrier) { String sentenceLines = carrier.getData().toString(); String[] tokens = sentenceLines.split ("\n"); TokenSequence data = new TokenSequence (tokens.length); LabelSequence target = new LabelSequence ((LabelAlphabet)getTargetAlphabet(), tokens.length); boolean [][] en...
05a9ee38-8ace-48ab-a441-d2172b97d119
public static String labelPrefixRemover(String label){ String newLabel = "O"; if(label.contains("B-")) { newLabel = label.replace("B-", ""); } else if(label.contains("I-")) { newLabel = label.replace("I-", ""); } if(newLabel.contains("Peo")) { return "PER"; } else if(newLabel.contains("Loc...
e2156683-03c9-4b7d-98c6-38d38db0ed5a
public static void main (String[] args) throws IOException { long startTime = System.currentTimeMillis(); if(args.length == 2){ trainingDirectory = args[0]; testingDirectory = args[1]; } else if (args.length == 0){ //trainingDirectory = "D:...
3a2a30a6-275f-4a5b-9f5e-d1579f67a4b0
public String getMsg(){ return "chirag rrrr"; }
cfdebf68-0361-4014-8188-cb3d946fe6c0
public void test(){ }
5d0c5672-56fe-43c0-9691-2ef25ee150ea
public DecryptionCezar(String text, int k) { String input = text; StringBuilder dec = new StringBuilder(); for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); if (isEnglish(c)) { int x = (findInEnglish(c) - k + nEng) % nEng; if (Character.isUpperCase(c)) { dec.append(engsli...
ebc32396-2d66-4d7a-93ea-1bba2cdd6f15
public DecryptionCezar(EncryptCezar enc) { int k = enc.getK(); String input = enc.getEncText(); DecryptionCezar dec = new DecryptionCezar(input, k); output = dec.getDecText(); }
6e6c2774-8209-4c5b-85d0-6f864f631706
public String getDecText() { return output; }
c58ad490-a729-44e8-ac3f-596ad21d4fa4
public EncryptCezar(String text, int k) { this.k = k; String input = text; StringBuilder output = new StringBuilder(); for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); if (isEnglish(c)) { int y = (findInEnglish(c) + k) % nEng; if (Character.isUpperCase(c)) { output.appe...
6947aa3e-0cc4-4139-b434-b4dd2261c7cb
public String getEncText() { return this.output; }
95fdd06e-1456-4e72-98a1-e3282f304f51
public int getK() { return this.k; }
59b9a531-8656-4e2a-a0a8-b6a484490e84
public String getVersion() { return version; }
b7001a8e-ad10-46a5-bdc4-d6f83706afd7
public int getSize(){ return size; }
8241d7c2-5b12-4df9-b941-ad598a0b9523
CONST(String str){ version = str; }
209d6f7a-3e00-470f-8091-cb9f472c3b59
CONST(int i){ size = i; }
6ee577f8-ede2-43e7-a80b-9dd9d431558d
public static void main(String[] args){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while(true){ System.out.println("Please enter a command ('help' provides help):"); System.out.print(">> "); String cmd; try{ cmd = br.readLine(); switch(cmd.t...
cd6e20f1-bfd4-438c-9094-8fa8d1f1ec8c
private static void processCommandFurther(String cmd){ if(cmd.startsWith("mst -r")){ // random mode String[] params = cmd.split("\\s+"); if(params.length < 4){ System.out.println("ERROR: Not enough params given. Syntax is 'mst -r n d'. Please try again.\n"); } else{ int numVertices...
250c8812-544c-402d-97b8-82228648ae05
private static void processRandomMode(int numVertices, double density){ Graph graph = GraphGenerator.generateGraph(numVertices, density); System.out.println("Graph size = "+numVertices+", density = "+density); System.out.println(); System.out.println("Running simple scheme"); System.out.printl...
05fc5b8f-bfc5-4413-a9a8-1bfea4dda300
private static void printTimeAndCost(long runtime, List<Edge> generatedMST){ System.out.format("Time taken:\t\t%d min, %d sec (%d millisec)\n", TimeUnit.MILLISECONDS.toMinutes(runtime), TimeUnit.MILLISECONDS.toSeconds(runtime) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(ru...
db27ee7d-83d3-4567-ad22-b4c73867889d
private static void printTotalCostOfMST(List<Edge> generatedMST){ int totalCost = 0; for(Edge MSTEdge: generatedMST){ totalCost += MSTEdge.getCost(); } System.out.println("Total cost of MST:\t"+totalCost); }
39583852-352b-44ef-a56e-a956bcaefceb
private static void printEdges(List<Edge> generatedMST){ System.out.println("Edges in MST:"); for(Edge MSTEdge: generatedMST){ System.out.println(MSTEdge.getStart()+"\t"+MSTEdge.getFinish()+"\t"+MSTEdge.getCost()); } System.out.println(); }
cd2507a5-d339-4d32-b973-b6b166849a55
private static Graph createGraphFromFile(String cmd){ String[] params = cmd.split("\\s+"); String fileName = params[2]; BufferedReader br; Graph graph = null; try{ br = new BufferedReader(new FileReader(fileName)); String line = br.readLine(); String[] values = line.split("\\s...
ad024736-4ebd-4bd9-9c04-e1b632b348a2
public static void runRandomizedExperiment(){ final int NUMRUNS = 5; final int[] numVerticesArray = {1000, 3000, 5000}; final int[] densityArray = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; for(int numVertices: numVerticesArray){ for(int density: densityArray){ long simpleSchemeRuntime = ...
7ed4eb72-133f-44e3-bf1f-78576d194b07
private static void exit(){ System.exit(0); }
7952ea6a-84e3-4a52-9d39-4de9a0e78f50
private static void printHelp(){ System.out.println("Available commands:"); System.out.println("'help' \t: Prints this message"); System.out.println("'mst -r n d' \t: Runs Prim's algorithm using both simple and f-heap schemes on a graph of size n and density d specified in %"); System.out....
0529ae69-804b-48a8-b697-172a5a373436
public List<Edge> generateMST(Graph graph);
e61222a8-2f08-4e73-b6a1-0922200fe7b9
public static Graph generateGraph(int numVertices, double density){ Graph graph = null; while(notConnected(graph = createAndPopulateGraph(numVertices, density))); return graph; }
7383002d-9949-456a-8cdf-6dc0e8ded007
private static Graph createAndPopulateGraph(int numVertices, double density){ if(DEBUG) return createTestGraph(numVertices); return uniformSpanningTreeApproach(numVertices, density); }
eaeda0aa-85b2-4d8e-ad3a-206a111c6cc0
private static boolean notConnected(Graph graph){ int startDFSAt = graph.selectARandomNode(); HashSet<Integer> visitedNodes = new HashSet<Integer>(); visitedNodes.add(startDFSAt); runDFSFromNode(startDFSAt, visitedNodes, graph); if(visitedNodes.size() == graph.getNumVertices()) ...
70a9665e-60aa-4527-bdad-5f64f41f11c7
private static void runDFSFromNode(Integer startNode, HashSet<Integer> visitedNodes, Graph graph){ for(AdjListNode node: graph.getAdjList().get(startNode)){ if(!visitedNodes.contains(node.getTargetNode())){ visitedNodes.add(node.getTargetNode()); runDFSFromNode(node.getTargetNode(), visitedNod...
c70c924c-282d-46e5-b118-7900e733a45a
private static Graph uniformSpanningTreeApproach(int numVertices, double density){ Graph graph = new Graph(numVertices, density); HashSet<Integer> visitedNodes = new HashSet<Integer>(); int[] firstIncidentEdges = createIncidentEdgeArray(numVertices); int startNode = (int) (Math.random() * numVertic...
22bb524a-0249-47c2-90d0-794022d5f942
private static int[] createIncidentEdgeArray(int numVertices){ int[] firstIncidentEdges = new int[numVertices]; // record the first incident edge on a newly discovered vertex. comes in handy if we need to prune edges // because it helps us avoid marooning vertice...
37c8ea01-0b5a-44ac-8343-7ead3f020720
private static Graph createTestGraph(int numVertices){ Graph graph = new Graph(numVertices, 0); //density is ignored since we're going to manually add test data /*graph.getAdjList().get(2).put(5, new Edge(2, 5, 36, false)); graph.getAdjList().get(5).put(2, new Edge(5, 2, 36, false)); graph.getAdjLi...
0a67577d-e008-4120-b382-f825dc3d51dd
public static List<Edge> generateMST(MSTGeneratorInterface mstGenerator, Graph graph){ long start = System.currentTimeMillis(); List<Edge> generatedMST = mstGenerator.generateMST(graph); long end = System.currentTimeMillis(); runtime = end - start; return generatedMST; }
e284d45e-82c8-44b1-b3a6-df1603de56ec
public static long getRuntime(){ return runtime; }
5269c7be-285e-4e1b-964e-74f4ea029d54
public static void main(String[] args){ int numVertices = 1000; double density = 0.5; //uncomment the while to check if the f-heap, simple scheme equality breaks down at any time /*while(true){*/ Graph graph = GraphGenerator.generateGraph(numVertices, density); printGraphMetrics(g...
31ca66d1-7045-4a94-ac75-54e0c4dd3879
private static void printGraphMetrics(Graph graph, double density){ System.out.println("Number of vertices = "+graph.getNumVertices()); System.out.println("Edge density = "+density); System.out.println("-----------------------------"); }
b5780c1f-fa23-457e-99ff-f632590b9ff2
private static int printResults(List<Edge> finalMST){ int totalCost = 0; for(Edge MSTEdge: finalMST){ totalCost += MSTEdge.getCost(); } System.out.println(totalCost); System.out.println("-----"); for(Edge MSTEdge: finalMST){ System.out.println(MSTEdge.getStart()+"\t"+MSTEdg...
9bf633dc-04d0-488a-b3fb-0a93d3dd6f56
@Override public List<Edge> generateMST(Graph graph){ fHeap = new FHeap(); List<Edge> generatedMST = new ArrayList<Edge>(); int startNodeIndex = graph.selectARandomNode(); for(int i = 0; i < graph.getNumVertices(); i++){ fHeap.insert(Integer.MAX_VALUE); } fHeap.decreaseKey(fHeap.getNo...
bd9b2a4a-f64b-478f-b82a-655c7ab722cc
@Override public List<Edge> generateMST(Graph graph){ List<Integer> nodesInMST = new ArrayList<Integer>(); int startMSTAt = graph.selectARandomNode(); nodesInMST.add(startMSTAt); Edge[] feelerEdges = new Edge[graph.getNumVertices()]; for(int i = 0; i < feelerEdges.length; i++){ feelerEdges[...
ca2d9715-afa8-4bc3-ac0b-30a6f772f28c
private void buildMSTNodeByNode(Graph graph, int startMSTAt, List<Integer> nodesInMST, List<Edge> finalMSTEdges, Edge[] feelerEdges){ //add the outgoing edges from this node to all the outgoing edges we already have for(AdjListNode node: graph.getAdjList().get(startMSTAt)){ Edge fe...
9068b204-baab-49e9-a511-12f75f32ee6a
public AdjListNode(int targetNode, Edge edge){ super(); this.targetNode = targetNode; this.edge = edge; }
06fa09dd-5d12-4bc9-b04c-2c95bc046f34
@Override public int hashCode(){ final int prime = 31; int result = 1; result = prime * result + targetNode; return result; }
4102a150-9698-4b48-9fe0-b0a23253a17a
@Override public boolean equals(Object obj){ if(this == obj) return true; if(obj == null) return false; if(!(obj instanceof AdjListNode)) return false; AdjListNode other = (AdjListNode)obj; if(targetNode != other.targetNode) return false; return true; }
53c3e243-7245-4eaf-b3b4-57174afaaa18
public int getTargetNode(){ return targetNode; }
3bf8c1ba-2683-4f4a-a9f1-e2ea3f7212f1
public void setTargetNode(int targetNode){ this.targetNode = targetNode; }
8a73b514-bb4a-4075-aeea-7710e9e41db9
public Edge getEdge(){ return edge; }
59d03317-5500-44e7-86ba-87d761ab6ff2
public void setEdge(Edge edge){ this.edge = edge; }
43031dc4-8acc-468b-b70d-a51495f64f38
public Edge(int start, int finish, int cost, boolean eligible){ super(); this.start = start; this.finish = finish; this.cost = cost; this.alreadyInMST = eligible; }
97c62cc0-8c91-4703-84f9-7a2404821604
public int getStart(){ return start; }
fae403ee-8dfd-4bd0-aedf-b5bca15226ce
public void setStart(int start){ this.start = start; }
1a19b8b2-4a6d-42ca-a94a-a29c29507cf9
public int getFinish(){ return finish; }
1b1399f8-cb81-4bad-9334-7fc518c0dd60
public void setFinish(int finish){ this.finish = finish; }
0209fe60-8b74-40a9-a5e9-aa5de8e97f14
public int getCost(){ return cost; }
cf923402-ec53-4c19-9f14-e02f9312ce2c
public void setCost(int cost){ this.cost = cost; }
f4161c83-ce90-4f1a-973c-a9eac760dffa
public boolean isAlreadyInMST(){ return alreadyInMST; }
56219136-3b8d-4e5c-974a-1f42c266a5e0
public void setAlreadyInMST(boolean alreadyInMST){ this.alreadyInMST = alreadyInMST; }
f7317649-9ad6-47ca-a653-ff9465f55180
public Graph(int numVertices, double density){ this.numVertices = numVertices; this.numEdges = (int) (density * numVertices * (numVertices - 1) / 2); adjList = new LinkedList<List<AdjListNode>>(); for(int i=0;i<numVertices;i++){ adjList.add(i, new LinkedList<AdjListNode>()); } }
e870d67a-c891-4575-a8b6-f9b213218825
public int selectARandomNode(){ return (int) (Math.random() * numVertices); }
519e060c-85f6-493a-853c-e9ab28d48330
public int getNumVertices(){ return numVertices; }
7a21116a-31fc-4602-8c62-946b0893b50e
public List<List<AdjListNode>> getAdjList(){ return adjList; }
f3f606a4-b061-4f98-bf27-e13de1e6c551
public int getNumEdges(){ return numEdges; }
fa083ea1-8fff-4297-b584-24a8dadafb72
public void setAdjList(List<List<AdjListNode>> adjList){ this.adjList = adjList; }
a2730c23-662a-41fc-ba5c-940133167358
public FHeap(){ size = 0; nodeList = new ArrayList<FHeapNode>(); nodeDegrees = new HashMap<Integer, FHeapNode>(); }
e1492b64-0ec7-40ca-b997-03f953db438e
public void insert(int key){ FHeapNode newNode = new FHeapNode(size, key, 0, 0, null, null, null, null, false); nodeList.add(newNode); size++; if(min == null){ newNode.setLeftSibling(newNode); newNode.setRightSibling(newNode); min = newNode; } else{ insertIntoRootList(nod...
7e342881-89d1-447c-ba51-0f551952db58
private void insertIntoRootList(FHeapNode nodeToInsert){ spliceNodeToRight(min, nodeToInsert); nodeToInsert.setParent(null); nodeToInsert.setMarked(false); if(nodeToInsert.getCost() < min.getCost()) min = nodeToInsert; }
cfd8e22a-bda8-4e80-8932-cb19baee4721
private void spliceNodeToRight(FHeapNode existingNode, FHeapNode newNode){ newNode.setRightSibling(existingNode.getRightSibling()); newNode.setLeftSibling(existingNode); existingNode.getRightSibling().setLeftSibling(newNode); existingNode.setRightSibling(newNode); }
f12db506-060a-4721-b9ab-5cd4b773e454
public FHeapNode deleteMin(){ if(size == 0) throw new RuntimeException("Error: No elements in heap"); FHeapNode nodeToDelete = nodeList.get(min.getIndex()); // insert the children of the node we're about to delete into the root chain insertChildrenOfNodeIntoRootList(nodeToDelete); // connec...
dd873633-49ce-4bb6-8001-029f3c5fb87d
private void insertChildrenOfNodeIntoRootList(FHeapNode node){ if(node.getChild() != null){ FHeapNode startNode = node.getChild(); FHeapNode currentNode = startNode.getRightSibling(); insertIntoRootList(startNode); while(currentNode != startNode){ FHeapNode tempNode = currentNode.ge...
a393a2ce-e03d-4d3b-95e3-e92e7316bca9
private void updateMin(FHeapNode startNode){ min = startNode; FHeapNode currentNode = startNode.getRightSibling(); while(currentNode != startNode){ if(!currentNode.isAlreadyInMST() && currentNode.getCost() < min.getCost()){ min = currentNode; } currentNode = currentNode.getRightSib...
b173037c-9caa-45a9-be78-ed075a96f20c
private void nonRecursiveBinomialize(FHeapNode startNode){ boolean DONE = false; FHeapNode currentNode = startNode; nodeDegrees.clear(); while(!DONE){ while(true){ int degree = currentNode.getDegree(); if(nodeDegrees.containsKey(degree)){ FHeapNode existingNodeOfSameDegr...
f363ea90-9ca2-4c01-b60e-4f53ddf6f5a2
private void binomialize(FHeapNode startNode){ nodeDegrees.clear(); binomialize(startNode, startNode); }
49abb080-8ca8-4940-a619-3af694439db1
private void binomialize(FHeapNode startNode, FHeapNode currentNode){ nodeDegrees.put(currentNode.getDegree(), currentNode); while(currentNode.getRightSibling() != startNode){ FHeapNode node = currentNode.getRightSibling(); int degree = node.getDegree(); if(nodeDegrees.containsKey(degree)){ ...
d973746c-3124-4488-80d2-abb0c0675f5d
private FHeapNode union(FHeapNode node1, FHeapNode node2){ if(node1.getCost() <= node2.getCost()){ node2.setParent(node1); // connect up the neighbors of the node that we're about to make a child. this way the root chain stays connected // without passing through the node that we just demoted ...
ef4e14f6-1158-4f9a-b566-5eb457d4e444
private void joinNeighbors(FHeapNode node){ node.getLeftSibling().setRightSibling(node.getRightSibling()); node.getRightSibling().setLeftSibling(node.getLeftSibling()); }
2fb09aa9-576b-4008-b796-60c222c2ca81
public void decreaseKey(FHeapNode node, int newKey, int predecessor){ if(node.isAlreadyInMST()) return; if(newKey >= node.getCost()) return; node.setCost(newKey); node.setPredecessor(predecessor); cut(node); }
d6876c25-a4c8-4b99-a528-0c2cd0e1900b
private void cut(FHeapNode node){ FHeapNode parent = node.getParent(); // save this beforehand because the reference to the parent will be nulled out in the insertIntoRootList method if(null == parent){ // stop if we're at the root chain or if we ascended to it if(node.getCost() < min.getCost()) m...
6e7c4552-6bc1-4761-87b2-e7d43315f078
public FHeapNode getMin(){ return min; }
829008db-b645-41ff-89f4-5b04e1f810b5
public int getSize(){ return size; }
9e17a92d-e6cc-4b3f-b36e-11150c1619a1
public List<FHeapNode> getNodeList(){ return nodeList; }
8541a900-c2cc-4aff-82eb-a4507ada92e1
public FHeapNode(int index, int cost, int degree, int predecessor, FHeapNode leftSibling, FHeapNode rightSibling, FHeapNode parent, FHeapNode child, boolean alreadyInMST){ super(); this.index = index; this.cost = cost; this.degree = degree; this.predecessor = predecessor; this.leftSibling ...
60024793-155d-4beb-9efe-b97ed8cdfb4f
public int getCost(){ return cost; }
f989796d-c08f-4e86-a3bf-2942f71f7dc9
public void setCost(int cost){ this.cost = cost; }
d198b9e9-296e-462f-ba7d-167564fd9c65
public FHeapNode getLeftSibling(){ return leftSibling; }
8d363503-4dad-4e8c-ac4c-2ed6f555a9a2
public void setLeftSibling(FHeapNode leftSibling){ this.leftSibling = leftSibling; }
760c19d8-ae8b-47b7-a296-c74778c6e2aa
public FHeapNode getRightSibling(){ return rightSibling; }
e61ad9fa-b6f7-459d-b2f4-e1299cb51eb9
public void setRightSibling(FHeapNode rightSibling){ this.rightSibling = rightSibling; }