<commit_before>#include <QUrl>
#include "kernel.h"
#include "ilwisdata.h"
#include "domain.h"
#include "catalog.h"
#include "connectorinterface.h"
#include "symboltable.h"
#include "mastercatalog.h"
#include "ilwiscontext.h"
#include "operationExpression.h"

using namespace Ilwis;

Parameter::Parameter() : _key(sUNDEF), _value(sUNDEF), _type(itUNKNOWN), _domain(sUNDEF) {
}

Parameter::Parameter(const QString &key, const QString &value, IlwisTypes tp, const SymbolTable &symtab) :
    Identity(key),
    _value(value),
    _domain(sUNDEF)
{
    _type = tp;
    if ( _type == itUNKNOWN)
        _type = Parameter::determineType(value, symtab);
}

Parameter::Parameter(const QString &value, IlwisTypes tp, const SymbolTable &symtab) : _domain(sUNDEF)
{
    _value = value;
    _type = tp;
    if ( _type == itUNKNOWN)
        _type = Parameter::determineType(_value, symtab);
}

Ilwis::Parameter::~Parameter()
{
}

QString Parameter::value() const
{
    return _value;
}

QString Parameter::domain() const
{
    return _domain;
}

void Parameter::domain(const QString &dom)
{
    _domain = dom;
}

IlwisTypes Parameter::valuetype() const
{
    return _type;
}

bool Parameter::isEqual(const Parameter &parm) const
{
    return parm.name() == name() && parm.value() == _value;
}

bool Parameter::isValid() const
{
    return !_value.isEmpty();
}

IlwisTypes Parameter::determineType(const QString& value, const SymbolTable &symtab) {
    IlwisTypes tp = IlwisObject::findType(value);
    if ( tp != itUNKNOWN)
        return tp;

    Symbol sym = symtab.getSymbol(value);
    if ( sym.isValid() && sym._type != itUNKNOWN)
        return sym._type;

    QString s = context()->workingCatalog()->resolve(value);
    IlwisTypes type = IlwisObject::findType(s) ;
    if ( type != itUNKNOWN)
        return type;

    if ( value.left(11) == ANONYMOUS_PREFIX) {
        QString sid = value.mid(11);
        bool ok;
        quint64 id = sid.toLongLong(&ok);
        if ( ok) {
            ESPIlwisObject obj =  mastercatalog()->get(id);
            if ( obj.get() != 0)
                return obj->ilwisType();
        }
    }

    if ( value.indexOf(NAME_ALIAS) == 0) {
        QString sid = value.mid(SZ_NAME_ALIAS);
        bool ok;
        quint64 id = sid.toLongLong(&ok);
        if ( ok) {
            ESPIlwisObject obj =  mastercatalog()->get(id);
            if ( obj.get() != 0)
                return obj->ilwisType();
        }
    }

    tp = Domain::ilwType(value);

    return tp == itUNKNOWN ? itSTRING : tp;

}



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

OperationExpression::OperationExpression()
{
}

Ilwis::OperationExpression::~OperationExpression()
{
}

OperationExpression::OperationExpression(const QString &e, const SymbolTable &symtab)
{
    setExpression(e, symtab);<commit_msg>extra way to determine the type of a id name<commit_after>#include <QUrl>
#include "kernel.h"
#include "ilwisdata.h"
#include "domain.h"
#include "catalog.h"
#include "connectorinterface.h"
#include "symboltable.h"
#include "mastercatalog.h"
#include "ilwiscontext.h"
#include "operationExpression.h"

using namespace Ilwis;

Parameter::Parameter() : _key(sUNDEF), _value(sUNDEF), _type(itUNKNOWN), _domain(sUNDEF) {
}

Parameter::Parameter(const QString &key, const QString &value, IlwisTypes tp, const SymbolTable &symtab) :
    Identity(key),
    _value(value),
    _domain(sUNDEF)
{
    _type = tp;
    if ( _type == itUNKNOWN)
        _type = Parameter::determineType(value, symtab);
}

Parameter::Parameter(const QString &value, IlwisTypes tp, const SymbolTable &symtab) : _domain(sUNDEF)
{
    _value = value;
    _type = tp;
    if ( _type == itUNKNOWN)
        _type = Parameter::determineType(_value, symtab);
}

Ilwis::Parameter::~Parameter()
{
}

QString Parameter::value() const
{
    return _value;
}

QString Parameter::domain() const
{
    return _domain;
}

void Parameter::domain(const QString &dom)
{
    _domain = dom;
}

IlwisTypes Parameter::valuetype() const
{
    return _type;
}

bool Parameter::isEqual(const Parameter &parm) const
{
    return parm.name() == name() && parm.value() == _value;
}

bool Parameter::isValid() const
{
    return !_value.isEmpty();
}

IlwisTypes Parameter::determineType(const QString& value, const SymbolTable &symtab) {
    IlwisTypes tp = IlwisObject::findType(value);
    if ( tp != itUNKNOWN)
        return tp;

    Symbol sym = symtab.getSymbol(value);
    if ( sym.isValid() && sym._type != itUNKNOWN)
        return sym._type;

    QString s = context()->workingCatalog()->resolve(value);
    IlwisTypes type = IlwisObject::findType(s) ;
    if ( type != itUNKNOWN)
        return type;

    quint64 id = IlwisObject::internalname2id(value);
    if ( id != i64UNDEF){
        ESPIlwisObject obj =  mastercatalog()->get(id);
        if ( obj.get() != 0)
            return obj->ilwisType();
    }
    tp = Domain::ilwType(value);

    return tp == itUNKNOWN ? itSTRING : tp;

}



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

OperationExpression::OperationExpression()
{
}

Ilwis::OperationExpression::~OperationExpression()
{
}

OperationExpression::OperationExpression(const QString &e, const SymbolTable &symtab)
{
    setExpression(e, symtab);
{'fraction_non_alphanumeric': 0.15195702225633154, 'fraction_numerical': 0.003261703760552571, 'mean_word_length': 3.3261410788381744, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1883053', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1738, 'n_words': 380}