Skip to content

Commit

Permalink
NLP-ENGINE-426 added pnvartype
Browse files Browse the repository at this point in the history
Signed-off-by: David de Hilster <[email protected]>
  • Loading branch information
ddehilster committed Sep 26, 2024
1 parent 16627e6 commit 3b4891b
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-enginefiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
recursive: false
dest: nlpengine.zip

- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v4
with:
name: nlpengine.zip
path: ${{ github.workspace }}/nlpengine.zip
2 changes: 1 addition & 1 deletion .github/workflows/build-visualfiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
recursive: false
dest: visualtext.zip

- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v4
with:
name: visualtext.zip
path: ${{ github.workspace }}/visualtext.zip
1 change: 1 addition & 0 deletions include/Api/lite/Arun.h
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,7 @@ class LITE_API Arun

static RFASem *pnvarnames(Nlppp*,NODE*); // 05/13/02 AM.
static RFASem *pnvarnames(Nlppp*,RFASem*); // 05/13/02 AM.
static RFASem *pnvartype(Nlppp*,NODE*,_TCHAR*);

static bool pnmakevar(Nlppp*,NODE*,_TCHAR*,_TCHAR*); // 07/03/02 AM.
static bool pnmakevar(Nlppp*,NODE*,_TCHAR*,long long); // 07/03/02 AM.
Expand Down
59 changes: 59 additions & 0 deletions lite/fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ switch (fnid) // 12/21/01 AM.
return fnPnvar(args,nlppp,/*UP*/sem); // 10/18/00 AM.
case FNpnvarnames:
return fnPnvarnames(args,nlppp,/*UP*/sem); // 05/13/02 AM.
case FNpnvartype:
return fnPnvartype(args,nlppp,sem);
case FNpranchor:
break;
case FNprchild:
Expand Down Expand Up @@ -10932,6 +10934,63 @@ if (vars)
return true;
}

/********************************************
* FN: FNPNVARTYPE
* CR: 09/25/2024 Dd.
* SUBJ: Check what type of variable a PNODE has.
* RET: 0 = string, 1 = int, 2 = concept, 3 = float
********************************************/

bool Fn::fnPnvartype(
Delt<Iarg> *args,
Nlppp *nlppp,
RFASem* &sem
)
{
sem = 0;
Parse *parse = nlppp->parse_;

RFASem *sem1;
_TCHAR *name1=0;

if (!Arg::sem1(_T("pnvar"),nlppp,(DELTS*&)args,sem1))
return false;
if (!Arg::str1(_T("pnvar"), /*UP*/ (DELTS*&)args, name1))
return false;
if (!Arg::done((DELTS*)args, _T("pnvar"),parse))
return false;

if (!sem1)
{
_stprintf(Errbuf,_T("[pnvar: Warning. Given no pnode.]"));
return parse->errOut(true);
}
if (!name1)
{
_stprintf(Errbuf,_T("[pnvar: Warning. Given no name.]"));
return parse->errOut(true);
}

// Get object from sem.
if (sem1->getType() != RSNODE)
{
_stprintf(Errbuf,_T("[pnvar: Bad semantic arg.]"));
return parse->errOut(false);
}

Node<Pn> *node = sem1->getNode();

if (!node)
{
_stprintf(Errbuf,_T("[pnvar: Couldn't fetch node.]"));
return parse->errOut(false);
}

sem = Arun::pnvartype(nlppp,node,name1);
return true;
}


#ifdef _ODBC

/********************************************
Expand Down
1 change: 1 addition & 0 deletions lite/fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ static bool fnStruniquechars(
static bool fnCoutreset(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/06/02 AM.
static bool fnInteractive(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/06/02 AM.
static bool fnPnvarnames(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/13/02 AM.
static bool fnPnvartype(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/13/02 AM.

static bool fnDbopen(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/23/02 AM.
static bool fnDbclose(Delt<Iarg>*,Nlppp*,RFASem*&); // 05/23/02 AM.
Expand Down
66 changes: 65 additions & 1 deletion lite/fnrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8215,7 +8215,7 @@ return str;
* NOTE: First NLP++ function for PNODE type!
********************************************/

RFASem *Arun::pnvar(
RFASem *Arun:: pnvar(
Nlppp *nlppp,
NODE *node,
_TCHAR *name1
Expand Down Expand Up @@ -13348,6 +13348,70 @@ delete node_sem;
return pnvarnames(nlppp,pnode);
}


RFASem *Arun::pnvartype(
Nlppp *nlppp,
NODE *pnode,
_TCHAR *varname
)
{
RFASem *sem = 0;
if (!nlppp || !pnode || !varname || !*varname)
return 0;

Node<Pn> *node = (Node<Pn> *)pnode;
Pn *pn = node->getData();
Dlist<Ipair> *dlist = pn->getDsem();
if (!dlist)
return 0;

Ipair *pairx = 0;
Var::find(varname,dlist,pairx);
if (!pairx)
return 0;

Dlist<Iarg> *vals = pairx->getVals();
if (!vals)
return 0;

Delt<Iarg> *darg = vals->getFirst();
if (!darg)
return 0;

long long typNum = 0;

Iarg *arg = darg->getData();
RFASem *obj;

/* 0 = string, 1 = int, 2 = concept, 3 = float */
switch (arg->getType())
{
case IASTR:
typNum = 0;
break;
case IANUM:
typNum = 1;
break;
case IASEM:
obj = arg->getSem();
if (!obj)
return 0;
switch (obj->getType())
{
case RS_KBCONCEPT:
typNum = 2;
break;
}
case IAFLOAT:
typNum = 3;
break;
}

sem = new RFASem(typNum);
return sem;
}


#ifdef _ODBC

/********************************************
Expand Down
1 change: 1 addition & 0 deletions lite/func_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ enum funcDef
FNpnup,
FNpnvar,
FNpnvarnames, // 05/13/02 AM.
FNpnvartype,
FNpranchor,
FNprchild,
FNpreaction,
Expand Down
1 change: 1 addition & 0 deletions lite/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ _T("pnsingletdown"),
_T("pnup"),
_T("pnvar"),
_T("pnvarnames"), // 05/13/02 AM.
_T("pnvartype"),
_T("pranchor"),
_T("prchild"),
_T("preaction"),
Expand Down
2 changes: 1 addition & 1 deletion nlp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ All rights reserved.
#include "lite/nlp_engine.h"
#include "version.h"

#define NLP_ENGINE_VERSION "2.12.3"
#define NLP_ENGINE_VERSION "2.13.0"

bool cmdReadArgs(int,_TCHAR*argv[],_TCHAR*&,_TCHAR*&,_TCHAR*&,_TCHAR*&,bool&,bool&,bool&);
void cmdHelpargs(_TCHAR*);
Expand Down

0 comments on commit 3b4891b

Please sign in to comment.