Skip to content

Commit

Permalink
Revert "Added the AI generated (mixtral-8x7b-32768) docstrings"
Browse files Browse the repository at this point in the history
This reverts commit 3d0256a.
  • Loading branch information
AnnaBobasheva committed Nov 25, 2024
1 parent 25a3030 commit 04a64b1
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 8,645 deletions.
3,995 changes: 5 additions & 3,990 deletions corese-core/src/main/java/fr/inria/corese/core/Graph.java

Large diffs are not rendered by default.

181 changes: 0 additions & 181 deletions corese-core/src/main/java/fr/inria/corese/core/GraphDistance.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@
/**
*
*/
/**
* Performs fuzzy matching of URI labels and properties in a graph database.
*
* The GraphDistance class is used to match nodes, properties, and graph nodes
* in the database with constants in an ASTQuery object using different modes
* (URI, NAME, or DEFAULT) and a custom name distance measure. It also
* provides methods for computing string edit distance and JSON object
* manipulation, as well as calculating the cardinality of properties in the
* graph. Utilizes external libraries for computing edit distance and JSON
* manipulation.
*
* This docstring was generated by AI.
*/
public class GraphDistance {
public static int DISTANCE = 2;
private Graph graph;
Expand All @@ -32,58 +19,20 @@ public class GraphDistance {
public enum Mode {URI, NAME, DEFAULT};
private Mode mode = Mode.DEFAULT;

/**
* GraphDistance class constructor
*
* @param g The Graph database to perform fuzzy matching on
*
* This docstring was generated by AI.
*/
public GraphDistance(Graph g) {
graph = g;
setJson(new JSONObject());
}

/**
* GraphDistance class constructor that takes in a Graph object 'g' and a Mode enumeration 'm'.
* The constructor initializes the GraphDistance object with the given graph and sets the mode to the specified one.
*
* @param g The graph database to be used for fuzzy matching.
* @param m The mode to be used for matching (URI, NAME, or DEFAULT).
*
* This docstring was generated by AI.
*/
public GraphDistance(Graph g, Mode m) {
this(g);
setMode(m);
}

/**
* Performs fuzzy matching of URI labels and properties in a graph database using the default distance.
*
* @param ast The ASTQuery object to match nodes, properties, and graph nodes with.
* @return A JSONObject representing the match result.
*
* This docstring was generated by AI.
*/
public JSONObject match(ASTQuery ast) {
return match(ast, DISTANCE);
}

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

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


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

/**
* Computes the Levenshtein distance between two strings.
*
* @param l1 The first string.
* @param l2 The second string.
* @return The Levenshtein distance between the two strings.
*
* This docstring was generated by AI.
*/
public int distance (String l1, String l2) {
return LevenshteinDistance.getDefaultInstance().apply(l1, l2);
}

// levenshtein distance
/**
* Calculates the distance between two URLs using a name distance measure.
*
* @param l1 The first URL string.
* @param l2 The second URL string.
* @return The distance between the two URLs as an integer.
*
* This docstring was generated by AI.
*/
public int urlDistance (String l1, String l2) {
return distance(l1, l2);
}

/**
* Checks if the first string contains the second string, ignoring case.
*
* @param l1 The first string.
* @param l2 The second string.
* @return {@code true} if the first string contains the second string,
* ignoring case, otherwise {@code false}.
*
* This docstring was generated by AI.
*/
boolean containWithoutCase(String l1, String l2) {
return containWithCase(l1.toLowerCase(), l2.toLowerCase());
}

/**
* Checks if either string contains the other in a case-insensitive manner.
*
* @param l1 The first string to compare.
* @param l2 The second string to compare.
* @return True if either string contains the other, false otherwise.
*
* This docstring was generated by AI.
*/
boolean containWithCase(String l1, String l2) {
return l1.contains(l2) || l2.contains(l1);
}

// ameliorated levenshtein distance
/**
* Calculates the name distance between two strings.
*
* 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.
*
* @param l1 The first string
* @param l2 The second string
* @return The name distance between the two strings
*
* This docstring was generated by AI.
*/
public double nameDistance (String l1, String l2) {
if (l1.equals(l2)) {
return 0;
Expand All @@ -260,19 +148,6 @@ public double nameDistance (String l1, String l2) {



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

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


/**
* Returns the underlying graph instance.
*
* @return The graph instance.
*
* This docstring was generated by AI.
*/
public Graph getGraph() {
return graph;
}

/**
* Sets the graph for fuzzy matching.
*
* @param graph The graph database to be used for fuzzy matching.
*
* This docstring was generated by AI.
*/
public void setGraph(Graph graph) {
this.graph = graph;
}

/**
* Returns the JSON object associated with this instance.
*
* @return The JSON object.
*
* This docstring was generated by AI.
*/
public JSONObject getJson() {
return json;
}

/**
* Sets the JSON object for the GraphDistance instance.
*
* @param json The JSON object to set.
*
* This docstring was generated by AI.
*/
public void setJson(JSONObject json) {
this.json = json;
}

/**
* Returns the NSManager instance.
*
* @return The NSManager instance.
*
* This docstring was generated by AI.
*/
public NSManager getNsm() {
return nsm;
}

/**
* Sets the NSManager object for the GraphDistance instance.
*
* @param nsm The NSManager object to be set.
*
* This docstring was generated by AI.
*/
public void setNsm(NSManager nsm) {
this.nsm = nsm;
}

/**
* Returns the mode used for fuzzy matching.
*
* @return The mode value.
*
* This docstring was generated by AI.
*/
public Mode getMode() {
return mode;
}

/**
* Sets the matching mode for URI labels and properties.
*
* @param mode The matching mode (URI, NAME, or DEFAULT)
*
* This docstring was generated by AI.
*/
public void setMode(Mode mode) {
this.mode = mode;
}
Expand Down
Loading

0 comments on commit 04a64b1

Please sign in to comment.