Example usage for java.lang Float floatValue

List of usage examples for java.lang Float floatValue

Introduction

In this page you can find the example usage for java.lang Float floatValue.

Prototype

@HotSpotIntrinsicCandidate
public float floatValue() 

Source Link

Document

Returns the float value of this Float object.

Usage

From source file:blue.components.lines.Line.java

public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    Float val = (Float) aValue;
    float newValue = val.floatValue();

    LinePoint point = getLinePoint(rowIndex);

    boolean isLeft = (rowIndex == 0);
    boolean isRight = (rowIndex == (size() - 1));

    LinePoint previous = isLeft ? null : getLinePoint(rowIndex - 1);
    LinePoint next = isRight ? null : getLinePoint(rowIndex + 1);

    if (columnIndex == 0) {

        if (isLeft) {
            return;
        }// w  w w.  j av  a 2  s .co m

        if (rightBound && isRight) {
            return;
        }

        if (newValue < previous.getX()) {
            newValue = previous.getX();
        }

        if (rightBound && newValue > next.getX()) {
            newValue = next.getX();
        }

        float y = point.getY();
        point.setLocation(newValue, y);
    } else {
        if (newValue < getMin() || newValue > getMax()) {
            return;
        }

        float x = point.getX();
        point.setLocation(x, newValue);
    }

    fireTableCellUpdated(rowIndex, columnIndex);
}

From source file:pcgen.cdom.facet.analysis.ChallengeRatingFacet.java

private Float calcClassesForRaceCR(CharID id) {
    Float CR = new Float(0);
    int levelsKey = 0;
    int levelsNonKey = 0;
    int levelsConverted = 0;
    int threshold = 0;

    List<String> raceRoleList = raceFacet.get(id).getListFor(ListKey.MONSTER_ROLES);
    if (raceRoleList == null || raceRoleList.isEmpty()) {
        raceRoleList = SettingsHandler.getGame().getMonsterRoleDefaultList();
    }//from  w  ww.ja v  a2s  .c  om

    // Calculate and add the CR from the PC Classes
    for (PCClass pcClass : classFacet.getClassSet(id)) {
        Float levels = calcClassCR(id, pcClass);
        if (levels.isNaN()) {
            return Float.NaN;
        }

        List<String> classRoleList = pcClass.getListFor(ListKey.MONSTER_ROLES);
        if (classRoleList != null) {
            classRoleList.retainAll(raceRoleList);
            if (classRoleList.size() > 0) {
                levelsKey += (int) levels.floatValue();
            } else {
                levelsNonKey += (int) levels.floatValue();
            }
        } else {
            if (raceRoleList != null) {
                levelsNonKey += (int) levels.floatValue();
            } else {
                levelsKey += (int) levels.floatValue();
            }
        }

    }
    String sThreshold = SettingsHandler.getGame().getCRThreshold();
    if (sThreshold != null) {
        threshold = formulaResolvingFacet.resolve(id, FormulaFactory.getFormulaFor(sThreshold), "").intValue();
    }

    while (levelsNonKey > 1) {
        CR++;
        // TODO: maybe the divisor 2 should be be made configurable, 
        // or the whole calculation put into a formula
        levelsNonKey -= 2;
        levelsConverted += 2;
        if (levelsConverted >= threshold) {
            break;
        }
    }
    if (levelsConverted > 0) {
        CR += levelsNonKey;
    }
    CR += levelsKey;

    return CR;
}

From source file:edu.lternet.pasta.dml.database.DatabaseAdapter.java

/**
 * Creates a SQL command to insert data. If some error happens, null will be
 * returned./*from   www.ja v  a  2s . c o m*/
 * 
 * @param attributeList  AttributeList which will be inserted
 * @param tableName      The name of the table which the data will be inserted into
 * @param oneRowData     The data vector which contains data to be inserted
 * @return A SQL String that can be run to insert one row of data into table
 */
public String generateInsertSQL(AttributeList attributeList, String tableName, Vector oneRowData)
        throws DataNotMatchingMetadataException, SQLException {
    String sqlString = null;
    int NULLValueCounter = 0;
    int hasValueCounter = 0;

    if (attributeList == null) {
        throw new SQLException("The attribute list is null and couldn't generate insert sql statement");
    }

    if (oneRowData == null || oneRowData.isEmpty()) {
        throw new SQLException("The the data is null and couldn't generte insert sql statement");
    }

    StringBuffer sqlAttributePart = new StringBuffer();
    StringBuffer sqlDataPart = new StringBuffer();
    sqlAttributePart.append(INSERT);
    sqlAttributePart.append(SPACE);
    sqlAttributePart.append(tableName);
    sqlAttributePart.append(LEFTPARENTH);
    sqlDataPart.append(SPACE);
    sqlDataPart.append(VALUES);
    sqlDataPart.append(SPACE);
    sqlDataPart.append(LEFTPARENTH);
    Attribute[] list = attributeList.getAttributes();

    if (list == null || list.length == 0) {
        throw new SQLException("The attributes is null and couldn't generate insert sql statement");
    }

    int size = list.length;
    // column name part
    boolean firstAttribute = true;

    for (int i = 0; i < size; i++) {
        // if data vector
        Object obj = oneRowData.elementAt(i);
        String value = null;

        if (obj == null) {
            NULLValueCounter++;
            continue;
        } else {
            value = (String) obj;
            if (value.trim().equals("")) {
                continue;
            }
        }

        Attribute attribute = list[i];

        if (attribute == null) {
            throw new SQLException("Attribute list contains a null attribute");
        }
        String[] missingValues = attribute.getMissingValueCode();
        boolean isMissingValue = isMissingValue(value, missingValues);
        if (isMissingValue) {
            continue;
        }
        String name = attribute.getDBFieldName();
        String attributeType = getAttributeType(attribute);

        if (!firstAttribute) {
            sqlAttributePart.append(COMMA);
            sqlDataPart.append(COMMA);
        }

        sqlAttributePart.append(name);
        Domain domain = attribute.getDomain();

        /* If attributeType is "datetime", convert to a timestamp
         * and wrap single quotes around the value. But only if we
         * have a format string!
         */
        if (attributeType.equalsIgnoreCase("datetime")) {
            String formatString = ((DateTimeDomain) domain).getFormatString();

            // Transform the datetime format string for database compatibility
            formatString = transformFormatString(formatString);

            // Transform the datetime value for database compatibility
            value = transformDatetime(value);

            value = escapeSpecialCharacterInData(value);
            sqlDataPart.append(TO_DATE_FUNCTION);
            sqlDataPart.append(LEFTPARENTH);

            sqlDataPart.append(SINGLEQUOTE);
            sqlDataPart.append(value);
            sqlDataPart.append(SINGLEQUOTE);

            sqlDataPart.append(COMMA);

            sqlDataPart.append(SINGLEQUOTE);
            sqlDataPart.append(formatString);
            sqlDataPart.append(SINGLEQUOTE);

            sqlDataPart.append(RIGHTPARENTH);
            hasValueCounter++;
            log.debug("datetime value expression= " + sqlDataPart.toString());
        }
        /* If domain is null or it is not NumericDomain we assign it text type
         * and wrap single quotes around the value.
         */
        else if (attributeType.equals("string")) {
            value = escapeSpecialCharacterInData(value);
            sqlDataPart.append(SINGLEQUOTE);
            sqlDataPart.append(value);
            sqlDataPart.append(SINGLEQUOTE);
            hasValueCounter++;
        }
        /* Else we have a NumericDomain. Determine whether it is a float or
         * integer.
         */
        else {

            String dataType = mapDataType(attributeType);

            try {
                if (dataType.equals("FLOAT")) {
                    Float floatObj = new Float(value);
                    float floatNum = floatObj.floatValue();
                    sqlDataPart.append(floatNum);
                } else {
                    Integer integerObj = new Integer(value);
                    int integerNum = integerObj.intValue();
                    sqlDataPart.append(integerNum);
                }
            } catch (Exception e) {
                log.error("Error determining numeric value: " + e.getMessage());
                throw new DataNotMatchingMetadataException(
                        "Data value '" + value + "' is NOT the expected data type of '" + dataType + "'");
            }
            hasValueCounter++;
        }

        firstAttribute = false;
    }

    // If all data is null, return null value for sql string.
    if (NULLValueCounter == list.length || hasValueCounter == 0) {
        return sqlString;
    }

    sqlAttributePart.append(RIGHTPARENTH);
    sqlDataPart.append(RIGHTPARENTH);
    sqlDataPart.append(SEMICOLON);

    // Combine the two parts
    sqlAttributePart.append(sqlDataPart.toString());
    sqlString = sqlAttributePart.toString();

    return sqlString;
}

From source file:org.muse.mneme.impl.SubmissionStorageSample.java

/**
 * {@inheritDoc}// w w  w.  j  a  v a 2s. c o m
 */
public Float getSubmissionHighestScore(Assessment assessment, String userId) {
    Float rv = null;
    for (SubmissionImpl submission : this.submissions.values()) {
        if (submission.getAssessment().equals(assessment) && submission.getUserId().equals(userId)
                && submission.getIsComplete()
                && ((rv == null) || (submission.getTotalScore() > rv.floatValue()))) {
            rv = submission.getTotalScore();
        }
    }

    return rv;
}

From source file:org.vivoweb.harvester.score.Score.java

/**
 * Constructor/*from w  ww. java2  s . com*/
 * @param inputJena model containing statements to be scored
 * @param vivoJena model containing vivoJena statements
 * @param scoreJena model containing scoring data statements
 * @param tempJenaDir model in which to store temp copy of input and vivo data statements
 * @param algorithms the classes of the algorithms to execute
 * @param inputPredicates the predicates to look for in inputJena model
 * @param vivoPredicates the predicates to look for in vivoJena model
 * @param namespace limit match Algorithm to only match rdf nodes in inputJena whose URI begin with this namespace
 * @param weights the weightings (0.0 , 1.0) for this score
 * @param matchThreshold score things with a total current score greater than or equal to this threshold
 * @param batchSize number of records to use in batch
 * @param reloadInput reload the temp copy of input, only needed if input has changed since last score
 * @param reloadVivo reload the temp copy of Vivo, only needed if Vivo has changed since last score
 */
public Score(JenaConnect inputJena, JenaConnect vivoJena, JenaConnect scoreJena, String tempJenaDir,
        Map<String, Class<? extends Algorithm>> algorithms, Map<String, String> inputPredicates,
        Map<String, String> vivoPredicates, String namespace, Map<String, Float> weights, Float matchThreshold,
        int batchSize, boolean reloadInput, boolean reloadVivo) {
    if (inputJena == null) {
        throw new IllegalArgumentException("Input model cannot be null");
    }
    this.inputJena = inputJena;

    if (vivoJena == null) {
        throw new IllegalArgumentException("Vivo model cannot be null");
    }
    this.vivoJena = vivoJena;

    if (scoreJena == null) {
        throw new IllegalArgumentException("Score Data model cannot be null");
    }
    this.scoreJena = scoreJena;

    String tempDir = tempJenaDir;
    if (tempDir == null) {
        log.trace("temp model directory is not specified, using system temp directory");
        //         tempDir = File.createTempFile("tempVivoInputCopyJena", "db").getAbsolutePath();
        //         log.debug("temp model is not specifiedhi , using memory jena model");
        this.tempJena = new MemJenaConnect("urn:x-arq:UnionGraph");
    } else {
        this.tempJena = new TDBJenaConnect(tempDir, "urn:x-arq:UnionGraph");
    }

    if (algorithms == null) {
        throw new IllegalArgumentException("Algorithm cannot be null");
    }
    this.algorithms = algorithms;

    if (inputPredicates == null) {
        throw new IllegalArgumentException("Input Predicate cannot be null");
    }
    this.inputPredicates = inputPredicates;

    if (vivoPredicates == null) {
        throw new IllegalArgumentException("Vivo Predicate cannot be null");
    }
    this.vivoPredicates = vivoPredicates;

    if (this.algorithms.size() < 1) {
        throw new IllegalArgumentException("No runs specified!");
    }

    this.namespace = namespace;

    for (Float weight : weights.values()) {
        float d = weight.floatValue();
        if (d > 1f) {
            throw new IllegalArgumentException("Weights cannot be greater than 1.0");
        }
        if (d < 0f) {
            throw new IllegalArgumentException("Weights cannot be less than 0.0");
        }
    }
    this.weights = weights;

    Map<String, Map<String, ? extends Object>> maps = new HashMap<String, Map<String, ? extends Object>>();
    maps.put("vivoJena predicates", this.vivoPredicates);
    maps.put("inputJena predicates", this.inputPredicates);
    maps.put("algorithms", this.algorithms);
    maps.put("weights", this.weights);
    verifyRunNames(maps);
    boolean test = true;
    for (Class<?> algClass : this.algorithms.values()) {
        try {
            algClass.asSubclass(EqualityTest.class);
        } catch (ClassCastException e) {
            test = false;
            break;
        }
    }
    this.equalityOnlyMode = test;
    this.matchThreshold = matchThreshold;
    setBatchSize(batchSize);
    log.trace("equalityOnlyMode: " + this.equalityOnlyMode);
    this.reloadInput = reloadInput;
    this.reloadVivo = reloadVivo;

}

From source file:org.etudes.mneme.impl.SubmissionStorageSample.java

/**
 * {@inheritDoc}//from ww w . j a  v a2  s . co m
 */
public Float getSubmissionHighestScore(Assessment assessment, String userId) {
    Float rv = null;
    for (SubmissionImpl submission : this.submissions.values()) {
        if (submission.getAssessment().equals(assessment) && submission.getUserId().equals(userId)
                && submission.getIsComplete() && submission.getIsReleased()
                && ((rv == null) || (submission.getTotalScore() > rv.floatValue()))) {
            rv = submission.getTotalScore();
        }
    }

    return rv;
}

From source file:org.ecoinformatics.datamanager.database.DatabaseAdapter.java

/**
 * Creates a SQL command to insert data. If some error happens, null will be
 * returned./*from   ww  w  .j  a  v a 2 s  .c  o m*/
 * 
 * @param attributeList  AttributeList which will be inserted
 * @param tableName      The name of the table which the data will be inserted into
 * @param oneRowData     The data vector which contains data to be inserted
 * @return A SQL String that can be run to insert one row of data into table
 */
public String generateInsertSQL(AttributeList attributeList, String tableName, Vector oneRowData)
        throws DataNotMatchingMetadataException, SQLException {
    String sqlString = null;
    int NULLValueCounter = 0;
    int hasValueCounter = 0;

    if (attributeList == null) {
        //log.debug("There is no attribute definition in entity");
        throw new SQLException("The attribute list is null and couldn't generate insert sql statement");
    }

    if (oneRowData == null || oneRowData.isEmpty()) {
        //return sqlString;
        throw new SQLException("The the data is null and couldn't generte insert sql statement");
    }

    StringBuffer sqlAttributePart = new StringBuffer();
    StringBuffer sqlDataPart = new StringBuffer();
    sqlAttributePart.append(INSERT);
    sqlAttributePart.append(SPACE);
    sqlAttributePart.append(tableName);
    sqlAttributePart.append(LEFTPARENTH);
    sqlDataPart.append(SPACE);
    sqlDataPart.append(VALUES);
    sqlDataPart.append(SPACE);
    sqlDataPart.append(LEFTPARENTH);
    Attribute[] list = attributeList.getAttributes();

    if (list == null || list.length == 0) {
        //log.debug("There is no attribute definition in entity");
        //return sqlString;
        throw new SQLException("The attributes is null and couldn't generate insert sql statement");
    }

    int size = list.length;
    // column name part
    boolean firstAttribute = true;

    for (int i = 0; i < size; i++) {
        // if data vector
        Object obj = oneRowData.elementAt(i);
        String value = null;

        if (obj == null) {
            NULLValueCounter++;
            continue;
        } else {
            value = (String) obj;
            if (value.trim().equals("")) {
                continue;
            }
        }

        Attribute attribute = list[i];

        if (attribute == null) {
            //log.debug("One attribute definition is null attribute list");
            //return null;
            throw new SQLException("Attribute list contains a null attribute");
        }
        String[] missingValues = attribute.getMissingValueCode();
        boolean isMissingValue = isMissingValue(value, missingValues);
        if (isMissingValue) {
            continue;
        }
        String name = attribute.getDBFieldName();
        String attributeType = getAttributeType(attribute);

        if (!firstAttribute) {
            sqlAttributePart.append(COMMA);
            sqlDataPart.append(COMMA);
        }

        sqlAttributePart.append(name);
        Domain domain = attribute.getDomain();
        //System.out.println("the value in element is "+value);

        /* If attributeType is "datetime", convert to a timestamp
         * and wrap single quotes around the value. But only if we
         * have a format string!
         */
        if (attributeType.equalsIgnoreCase("datetime")) {
            String formatString = ((DateTimeDomain) domain).getFormatString();
            //System.out.println("in DateTimeDomain " + value);
            value = escapeSpecialCharacterInData(value);
            sqlDataPart.append(TO_DATE_FUNCTION);
            sqlDataPart.append(LEFTPARENTH);

            sqlDataPart.append(SINGLEQUOTE);
            sqlDataPart.append(value);
            sqlDataPart.append(SINGLEQUOTE);

            sqlDataPart.append(COMMA);

            sqlDataPart.append(SINGLEQUOTE);
            sqlDataPart.append(formatString);
            sqlDataPart.append(SINGLEQUOTE);

            sqlDataPart.append(RIGHTPARENTH);
            hasValueCounter++;
            log.debug("datetime value expression= " + sqlDataPart.toString());
        }
        /* If domain is null or it is not NumericDomain we assign it text type
         * and wrap single quotes around the value.
         */
        else if (attributeType.equals("string")) {
            //System.out.println("in non NumericDomain " + value);
            value = escapeSpecialCharacterInData(value);
            sqlDataPart.append(SINGLEQUOTE);
            sqlDataPart.append(value);
            sqlDataPart.append(SINGLEQUOTE);
            hasValueCounter++;
        }
        /* Else we have a NumericDomain. Determine whether it is a float or
         * integer.
         */
        else {

            String dataType = mapDataType(attributeType);

            try {
                if (dataType.equals("FLOAT")) {
                    //System.out.println("in float NumericDomain " + value);
                    Float floatObj = new Float(value);
                    /* System.out.println("after generating floatObj numericDomain "
                         + value); */
                    float floatNum = floatObj.floatValue();
                    //System.out.println("float number " + floatNum);
                    sqlDataPart.append(floatNum);
                    //System.out.println("end of float");
                } else {
                    //System.out.println("in integer NumericDomain " + value);
                    Integer integerObj = new Integer(value);
                    //System.out.println("after generate Integer Obj NumericDomain "
                    //                   + value);
                    int integerNum = integerObj.intValue();
                    //System.out.println("the int value is " + integerNum);
                    sqlDataPart.append(integerNum);
                    //System.out.println("end of integer");
                }
            } catch (Exception e) {
                System.out.println("Error determining numeric value: " + e.getMessage());
                //return sqlString;
                throw new DataNotMatchingMetadataException(
                        "Data " + value + " is NOT a " + dataType + " : " + e.getMessage());
            }
            hasValueCounter++;
        }

        firstAttribute = false;
        // insert
    }

    // If all data is null, return null value for sql string.
    if (NULLValueCounter == list.length || hasValueCounter == 0) {
        return sqlString;
        //throw new SQLException("All data is null and couldn't generate insert data statement");
    }

    sqlAttributePart.append(RIGHTPARENTH);
    sqlDataPart.append(RIGHTPARENTH);
    sqlDataPart.append(SEMICOLON);

    // Combine the two parts
    sqlAttributePart.append(sqlDataPart.toString());
    sqlString = sqlAttributePart.toString();
    //System.out.println("the sql command is " + sqlString);

    return sqlString;
}

From source file:edu.stanford.muse.xword.Crossword.java

/** looks up all names in the given docs in the names archive and assigns types to them. key in returned map has _ instead of spaces */
public void assignTypes(List<String> names) throws IOException {
    // compute name -> nameInfo
    wordToNameInfo = new LinkedHashMap<String, NameInfo>();
    // we're assuming no dups in the names
    for (String name : names) {
        String word = convertToWord(name).getFirst();
        String cTitle = name.trim().toLowerCase().replaceAll(" ", "_"); // canonical wp title         
        NameInfo ni = wordToNameInfo.get(word);
        ni = new NameInfo(cTitle);
        ni.score = 1;//from   w ww .  ja v a2  s  . co m
        Float F = wordToWeight.get(word);
        if (F != null) {
            ni.score = F;
            ni.times = (int) F.floatValue();
        }
        ni.snippet = "";
        ni.word = word;
        ni.originalTerm = wordToOriginalTerm.get(name);
        wordToNameInfo.put(word, ni);
    }

    // assign types to all the names
    NameTypes.readTypes(wordToNameInfo);
}

From source file:org.caleydo.core.data.collection.table.Table.java

/**
 * Returns the 3-component color for the given table cell. This works independent of the data type.
 *
 * FIXME: inhomogeneous numerical is not implemented
 *
 * @param dimensionID//from w w  w .j a v  a  2 s .  co  m
 * @param recordID
 * @return
 */
public float[] getColor(Integer dimensionID, Integer recordID) {
    if (isDataHomogeneous()) {
        return getColorMapper().getColor(getNormalizedValue(dimensionID, recordID));
    } else {
        if (EDataClass.CATEGORICAL.equals(getDataClass(dimensionID, recordID))) {
            CategoricalClassDescription<?> specific = (CategoricalClassDescription<?>) getDataClassSpecificDescription(
                    dimensionID, recordID);
            Object category = getRaw(dimensionID, recordID);
            if (category == null)
                return Color.NOT_A_NUMBER_COLOR.getRGBA();
            CategoryProperty<?> p = specific.getCategoryProperty(category);
            if (p == null)
                return Color.NOT_A_NUMBER_COLOR.getRGBA();
            return specific.getCategoryProperty(category).getColor().getRGBA();
        } else {
            // simple implementation just gray scale
            Float v = getNormalizedValue(dimensionID, recordID);
            if (v == null || v.isNaN())
                return Color.NOT_A_NUMBER_COLOR.getRGBA();
            return new Color(v.floatValue()).getRGBA();
            // not implemented
            // throw new IllegalStateException("not implemented");
        }
    }

}

From source file:net.iiit.siel.analysis.lang.LanguageIdentifier.java

/**
 * Identify./*from ww w . j  ava 2 s.  c  om*/
 *
 * @param content the content
 * @return the string
 */
