<commit_before>package org.projectspinoza.gephiswissarmyknife.graph.filters;

import org.gephi.data.attributes.api.AttributeColumn;
import org.gephi.data.attributes.api.AttributeModel;
import org.gephi.filters.plugin.attribute.AttributeEqualBuilder.EqualStringFilter;
import org.gephi.graph.api.Attributable;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.GraphModel;
import org.gephi.graph.api.Node;
import org.openide.util.Lookup;
import org.projectspinoza.gephiswissarmyknife.graph.GephiGraph.GraphDim;

public class Equal {
  
  
  private GraphModel graphModel;
  private AttributeModel attributeModel;
  private AttributeColumn attributeColumn;
  private Attributable attributable;
  private EqualStringFilter EqualStrfilter;
  
  public EqualStringFilter getEqualStrfilter() {
    return EqualStrfilter;
  }

  public void setEqualStrfilter(EqualStringFilter equalStrfilter) {
    EqualStrfilter = equalStrfilter;
  }

  public Equal() {
    setAttributable(Lookup.getDefault().lookup(Attributable.class));
  }
  
  public Equal (GraphModel graphModel, AttributeModel attributeModel) {
    this();
    this.setGraphModel(graphModel);
    this.setAttributeModel(attributeModel);
  }

  /*
   * 
   * 
   * */
  public void idNodeFilter(String id, boolean useRegex) {
    this.attributeColumn = attributeModel.getNodeTable().getColumn("id");
    this.EqualStrfilter = new EqualStringFilter(attributeColumn);
    this.EqualStrfilter.addProperty(String.class, "match");
    this.EqualStrfilter.setColumn(attributeColumn);
    this.EqualStrfilter.setPattern(id);
    this.EqualStrfilter.setUseRegex(useRegex);

    Graph graph = this.graphModel.getGraph();
    Node[] nodes = graph.getNodes().toArray();
    boolean nodeMatched = false;
    for (int i = 0; i < nodes.length; i++) {
      attributable = (Attributable) nodes[i];
      nodeMatched = this.EqualStrfilter.evaluate(graph, attributable);
      /*
       * See if node Matched then Remove it.
       */
      if (!nodeMatched) {
        graph.removeNode(nodes[i]);
      }
    }
  }
  
  public void idEdgeFilter (String id, boolean useRegex) {

  }
  
  public void labelNodeFilter (String label, boolean useRegex) {

  }
  
  public void labelEdgeFilter (String label, boolean useRegex) {

  }
  
  public void weightFilter (float weight) {
    
  }
  
  public void equalNumberFilter (String column, Number num) {
    
  }

  public void equalStringFilter (String column, String str) {
    
  }
  
  public void id (GraphDim dim, Number idNum) {
    this.attributeColumn = null;
    
    switch (dim) {
    case NODES:
      this.attributeColumn = attributeModel.getNodeTable().getColumn("id");
      break;
      
    case EDGES:
      this.attributeColumn = attributeModel.getEdgeTable().getColumn("id");
      break;

    default:
      break;
    }
  }
  
  public void id (GraphDim dim, String idString) {
    
  }
  
  public GraphModel getGraphModel() {
    return graphModel;
  }


  public void setGraphModel(GraphModel graphModel) {
    this.graphModel = graphModel;
  }


  public AttributeModel getAttributeModel() {
    return attributeModel;
  }

  public void setAttributeModel(AttributeModel attributeModel) {
    this.attributeModel = attributeModel;
  }


  public Attributable getAttributable() {
    return attributable;
  }

  public void setAttributable(Attributable attributable) {
    this.attributable = attributable;
  }
  
}
<commit_msg>minor modifications equal filter<commit_after>package org.projectspinoza.gephiswissarmyknife.graph.filters;

import org.gephi.data.attributes.api.AttributeColumn;
import org.gephi.data.attributes.api.AttributeModel;
import org.gephi.filters.plugin.attribute.AttributeEqualBuilder.EqualStringFilter;
import org.gephi.graph.api.Attributable;
import org.gephi.graph.api.Graph;
import org.gephi.graph.api.GraphModel;
import org.gephi.graph.api.Node;
import org.openide.util.Lookup;
import org.projectspinoza.gephiswissarmyknife.graph.GephiGraph.GraphDim;

public class Equal {
  
  
  private GraphModel graphModel;
  private AttributeModel attributeModel;
  private AttributeColumn attributeColumn;
  private Attributable attributable;
  private EqualStringFilter EqualStrfilter;
  
  public EqualStringFilter getEqualStrfilter() {
    return EqualStrfilter;
  }

  public void setEqualStrfilter(EqualStringFilter equalStrfilter) {
    EqualStrfilter = equalStrfilter;
  }

  public Equal() {
    setAttributable(Lookup.getDefault().lookup(Attributable.class));
  }
  
  public Equal (GraphModel graphModel, AttributeModel attributeModel) {
    this();
    this.setGraphModel(graphModel);
    this.setAttributeModel(attributeModel);
  }

  /*
   * @return void
   * 
   * Type: Filter
   * 
   * Function: filters Graph Nodes whose id matches the specified ID
   * 
   * OR
   * 
   * Contains the specified ID when 'useRegex' is set to true.
   * 
   * */
  public void idNodeFilter(String id, boolean useRegex) {
    this.attributeColumn = attributeModel.getNodeTable().getColumn("id");
    this.EqualStrfilter = new EqualStringFilter(attributeColumn);
    this.EqualStrfilter.addProperty(String.class, "match");
    this.EqualStrfilter.setColumn(attributeColumn);
    this.EqualStrfilter.setPattern(id);
    this.EqualStrfilter.setUseRegex(useRegex);

    Graph graph = this.graphModel.getGraph();
    Node[] nodes = graph.getNodes().toArray();
    boolean nodeMatched = false;
    for (int i = 0; i < nodes.length; i++) {
      attributable = (Attributable) nodes[i];
      nodeMatched = this.EqualStrfilter.evaluate(graph, attributable);
      /*
       * See if node Matched then Remove it.
       */
      if (!nodeMatched) {
        graph.removeNode(nodes[i]);
      }
    }
  }
  
  public void idEdgeFilter (String id, boolean useRegex) {

  }
  
  public void labelNodeFilter (String label, boolean useRegex) {

  }
  
  public void labelEdgeFilter (String label, boolean useRegex) {

  }
  
  public void weightFilter (float weight) {
    
  }
  
  public void equalNumberFilter (String column, Number num) {
    
  }

  public void equalStringFilter (String column, String str) {
    
  }
  
  public void id (GraphDim dim, Number idNum) {
    this.attributeColumn = null;
    
    switch (dim) {
    case NODES:
      this.attributeColumn = attributeModel.getNodeTable().getColumn("id");
      break;
      
    case EDGES:
      this.attributeColumn = attributeModel.getEdgeTable().getColumn("id");
      break;

    default:
      break;
    }
  }
  
  public void id (GraphDim dim, String idString) {
    
  }
  
  public GraphModel getGraphModel() {
    return graphModel;
  }


  public void setGraphModel(GraphModel graphModel) {
    this.graphModel = graphModel;
  }


  public AttributeModel getAttributeModel() {
    return attributeModel;
  }

  public void setAttributeModel(AttributeModel attributeModel) {
    this.attributeModel = attributeModel;
  }


  public Attributable getAttributable() {
    return attributable;
  }

  public void setAttributable(Attributable attributable) {
    this.attributable = attributable;
  }
  
}

{'fraction_non_alphanumeric': 0.09381603042682068, 'fraction_numerical': 0.0002817298211015636, 'mean_word_length': 3.5136681500317866, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '378741', 'n_tokens_mistral': 2170, 'n_tokens_neox': 2097, 'n_words': 452}