Created
October 14, 2025 03:09
-
-
Save DreamOfTranscendence/a7d8e3ed0e7341c2419494d7cbf07086 to your computer and use it in GitHub Desktop.
generic Sentance compare ( a cool hardcoded pseudo-ai language thing maybe )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.compareWordSamePer100 = function compareWordSamePer100(s, s2) | |
| { //at least ##% of words must be the same for it to be considered the same | |
| var re=/\s\s/g, haz={}, wut=[], i=0, L=s.length-3, cs; | |
| s=s.toLowerCase().replace(re," ").replace(re," "); | |
| s2=s2.toLowerCase().replace(re," ").replace(re," "); | |
| while(i!=L){ | |
| cs="_"+s.substr(i,4); | |
| if( ! (cs in haz) ){ haz[cs] = 1; wut.push(cs); } | |
| else haz[cs] |= 1; | |
| i++; | |
| }; | |
| i=0; L=s2.length-3; | |
| while(i!=L){ | |
| cs="_"+s2.substr(i,4); | |
| if( ! (cs in haz) ){ haz[cs] = 2; wut.push(cs); } | |
| else haz[cs] |= 2; | |
| i++; | |
| }; | |
| i=0; L=wut.length; cs=0; | |
| while(i!=L){ | |
| if(haz[wut[i]]==3) cs++; | |
| i++; | |
| }; | |
| return cs/L; // return sameness in percent decimal format 1 == 100, 0.5 = 50% etc; | |
| }; // is this a cool function? does it help explain the workings of a single ai neuron in a language model, or is it nowhere close to how it actually works? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment