Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 55a9aab

Browse files
committed
Added the AI generated (mixtral-8x7b-32768) docstrings without commenting methods with @OverRide and @depricated modifiers
1 parent 04a64b1 commit 55a9aab

File tree

11 files changed

+8082
-21
lines changed

11 files changed

+8082
-21
lines changed

corese-core/src/main/java/fr/inria/corese/core/Graph.java

+4,005-20
Large diffs are not rendered by default.

corese-core/src/main/java/fr/inria/corese/core/GraphDistance.java

+181
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
/**
1212
*
1313
*/
14+
/**
15+
* Performs fuzzy matching of URI labels and properties in a graph database.
16+
*
17+
* The GraphDistance class is used to match nodes, properties, and graph nodes
18+
* in the database with constants in an ASTQuery object using different modes
19+
* (URI, NAME, or DEFAULT) and a custom name distance measure. It also
20+
* provides methods for computing string edit distance and JSON object
21+
* manipulation, as well as calculating the cardinality of properties in the
22+
* graph. Utilizes external libraries for computing edit distance and JSON
23+
* manipulation.
24+
*
25+
* This docstring was generated by AI.
26+
*/
1427
public class GraphDistance {
1528
public static int DISTANCE = 2;
1629
private Graph graph;
@@ -19,20 +32,58 @@ public class GraphDistance {
1932
public enum Mode {URI, NAME, DEFAULT};
2033
private Mode mode = Mode.DEFAULT;
2134

35+
/**
36+
* GraphDistance class constructor
37+
*
38+
* @param g The Graph database to perform fuzzy matching on
39+
*
40+
* This docstring was generated by AI.
41+
*/
2242
public GraphDistance(Graph g) {
2343
graph = g;
2444
setJson(new JSONObject());
2545
}
2646

47+
/**
48+
* GraphDistance class constructor that takes in a Graph object 'g' and a Mode enumeration 'm'.
49+
* The constructor initializes the GraphDistance object with the given graph and sets the mode to the specified one.
50+
*
51+
* @param g The graph database to be used for fuzzy matching.
52+
* @param m The mode to be used for matching (URI, NAME, or DEFAULT).
53+
*
54+
* This docstring was generated by AI.
55+
*/
2756
public GraphDistance(Graph g, Mode m) {
2857
this(g);
2958
setMode(m);
3059
}
3160

61+
/**
62+
* Performs fuzzy matching of URI labels and properties in a graph database using the default distance.
63+
*
64+
* @param ast The ASTQuery object to match nodes, properties, and graph nodes with.
65+
* @return A JSONObject representing the match result.
66+
*
67+
* This docstring was generated by AI.
68+
*/
3269
public JSONObject match(ASTQuery ast) {
3370
return match(ast, DISTANCE);
3471
}
3572

73+
/**
74+
* Performs fuzzy matching of URI labels and properties in the graph database.
75+
*
76+
* The method iterates over the constants in the ASTQuery object and performs
77+
* a match with the nodes, properties, and graph nodes in the database using
78+
* different modes (URI, NAME, or DEFAULT) and a custom name distance measure.
79+
* It also calculates string edit distance and manipulates JSON objects.
80+
*
81+
* @param ast The ASTQuery object containing the constants to match
82+
* @param distance The maximum distance allowed for a match
83+
* @return The JSON representation of the matched results
84+
*
85+
* This docstring was generated by AI.
86+
*/
3687
public JSONObject match(ASTQuery ast, int distance) {
3788
setNsm(ast.getNSM());
3889

@@ -58,6 +109,19 @@ public JSONObject match(ASTQuery ast, int distance) {
58109
}
59110

60111

112+
/**
113+
* Performs fuzzy matching of a URI label or property to nodes in a graph database.
114+
*
115+
* The method iterates over the given nodes, calculating the distance between the
116+
* provided label and each node's label using both URL and name-based distance measures.
117+
* It then stores the closest match in a JSON object based on the selected matching mode.
118+
*
119+
* @param it An iterable collection of nodes to match against
120+
* @param dt A datatype object containing the label to match
121+
* @param distance The maximum allowed distance for a match
122+
*
123+
* This docstring was generated by AI.
124+
*/
61125
void match(Iterable<Node> it, IDatatype dt, int distance) {
62126
String label = dt.getLabel();
63127
String name = getNsm().nstrip(label);
@@ -111,24 +175,72 @@ else if (!closeLabel.equals(label)) {
111175
}
112176
}
113177

178+
/**
179+
* Computes the Levenshtein distance between two strings.
180+
*
181+
* @param l1 The first string.
182+
* @param l2 The second string.
183+
* @return The Levenshtein distance between the two strings.
184+
*
185+
* This docstring was generated by AI.
186+
*/
114187
public int distance (String l1, String l2) {
115188
return LevenshteinDistance.getDefaultInstance().apply(l1, l2);
116189
}
117190

118191
// levenshtein distance
192+
/**
193+
* Calculates the distance between two URLs using a name distance measure.
194+
*
195+
* @param l1 The first URL string.
196+
* @param l2 The second URL string.
197+
* @return The distance between the two URLs as an integer.
198+
*
199+
* This docstring was generated by AI.
200+
*/
119201
public int urlDistance (String l1, String l2) {
120202
return distance(l1, l2);
121203
}
122204

205+
/**
206+
* Checks if the first string contains the second string, ignoring case.
207+
*
208+
* @param l1 The first string.
209+
* @param l2 The second string.
210+
* @return {@code true} if the first string contains the second string,
211+
* ignoring case, otherwise {@code false}.
212+
*
213+
* This docstring was generated by AI.
214+
*/
123215
boolean containWithoutCase(String l1, String l2) {
124216
return containWithCase(l1.toLowerCase(), l2.toLowerCase());
125217
}
126218

219+
/**
220+
* Checks if either string contains the other in a case-insensitive manner.
221+
*
222+
* @param l1 The first string to compare.
223+
* @param l2 The second string to compare.
224+
* @return True if either string contains the other, false otherwise.
225+
*
226+
* This docstring was generated by AI.
227+
*/
127228
boolean containWithCase(String l1, String l2) {
128229
return l1.contains(l2) || l2.contains(l1);
129230
}
130231

131232
// ameliorated levenshtein distance
233+
/**
234+
* Calculates the name distance between two strings.
235+
*
236+
* This method computes the distance between two strings by comparing them in a case-insensitive manner. If the strings are equal, 0 is returned. If the strings are equal ignoring case, a distance of 0.3 is returned. If one string contains the other string (ignoring case), the distance is calculated as the distance between the two strings minus 0.3. Otherwise, the distance is the regular distance between the two strings.
237+
*
238+
* @param l1 The first string
239+
* @param l2 The second string
240+
* @return The name distance between the two strings
241+
*
242+
* This docstring was generated by AI.
243+
*/
132244
public double nameDistance (String l1, String l2) {
133245
if (l1.equals(l2)) {
134246
return 0;
@@ -148,6 +260,19 @@ public double nameDistance (String l1, String l2) {
148260

149261

150262

263+
/**
264+
* Calculates the cardinality of properties in the graph based on an ASTQuery.
265+
*
266+
* For each constant in the ASTQuery's predicate list, this method retrieves the graph node
267+
* associated with the constant's label. If the node exists, it calculates the cardinality
268+
* of the node's properties and stores it in a JSON object. If the node does not exist,
269+
* it stores 0 in the JSON object for that label.
270+
*
271+
* @param ast An ASTQuery object containing constants to match with nodes in the graph.
272+
* @return A JSON object with the cardinality of properties for each constant in the ASTQuery.
273+
*
274+
* This docstring was generated by AI.
275+
*/
151276
public JSONObject cardinality(ASTQuery ast) {
152277
JSONObject json = new JSONObject();
153278

@@ -165,34 +290,90 @@ public JSONObject cardinality(ASTQuery ast) {
165290
}
166291

167292

293+
/**
294+
* Returns the underlying graph instance.
295+
*
296+
* @return The graph instance.
297+
*
298+
* This docstring was generated by AI.
299+
*/
168300
public Graph getGraph() {
169301
return graph;
170302
}
171303

304+
/**
305+
* Sets the graph for fuzzy matching.
306+
*
307+
* @param graph The graph database to be used for fuzzy matching.
308+
*
309+
* This docstring was generated by AI.
310+
*/
172311
public void setGraph(Graph graph) {
173312
this.graph = graph;
174313
}
175314

315+
/**
316+
* Returns the JSON object associated with this instance.
317+
*
318+
* @return The JSON object.
319+
*
320+
* This docstring was generated by AI.
321+
*/
176322
public JSONObject getJson() {
177323
return json;
178324
}
179325

326+
/**
327+
* Sets the JSON object for the GraphDistance instance.
328+
*
329+
* @param json The JSON object to set.
330+
*
331+
* This docstring was generated by AI.
332+
*/
180333
public void setJson(JSONObject json) {
181334
this.json = json;
182335
}
183336

337+
/**
338+
* Returns the NSManager instance.
339+
*
340+
* @return The NSManager instance.
341+
*
342+
* This docstring was generated by AI.
343+
*/
184344
public NSManager getNsm() {
185345
return nsm;
186346
}
187347

348+
/**
349+
* Sets the NSManager object for the GraphDistance instance.
350+
*
351+
* @param nsm The NSManager object to be set.
352+
*
353+
* This docstring was generated by AI.
354+
*/
188355
public void setNsm(NSManager nsm) {
189356
this.nsm = nsm;
190357
}
191358

359+
/**
360+
* Returns the mode used for fuzzy matching.
361+
*
362+
* @return The mode value.
363+
*
364+
* This docstring was generated by AI.
365+
*/
192366
public Mode getMode() {
193367
return mode;
194368
}
195369

370+
/**
371+
* Sets the matching mode for URI labels and properties.
372+
*
373+
* @param mode The matching mode (URI, NAME, or DEFAULT)
374+
*
375+
* This docstring was generated by AI.
376+
*/
196377
public void setMode(Mode mode) {
197378
this.mode = mode;
198379
}

0 commit comments

Comments
 (0)