public String identify(StringBuffer content) {
    // Added
    String lang = "", randomWord;
    StringBuffer text = content;
    if (text.length() <= 1)
        return "";

    LanguageIdentifierConstants.LangShortNames[] languagesSampled = new LanguageIdentifierConstants.LangShortNames[LanguageIdentifierConstants.totalRandomNumberTrials];
    /*
     * We need to analyse "text" now.
     */

    languagesSampled = getLanguagesSampled(text, LangIdentifierUtility.getRandomNumber(text.length() - 1,
            LanguageIdentifierConstants.totalRandomNumberTrials));

    // TODO uncomment the next line For TableMap purpose.(when needed
    // to create a lang-charRange table
    // languagesSampled = getLanguageAndForTaggingWithLangID(text);
    Boolean isNGramReqd = checkIsNGramReqd(languagesSampled);

    /*
     * if we already identified the right language then don't proceed to
     * ngram
     */
    if (!isNGramReqd) {
        //      System.out.println("Language is identified (without ngrams) as: "
        //            + languagesSampled[0].langShortName());
        /*
         * DONOT delete the next few lines, they should be enabled, when a
         * lang. mapping map needs to be generated. Set the
         * hashmapRangeMarker from start to end .. tag as LangID
         * 
         * String rangeMarkerString = this.langMarkerObject
         * .setLangRangeMarkerTableTillTheEnd(0); if
         * (!this.langMarkerObject.getLangRangeMarkerTable().containsKey(
         * languagesSampled[0].langShortName())) { ArrayList<String>
         * rangeMarkerArrayList = new ArrayList<String>();
         * rangeMarkerArrayList.add(rangeMarkerString);
         * this.langMarkerObject.getLangRangeMarkerTable().put(
         * languagesSampled[0].langShortName(), rangeMarkerArrayList); }
         * else { ArrayList<String> rangeMarkerArrayList = new
         * ArrayList<String>(); rangeMarkerArrayList = this.langMarkerObject
         * .getLangRangeMarkerTable().get(
         * languagesSampled[0].langShortName());
         * rangeMarkerArrayList.add(rangeMarkerString);
         * 
         * this.langMarkerObject.getLangRangeMarkerTable().put(
         * languagesSampled[0].langShortName(), rangeMarkerArrayList); }
         */

        return languagesSampled[0].langShortName();
    }

    //   System.out.print("Using NGP...  ");
    // Code to calculate n-gram profile similarity
    suspect.analyze(text);
    Iterator iter = suspect.getSorted().iterator();
    float topscore = Float.MIN_VALUE;
    HashMap scores = new HashMap();
    NGramEntry searched = null;
    List<String> listOfLang = new ArrayList<String>();
    int decide_point = 0;
    while (iter.hasNext()) {

        searched = (NGramEntry) iter.next();

        NGramEntry[] ngrams = (NGramEntry[]) ngramsIdx.get(searched.getSeq());

        /*
         * Check if ngrams is null, implies that such a sequence of
         * characters is not found in our profiles, which implies that the
         * profile is a foreign profile.
         */
        if (ngrams == null) {
            /*
             * Check if the searched.getSeq() has a indicUnicode
             */
            Boolean isForeignLangID = checkCharSequence(searched.getSeq());

            /*
             * Set the lang as unknown for foreignLangID.
             */
            if (isForeignLangID) {
                decide_point++;
                lang = LanguageIdentifierConstants.UKNOWN_LANG;
            }

        }
        if (ngrams != null) {
            for (int j = 0; j < ngrams.length; j++) {
                NGramProfile profile = ngrams[j].getProfile();
                /*
                 * Check when profile is null
                 */
                if (profile == null) {
                    profile = new NGramProfile(LanguageIdentifierConstants.UKNOWN_LANG,
                            NGramProfile.DEFAULT_MIN_NGRAM_LENGTH, NGramProfile.DEFAULT_MAX_NGRAM_LENGTH);
                }

                Float pScore = (Float) scores.get(profile);
                if (pScore == null) {
                    pScore = new Float(0);
                }
                float plScore = pScore.floatValue();
                plScore += ngrams[j].getFrequency() + searched.getFrequency();
                scores.put(profile, new Float(plScore));

                /*
                 * If the plScore is greater than topScore --> add
                 * the langId to list
                 */
                if (plScore > topscore) {
                    topscore = plScore;
                    lang = profile.getName();
                    /*
                     * Add the lang to list
                     */
                    if (!listOfLang.contains(lang)) {
                        listOfLang.add(lang);
                    }

                }
            }
        }
    }

    if (listOfLang.contains(LanguageIdentifierConstants.UKNOWN_LANG)
            && decide_point >= (content.length() * 0.1)) {
        lang = LanguageIdentifierConstants.UKNOWN_LANG;
    }
    System.out.println("Lang identified thru ngrams test =" + lang);
    return lang;
}