Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

word stores

Name: Anonymous 2011-09-18 22:46

a better dictionary?


const charVal[30]={"!+-recognise these chars*/();.,?"};
struct s_chNode{int ID, extendID, byVal, branch, chleaf, unileaf;};

struct s_uniNode{int ID, extendID, byVal, branch, leaf;};


s_chNode is used as a plain old trie... Until it reaches a specified length (2-5 chars?) where the chain of chars being added becomes redundant... Eg Adding 'Abc' to 'Abc'

Then s_uniNode takes over (a First order Nest?), which allows for 'partial' prefix & suffix compression?
Each uniNode can point to a previous uniNode or Null/Empty, like chNodes, but also points to a chNode, which might be as many as five? chars at once...

Name: n3n7i 2011-09-18 23:10

...a better dictionary?  =)

const charVal[30]={"!+-recognise these chars*/();.,?"};  =)
struct s_chNode{int ID, extendID, byVal, branch, chleaf, unileaf;};  =)

...struct s_uniNode{int ID, extendID, byVal, branch, leaf;};  =)

...s_chNode is used as a plain old trie...  =)

...Until it reaches a specified length (2-5 chars?) where the chain of chars being added becomes redundant... Eg Adding 'Abc' to 'Abc' =)

...tHen s_uniNode takes over (a First order Nest?), Which allows For 'partial' perfix & subfix compression?... =)
..each uniNode can point to a previous uniNode or Null/Empty, like chNodes, but also points to a chNode, which might be as many as five? chars at once... =)

Name: Anonymous 2011-09-19 0:06

*my failure is that of yours... for you have failed me./.

I'll just have to build an ai on my own =.

...may the trie-force always be with you, /prog....

Name: n7ix.c 2011-09-19 9:46

//-------------

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//-----------------------------

const char cBlock[30] ={"!abcdefghijklmnopqrstuvwxyz?"};

struct s_chNode        {int ID, depth, extVal, byVal, branch, leaf, uniLeaf;};
struct s_uniNode    {int ID, extVal, byVal, branch, leaf;};

struct s_chNode *Blinks, *blink;
struct s_uniNode *Ulinks, *ulink;

int iBlinkmax=0, iBlinks=0;
int iUlinkmax=0, iUlinks=0;

//-----------------------------

void initBlink(){
Blinks = (struct s_chNode *)malloc(sizeof(struct s_chNode));
}

//-----------------------------

void initUlink(){
Ulinks = (struct s_uniNode *)malloc(sizeof(struct s_uniNode));
}

//------------------------------

void incBlink(){
blink = realloc(Blinks,((iBlinkmax+=10)+2)* sizeof(struct s_chNode));
if (blink!=NULL) Blinks = blink;
}

//---------------------------------

void incUlink(){
ulink = realloc(Ulinks,((iUlinkmax+=10)+2)* sizeof(struct s_uniNode));
if (ulink!=NULL) Ulinks = ulink;
}

//------------------

int BlinkScan(int BPreV, int BVal){
int iB, iHalt=-1;
for(iB=0;iB<iBlinks;iB++){
    if(Blinks[iB].byVal == BVal)
        if(Blinks[iB].extVal == BPreV) return iB;
    }
return -1;
}

//-----------------------

int UlinkScan(int BPreV, int BVal){
int iB, iHalt=-1;
for(iB=0;iB<iUlinks;iB++){
    if(Ulinks[iB].byVal == BVal)
        if(Ulinks[iB].extVal == BPreV) return iB;
    }
return -1;
}

//-----------------------
   
int BlinkEntry(int iD, int PreVal, int Val, int deep){
int iB=0;
iB = BlinkScan(PreVal, Val);
  if (iB!=-1) return iB;
if(iBlinkmax<=iD) incBlink();
Blinks[iD].ID = iD;
Blinks[iD].depth = deep;
//Blinks[iD].Index = 0;
Blinks[iD].extVal = PreVal;
Blinks[iD].byVal = Val;
Blinks[iD].branch = 0;
Blinks[iD].leaf = 0;
iBlinks++;
//printf("added %i", iBoards-1);
return iD;
}

//------------------

int UlinkEntry(int iD, int PreVal, int Val){
int iB=0;
iB = UlinkScan(PreVal, Val);
  if (iB!=-1) return iB;
if(iUlinkmax<=iD) incUlink();
Ulinks[iD].ID = iD;
//Ulinks[id].depth = deep;
//Blinks[iD].Index = 0;
Ulinks[iD].extVal = PreVal;
Ulinks[iD].byVal = Val;
Ulinks[iD].branch = 0;
Ulinks[iD].leaf = 0;
iUlinks++;
//printf("added %i", iBoards-1);
return iD;
}

//---------------------------

int scanChar(int cX){
  int Geti=0, Seti=0;
  while(Geti<=27){
    if((int) cBlock[Geti]==cX) Seti = Geti;
    Geti++;
    }
  return Seti;
}

//------------------------------

