GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add docs and remove console logs · RepGraph/RepGraph@0222180

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/main
    • javascript/repgraphfrontend/src
      • Components
        • AnalysisComponents
          • DisplaySubsetTool.js
        • Graph
          • Node.js
      • HomePage.js
      • LayoutAlgorithms
        • layoutFlat.js
        • layoutHierarchy.js
        • layoutTree.js
    • java/com/RepGraph
      • AMRGraph.java
      • AMRModel.java
      • AbstractModel.java
      • EDSGraph.java
      • EDSModel.java
      • Node.java
      • PTGGraph.java
      • PTGModel.java
      • RequestHandler.java
      • UCCAGraph.java
      • UCCAModel.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/main/java/com/RepGraph/AMRGraph.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/AMRGraph.java
+15-73Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.Stack;
1616

1717
/**
18-
* The Graph class represents a single sentence which comprises of nodes, edges and tokens.
18+
* The AMR Graph class represents a graph following the AMR Framework
1919
*/
2020
public class AMRGraph extends AbstractGraph {
2121

@@ -47,6 +47,9 @@ public AMRGraph(@JsonProperty("id") String id, @JsonProperty("source") String so
4747
}
4848

4949

50+
/**
51+
* Utility function used in the process of aligning nodes to tokens using the JAMR aligner
52+
*/
5053
public void alignUtil(String NodeID, HashMap<String, Node> nodes, HashMap<String, Boolean> visited, int layer, StringWriter writer) throws IOException {
5154
// Mark the current node as visited and print it
5255
visited.put(NodeID, true);
@@ -71,6 +74,11 @@ public void alignUtil(String NodeID, HashMap<String, Node> nodes, HashMap<String
7174

7275
}
7376

77+
/**
78+
* Aligns nodes to tokens
79+
* @throws IOException
80+
* @throws InterruptedException
81+
*/
7482
public void alignNodes() throws IOException, InterruptedException {
7583
setNodeNeighbours();
7684

@@ -158,78 +166,12 @@ public void alignNodes() throws IOException, InterruptedException {
158166

159167
}
160168

161-
public void fillInSpans(HashMap<String, Node> nodes) {
162-
ArrayList<ArrayList<String>> order = getPaths(nodes);
163-
164-
for (ArrayList<String> path : order) {
165-
if (nodes.get(path.get(0)).getAnchors() != null) {
166-
continue;
167-
}
168-
int min = Integer.MAX_VALUE;
169-
for (int i = 1; i < path.size(); i++) {
170-
if (nodes.get(path.get(i)).getAnchors() != null) {
171-
min = Math.min(min, nodes.get(path.get(i)).getAnchors().get(0).getFrom());
172-
}
173-
}
174-
if (min == Integer.MAX_VALUE) {
175-
for (Node n : nodes.get(path.get(0)).getUndirectedNeighbours()) {
176-
if (n.getAnchors() != null) {
177-
min = Math.min(min, n.getAnchors().get(0).getFrom());
178-
}
179-
}
180-
}
181-
if (min != Integer.MAX_VALUE) {
182-
ArrayList<Anchors> arr = new ArrayList<>();
183-
Anchors a = new Anchors(min, min);
184-
arr.add(a);
185-
nodes.get(path.get(0)).setAnchors(arr);
186-
}
187-
}
188-
189-
}
190-
191-
private void topologicalSort(String nodeID, HashMap<String, Node> nodes, HashMap<String, Boolean> visited,
192-
Stack<String> stack) {
193-
194-
visited.put(nodeID, true);
195-
Iterator<Node> it = nodes.get(nodeID).getDirectedNeighbours().iterator();
196-
197-
String i;
198-
while (it.hasNext()) {
199-
i = it.next().getId();
200-
if (!visited.get(i))
201-
topologicalSort(i, nodes, visited, stack);
202-
}
203-
204-
stack.push((nodeID));
205-
}
206-
207-
private ArrayList<ArrayList<String>> getPaths(HashMap<String, Node> nodes) {
208-
209-
Stack<String> stack = new Stack<String>();
210-
211-
HashMap<String, Boolean> visited = new HashMap<>();
212-
213-
ArrayList<ArrayList<String>> searches = new ArrayList<>();
214-
for (Node n : nodes.values()) {
215-
for (String i : nodes.keySet()) {
216-
visited.put(i, false);
217-
}
218-
if (!visited.get(n.getId())) {
219-
topologicalSort(n.getId(), nodes, visited, stack);
220-
}
221-
222-
ArrayList<String> order = new ArrayList<>();
223-
while (!stack.empty()) {
224-
order.add(stack.pop());
225-
}
226-
searches.add(order);
227-
228-
}
229-
230-
return searches;
231-
}
232-
169+
/**
170+
* Overrided method to align nodes before calling planar method
171+
* @return planar data
172+
* @throws IOException
173+
* @throws InterruptedException
174+
*/
233175
@JsonIgnore
234176
public HashMap<String,Object> isPlanar() throws IOException, InterruptedException {
235177
this.alignNodes();
Collapse file

‎src/main/java/com/RepGraph/AMRModel.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/AMRModel.java
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,38 @@
55
import java.io.IOException;
66
import java.util.*;
77

8+
89
/**
9-
* The RepGraphModel class is used to store all the system's graphs and run analysis functions on graphs.
10+
* Model class for AMR graphs - contains AMR specific functions
1011
*/
1112
public class AMRModel extends AbstractModel {
1213

1314

15+
/**
16+
* AMR model constructor - simply calls super
17+
*/
1418
public AMRModel() {
1519
super();
1620
}
1721

22+
/**
23+
* @param graphID A Graph's ID.
24+
* @return the graph requested.
25+
* @throws IOException
26+
* @throws InterruptedException
27+
*/
28+
@Override
1829
public AMRGraph getGraph(String graphID) throws IOException, InterruptedException {
1930
AMRGraph g = (AMRGraph)graphs.get(graphID);
2031
g.alignNodes();
2132
return g;
2233
}
2334

35+
/**
36+
* Runs all graphs in the model through the aligner
37+
* @throws IOException
38+
* @throws InterruptedException
39+
*/
2440
public void alignAllGraphs() throws IOException, InterruptedException {
2541
for (AbstractGraph t:graphs.values()) {
2642
AMRGraph g = (AMRGraph)t;
@@ -29,6 +45,11 @@ public void alignAllGraphs() throws IOException, InterruptedException {
2945
}
3046
}
3147

48+
/**
49+
* @return statistics about the graphs in the dataset - AMR model analysis does not include planarity or edge length
50+
* @throws IOException
51+
* @throws InterruptedException
52+
*/
3253
@Override
3354
public HashMap<String, String> modelAnalysis() throws IOException, InterruptedException {
3455
HashMap<String, String> AnalysisInfo = new HashMap<>();
Collapse file

‎src/main/java/com/RepGraph/AbstractModel.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/AbstractModel.java
+35-2Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public AbstractGraph getGraph(String graphID) throws IOException, InterruptedExc
3737
return graphs.get(graphID);
3838
}
3939

40+
41+
/**
42+
* get hashmap of all graphs in model
43+
* @return all graphs in model
44+
*/
4045
public HashMap<String, AbstractGraph> getAllGraphs() {
4146
return graphs;
4247
}
@@ -67,6 +72,12 @@ public void clearGraphs() {
6772
graphs.clear();
6873
}
6974

75+
/**
76+
* Collects statistics about the dataset the model represents
77+
* @return model statistics
78+
* @throws IOException
79+
* @throws InterruptedException
80+
*/
7081
public HashMap<String, String> modelAnalysis() throws IOException, InterruptedException {
7182
HashMap<String, String> AnalysisInfo = new HashMap<>();
7283

@@ -119,6 +130,9 @@ public HashMap<String, String> modelAnalysis() throws IOException, InterruptedEx
119130
return AnalysisInfo;
120131
}
121132

133+
/**
134+
* Runs graphs through Core NLP NER model and assigns NER to tokens
135+
*/
122136
public void parseAlltokens() {
123137
Properties props = new Properties();
124138
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner");
@@ -157,6 +171,12 @@ public void parseAlltokens() {
157171

158172
}
159173

174+
/**
175+
* Creates a subgraph from adjacent nodes
176+
* @param parent Graph that the subgraph is created from
177+
* @param headNodeID Node ID that the subgraph is created from
178+
* @return Subgraph
179+
*/
160180
public AbstractGraph CreateSubsetAdjacent(AbstractGraph parent, String headNodeID) {
161181

162182

@@ -229,6 +249,12 @@ public AbstractGraph CreateSubsetAdjacent(AbstractGraph parent, String headNodeI
229249
return subset;
230250
}
231251

252+
/**
253+
* Creates a subgraph from descendent nodes
254+
* @param parent Graph that the subgraph is created from
255+
* @param headNodeID Node ID that the subgraph is created from
256+
* @return Subgraph
257+
*/
232258
public AbstractGraph CreateSubsetDescendent(AbstractGraph parent, String headNodeID) {
233259

234260
AbstractGraph subset = new AbstractGraph();
@@ -348,6 +374,11 @@ public HashMap<String, Object> searchSubgraphPattern(String graphID, String[] No
348374

349375
}
350376

377+
/**
378+
* Search through model to find graphs containing the subgraph pattern given
379+
* @param Asubgraph subgraph pattern
380+
* @return hashmap of inputs and ids as well as a response - keys : "data" and "response"
381+
*/
351382
public HashMap<String, Object> searchSubgraphPattern(AbstractGraph Asubgraph) {
352383

353384
AbstractGraph subgraph = (AbstractGraph) Asubgraph;
@@ -505,6 +536,9 @@ public HashMap<String, Object> searchSubgraphNodeSet(ArrayList<String> labels) {
505536
*
506537
* @param graphID1 AbstractGraph ID of the first AbstractGraph.
507538
* @param graphID2 AbstractGraph ID of the second AbstractGraph.
539+
* @param strict Boolean for strict comparison
540+
* @param noSurface Boolean to not check surface nodes
541+
* @param noAbstract Boolean to not check abstract nodes
508542
* @return HashMap<String, Object> The differences and similarities of the two graphs i.e
509543
* the "SimilarNodes1" key gives the Node ids of the similar nodes in graph1.
510544
* the "SimilarNodes2" key gives the Node ids of the similar nodes in graph2.
@@ -657,8 +691,7 @@ public HashMap<String, Object> compareTwoGraphs(String graphID1, String graphID2
657691
* @param longestPathUndirected Boolean to decide if to find the longest undirected path.
658692
* @param connected Boolean to decide if to test for if the AbstractGraph is connected.
659693
* @return HashMap<String, Object> Results of the tests i.e
660-
* the "Planar" key returns a boolean of whether or not the AbstractGraph is planar
661-
* the "PlanarVis" key returns the visualisation data
694+
* the "Planar" key returns a HashMap of Planar data - the result and the graph construction
662695
* the "LongestPathDirected" key returns an ArrayList of an Arraylist of integers defining the multiple longest directed paths in the graphs
663696
* the "LongestPathUndirected" key returns an ArrayList of an Arraylist of integers defining the multiple longest undirected paths in the graphs
664697
* the "Connected" returns a boolean of whether or not the AbstractGraph is connected.
Collapse file

‎src/main/java/com/RepGraph/EDSGraph.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/EDSGraph.java
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
import java.util.*;
1212

1313
/**
14-
* The Graph class represents a single sentence which comprises of nodes, edges and tokens.
14+
* The EDS Graph class represents a graph following the EDS Framework
1515
*/
1616
public class EDSGraph extends AbstractGraph {
1717

1818

1919
/**
20-
* Default constructor for the Graph class.
20+
* Default constructor for the EDS Graph class.
2121
*/
2222
public EDSGraph() {
2323
super();
@@ -28,6 +28,10 @@ public EDSGraph(String id, String source, String input, HashMap<String, Node> no
2828

2929
}
3030

31+
/**
32+
* Set the hashmap of nodes from an array of nodes - uses EDS specific rules
33+
* @param nodelist Array of Node objects
34+
*/
3135
@JsonSetter("nodes")
3236
public void setNodes(ArrayList<Node> nodelist) {
3337

Collapse file

‎src/main/java/com/RepGraph/EDSModel.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/EDSModel.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.*;
44

55
/**
6-
* The RepGraphModel class is used to store all the system's graphs and run analysis functions on graphs.
6+
* Model class for EDS graphs - contains EDS specific functions
77
*/
88
public class EDSModel extends AbstractModel {
99

Collapse file

‎src/main/java/com/RepGraph/Node.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/Node.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import java.util.LinkedHashMap;
1818
import java.util.Map;
1919

20+
/**
21+
* Node object - contains node information
22+
*/
2023
@JsonIgnoreProperties(ignoreUnknown = true)
2124
public class Node {
2225

Collapse file

‎src/main/java/com/RepGraph/PTGGraph.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/PTGGraph.java
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
import java.util.HashMap;
77

88
/**
9-
* The Graph class represents a single sentence which comprises of nodes, edges and tokens.
9+
* The PTG Graph class represents a graph following the PTG Framework
1010
*/
1111
public class PTGGraph extends AbstractGraph {
1212

1313

14-
/**
15-
* Default constructor for the Graph class.
16-
*/
14+
1715
public PTGGraph() {
1816
super();
1917
}
@@ -23,6 +21,10 @@ public PTGGraph(String id, String source, String input, HashMap<String, Node> no
2321

2422
}
2523

24+
/**
25+
* Sets the nodes hashmap from an array of node objects - uses PTG specific rules
26+
* @param nodelist Array of Node objects
27+
*/
2628
@JsonSetter("nodes")
2729
public void setNodes(ArrayList<Node> nodelist) {
2830

Collapse file

‎src/main/java/com/RepGraph/PTGModel.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/PTGModel.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.util.*;
44

55
/**
6-
* The RepGraphModel class is used to store all the system's graphs and run analysis functions on graphs.
6+
* Model class for PTG graphs - contains PTG specific functions
77
*/
88
public class PTGModel extends AbstractModel {
99

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.