<commit_before>#include <iostream>
#include <jni.h>
#include <time.h>
#include "edu_mit_csail_uid_ScreenMatchProxy.h"
#include "template-matcher.h"
#include "ocr-matcher.h"
#include "screendiff.h"

#define CLASS_MATCH "edu/mit/csail/uid/Match"
#define DEBUG_DIFF

using namespace std;

jobjectArray& initMatches(JNIEnv *env, int size, jobjectArray& ret){
   jclass jClassMatch = env->FindClass(CLASS_MATCH);
   jobject jMatch = env->AllocObject(jClassMatch);
   ret = (jobjectArray)env->NewObjectArray(size, jClassMatch, jMatch);
   return ret;
}



jobjectArray genericMatch
(bool by_ocr, JNIEnv *env, jobject jobj, jstring jtarget, jstring jscreen, jdouble threshold, jint numMatches)
{
   const char *fname_target = env->GetStringUTFChars(jtarget, NULL);
   const char *fname_screen = env->GetStringUTFChars(jscreen, NULL);

   if( fname_target && fname_screen ){
      cout << "[JNI] Run screenMatch: " << fname_target << " " << fname_screen << endl;
   }
   Matches matches;
   if(by_ocr)
      matches = match_by_ocr(fname_screen, fname_target, numMatches, threshold);
   else
      matches = match_by_template(fname_screen, fname_target, numMatches, threshold);

   jobjectArray ret;
   ret = initMatches(env,  matches.size(), ret);

   jclass jClassMatch = env->FindClass(CLASS_MATCH);

   int i=0;
   for(Matches::iterator it = matches.begin(); it != matches.end(); ++it, ++i){
      //cout << it->x << " " << it->y << " " << it->score << endl;
      jobject match = env->AllocObject(jClassMatch);
      jfieldID match_x = env->GetFieldID(jClassMatch, "x", "I");
      jfieldID match_y = env->GetFieldID(jClassMatch, "y", "I");
      jfieldID match_w = env->GetFieldID(jClassMatch, "w", "I");<commit_msg>remove ocr-matcher<commit_after>#include <iostream>
#include <jni.h>
#include <time.h>
#include "edu_mit_csail_uid_ScreenMatchProxy.h"
#include "template-matcher.h"
#include "screendiff.h"

#define CLASS_MATCH "edu/mit/csail/uid/Match"
#define DEBUG_DIFF

using namespace std;

jobjectArray& initMatches(JNIEnv *env, int size, jobjectArray& ret){
   jclass jClassMatch = env->FindClass(CLASS_MATCH);
   jobject jMatch = env->AllocObject(jClassMatch);
   ret = (jobjectArray)env->NewObjectArray(size, jClassMatch, jMatch);
   return ret;
}



jobjectArray genericMatch
(bool by_ocr, JNIEnv *env, jobject jobj, jstring jtarget, jstring jscreen, jdouble threshold, jint numMatches)
{
   const char *fname_target = env->GetStringUTFChars(jtarget, NULL);
   const char *fname_screen = env->GetStringUTFChars(jscreen, NULL);

   if( fname_target && fname_screen ){
      cout << "[JNI] Run screenMatch: " << fname_target << " " << fname_screen << endl;
   }
   Matches matches;
   matches = match_by_template(fname_screen, fname_target, numMatches, threshold);

   jobjectArray ret;
   ret = initMatches(env,  matches.size(), ret);

   jclass jClassMatch = env->FindClass(CLASS_MATCH);

   int i=0;
   for(Matches::iterator it = matches.begin(); it != matches.end(); ++it, ++i){
      //cout << it->x << " " << it->y << " " << it->score << endl;
      jobject match = env->AllocObject(jClassMatch);
      jfieldID match_x = env->GetFieldID(jClassMatch, "x", "I");
      jfieldID match_y = env->GetFieldID(jClassMatch, "y", "I");
      jfieldID match_w = env->GetFieldID(jClassMatch, "w", "I");
{'fraction_non_alphanumeric': 0.14515151515151514, 'fraction_numerical': 0.0006060606060606061, 'mean_word_length': 4.613945578231292, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 35, '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': '1209774', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1153, 'n_words': 255}