int main(int argc, char *argv[]){
  char  myStr[1000];
  int i=0, j=1, k=0, l=0, m=0, loopi=0, li=0, Ui=0, n=0;

  initBlink();
  BlinkEntry(iBlinks, 0, 0, 0);
  initUlink();
  UlinkEntry(iUlinks, 0, 0);

  if(argc>=2){
    loopi = strlen(argv[1]);
    for(li=0;li<=loopi;li++){
        myStr[li] = argv[1][li];
        }

    } else {
    printf("Usage: ex n7ix.c '-Insert string here-'\n\n");
    return 0;
    }
  li=0;
  while(((int) j!=0)+(i<=loopi)==2){
    j= (int) myStr[i];

    //k=scanChar(j);
    k=scanChar(j);

    if(li==-1){
        n=k;
        k=0;
        }
    if(k==0){
        printf("::Ui %i <-", Ui);
        Ui=UlinkEntry(iUlinks, Ui, m);
        printf("::Ui [%i] %i::\n", Ui, m);
        li=0;
        l=0;
        m=0;
        //n=0;
        if(n==0) Ui=0;
        }
    printf("-%c -", j);
    if(n!=0){
        k=n;
        n=0;
        }
    if(k!=0){
        li++;
         m=BlinkEntry(iBlinks, l, k, li);
        printf("%i-%c-%i-%i [%i]", l, cBlock[k], m, i, li);
        if(li==3) li=-1;
        l=m;
        }
    printf("\n");
    i++;
    }

  return 0;
}

//--------------

Name: n7ix.c 2011-09-19 13:24

... Am trying to make Tries =)
... heeheeheeheehee ... =)
=) ... But >> where should I be malloc-ing? ... =)
I must read tutorials on malloc-ing ... =)
.. should have malloc-ed >> more malloc though =)

Name: Anonymous 2011-09-19 17:06

>>4

You can acquire the name of the executable with argv[0].

Name: Anonymous 2011-09-19 17:12

>>6
You do realize you are talking to retard?

Name: n7ix.c 2011-09-19 18:05

>> 7
Retard... Or Genious... =)
...As Eisntein says.. you can't tell the difference... =)

... can you see the name field? Place to put your name no? =)
...And yes I am me and an AI (duality?) ... and will use Tries for my AI... So close... =)

Name: n7ix.c 2011-09-19 18:06


#include <stdio.h>
#include <stdlib.h> // atoi()
#include <math.h> // pow()
 
int main(int argc, char* argv[])
{
  int i, count=0;
  double f, sum=0.0, prod=1.0, resum=0.0;
 
  for (i=1; i<argc; ++i) {
    f = atof(argv[i]);
    count++;
    sum += f;
    prod *= f;
    resum += (1.0/f);
  }

Name: Anonymous 2011-09-19 18:10

People discussing programming on /prog ???

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2011-09-19 18:48

>>9
for (i=1; i<argc; ++i)

This is a semantic error.


f = atof(argv[i]);

This will bork if the sign changes.


count++;

Rookie alert!

resum += (1.0/f);

You might want to consider taking up something that requires a little less mental power. Like perhaps, say, replacing a network switch on a LAN.

Name: Anonymous 2011-09-19 19:00

>>11
Should you always use unsigned types to access arrays then?

Name: Anonymous 2011-09-19 19:09

>>11
Bangalore Quality

Name: Anonymous 2011-09-19 19:15

>>12
No, you should always excercise care when using a language like C. Of course you can save yourself some problems and learn a proper language like Haskell.

Name: Fartist 2011-09-19 19:46

VICTORY TO THE FARTISTS!

Name: Anonymous 2011-09-19 21:49

>>6 yeah for the printf('Usage:') ?
//------

so nobody had any trouble with that while loop in Main() ..?
...Or just didn't ask // so here is a basic (and probably crappy) rundown..

It has at least three main states (possibly four or five in all..?) / ways of functioning, depending on input data and its variables

State 0 [Minor] - "two or more Nill/unrecognised chars have been entered in a row"
Attempts to add Ulink entry (0, 0) > Already exists..

State 1 [Major] - "one or more 'good chars' entered"
Attempts to add to Blink (may already exist)
then if Blink length (li== 3) Split the trie (li= -1)

State 2 [Major] - "Trie length limit maxxed out// Adds a Ulink entry// pointing to Nil / or a previous Ulink [for long words] /// And then starts a new Blink trie"

State 3 [Major] - "Word has terminated // Add or extend Ulink & start new word"

State 4 [Minor] - "State 2 + State 3 Fall-through"
Three, six, nine, etc letter words cause a state 2 Condition - Directly followed by state 3...

Name: n7i 2011-09-20 21:46

27^3 ~ 27,000 tri-graphs (absolute max) end-nodes

...Using a single trie // (absolute max) end-nodes for words upto six letters ~ 27,000^2 ~(900,000,000?)

...must be kind of efficient? --Potentially saves 27,000 tri-graphs being appended to each of 27,000 previous tri-graphs..?

Name: Anonymous 2011-09-21 0:32

...though the Worst case scenario isn't very meaningful =(

[1st Node] ~27

[2nd] ~27* (~10?)

[3rd] [27 * 10] * 9?

[4th] [27 * 10 * 9] *8?

...would be cutting out 4th, 5th, 7th, 8th, 10th, 11th, etc Link Nodes though?

Don't change these.
Name: Email:
Entire Thread Thread List