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 token extractor from nodes refering to char anchors. · RepGraph/RepGraph@dc67933

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/main/java/com/RepGraph
    • AbstractGraph.java
    • AbstractModel.java
    • Anchors.java
    • DMRSGraph.java
    • DMRSModel.java
    • Edge.java
    • Node.java
    • RequestHandler.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/AbstractGraph.java
+12-18Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/**
88
* The Graph class represents a single sentence which comprises of nodes, edges and tokens.
99
*/
10+
1011
abstract class AbstractGraph {
1112

1213

@@ -37,14 +38,11 @@ abstract class AbstractGraph {
3738
@JsonAlias({"links","edges"})
3839
protected ArrayList<Edge> edges;
3940

40-
/**
41-
* An array list of the Graph's tokens.
42-
*/
43-
protected ArrayList<Token> tokens;
4441

4542
/**
4643
* ID of the Top node
4744
*/
45+
@JsonAlias({"top","tops"})
4846
protected String top;
4947

5048
/**
@@ -148,7 +146,7 @@ public void setEdges(ArrayList<Edge> edges) {
148146
this.edges = edges;
149147
}
150148

151-
@JsonGetter("tops")
149+
152150
/**
153151
* Getter method for a graphs top Node array
154152
*
@@ -158,20 +156,21 @@ public String getTop() {
158156
return top;
159157
}
160158

159+
161160
@JsonSetter("tops")
162-
/**
163-
* Setter method for a graphs top Node array
164-
*
165-
* @param top This is an ArrayList of the ids of the top nodes in a Graph
166-
*/
167-
public void setTop(ArrayList<String> top) {
168-
this.top = top.get(0);
161+
public void setTopArray(ArrayList<Integer> top) {
162+
this.top = top.get(0)+"";
169163
}
170164

171-
public void setTop(String top) {
165+
public void setTopString(String top) {
172166
this.top = top;
173167
}
174168

169+
@JsonSetter("top")
170+
public void setTopInt(int top) {
171+
this.top = top+"";
172+
}
173+
175174
@JsonGetter("nodes")
176175
public ArrayList<Node> returnNodeInArrayList() {
177176
ArrayList<Node> returnNodes = new ArrayList<Node>();
@@ -192,11 +191,6 @@ public HashMap<String, Node> getNodes() {
192191
}
193192

194193
@JsonSetter("nodes")
195-
/**
196-
* Setter method for the Graph's nodes HashMap. This setter also resets and populates the linear list of nodes "nodeslist"
197-
*
198-
* @param nodes The Graph's nodes HashMap.
199-
*/
200194
public void setNodes(ArrayList<Node> nodelist) {
201195

202196
for (Node n : nodelist) {
Collapse file

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

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/AbstractModel.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void clearGraphs() {
6666
public abstract AbstractGraph CreateSubsetAdjacent(String graphID, String headNodeID);
6767

6868

69-
public abstract AbstractGraph CreateSubsetDescendent(String graphID, String headNodeID);
69+
public abstract AbstractGraph CreateSubsetDescendent(String graphID, String headNodeID) ;
7070

7171

7272
public abstract HashMap<String, Object> searchSubgraphPattern(String graphID, String[] NodeId, int[] EdgeIndices);
Collapse file

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

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/Anchors.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
package com.RepGraph;
33

44
import com.fasterxml.jackson.annotation.JsonAlias;
5+
import com.fasterxml.jackson.annotation.JsonGetter;
56

67
/**
78
* This class stores the Token span information of a Node
89
*/
910
public class Anchors {
1011

1112
private int from;
13+
1214
@JsonAlias({"end","to"})
1315
private int end;
1416

@@ -44,6 +46,7 @@ public int getFrom() {
4446
*
4547
* @return int This is the value of "end"
4648
*/
49+
4750
public int getEnd() {
4851
return end;
4952
}
Collapse file

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

Copy file name to clipboardExpand all lines: src/main/java/com/RepGraph/DMRSGraph.java
+59-10Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
*/
1313
public class DMRSGraph extends AbstractGraph {
1414

15+
@JsonProperty("index")
16+
protected String index;
17+
18+
19+
protected ArrayList<Token> tokens;
20+
21+
22+
public String getIndex() {
23+
return index;
24+
}
25+
26+
public void setIndex(int index) {
27+
this.index = index + "";
28+
}
29+
30+
public void setIndex(String index) {
31+
this.index = index;
32+
}
1533

1634
/**
1735
* Default constructor for the Graph class.
@@ -27,6 +45,43 @@ public DMRSGraph(String id, String source, String input, HashMap<String, Node> n
2745
this.tokens = tokens;
2846
}
2947

48+
public ArrayList<Token> extractTokensFromNodes() {
49+
50+
51+
ArrayList<Token> tokenlist = new ArrayList<>();
52+
String[] list = this.input.split(" ");
53+
54+
for (int i =0;i<list.length;i++) {
55+
list[i]+=" ";
56+
tokenlist.add(new Token(i,list[i],list[i],list[i]));
57+
58+
}
59+
60+
int lengthBoundary[] = new int[list.length];
61+
62+
lengthBoundary[0] = list[0].length();
63+
64+
65+
for (int i = 1; i < lengthBoundary.length; ++i) {
66+
lengthBoundary[i] = lengthBoundary[i - 1] + list[i].length();
67+
System.out.println(lengthBoundary[i]);
68+
}
69+
70+
for (Node n:this.nodes.values()) {
71+
for (int i = 0; i <lengthBoundary.length ; i++) {
72+
if (n.getAnchors().getFrom()<lengthBoundary[i] && i<=n.getAnchors().getFrom()){
73+
n.getAnchors().setFrom(i);
74+
}
75+
if (n.getAnchors().getEnd()<=lengthBoundary[i] && i<=n.getAnchors().getEnd()){
76+
n.getAnchors().setEnd(i);
77+
}
78+
79+
}
80+
}
81+
82+
return tokenlist;
83+
}
84+
3085
@JsonGetter("nodes")
3186
public ArrayList<Node> returnNodeInArrayList() {
3287
ArrayList<Node> returnNodes = new ArrayList<Node>();
@@ -65,24 +120,17 @@ public void setNodes(HashMap<String, Node> nodes) {
65120
this.nodes = nodes;
66121
}
67122

68-
/**
69-
* Getter method for the Graph's tokens.
70-
*
71-
* @return ArrayList The Graph's tokens.
72-
*/
123+
73124
public ArrayList<Token> getTokens() {
74125
return tokens;
75126
}
76127

77-
/**
78-
* Setter method for the Graph's tokens.
79-
*
80-
* @param tokens The Graph's tokens.
81-
*/
128+
82129
public void setTokens(ArrayList<Token> tokens) {
83130
this.tokens = tokens;
84131
}
85132

133+
86134
/**
87135
* Analysis Tool for finding the longest paths in the Graph.
88136
*
@@ -399,6 +447,7 @@ public ArrayList<ArrayList<String>> traverseLongestPath(HashMap<String, Integer>
399447
return paths;
400448
}
401449

450+
@JsonIgnore
402451
/**
403452
* Method to check if a Graph is planar
404453
*

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.