Index: gc_lang/fr/modules-js/lexicographe.js ================================================================== --- gc_lang/fr/modules-js/lexicographe.js +++ gc_lang/fr/modules-js/lexicographe.js @@ -334,14 +334,13 @@ } getListOfTokens (sText, bInfo = true) { let aElem = []; if (sText !== "") { - let aRes = null; for (let oToken of this.oTokenizer.genTokens(sText)) { if (bInfo) { - aRes = this.getInfoForToken(oToken); + let aRes = this.getInfoForToken(oToken); if (aRes) { aElem.push(aRes); } } else if (oToken.sType !== "SPACE") { aElem.push(oToken); @@ -357,34 +356,32 @@ getListOfTokensReduc (sText, bInfo = true) { let aTokenList = this.getListOfTokens(sText.replace("'", "’").trim(), false); let iKey = 0; let aElem = []; - let aRes = null; do { - let oToken = aTokenList[iKey] - let aLocution = this.oLocGraph[this._unifyStr(oToken.sValue)]; + let oToken = aTokenList[iKey]; let bLocFound = false; let iKeyTree = iKey + 1; let sTokenTmpKey = ''; - let aTokenTempList = []; - aTokenTempList.push(oToken); + let aTokenTempList = [oToken]; if (oToken.sType == "WORD" || oToken.sType == "ELPFX"){ - while (typeof(aLocution) !== "undefined") { + let oLocNode = this.oLocGraph[this._unifyStr(oToken.sValue)]; + while (typeof(oLocNode) !== "undefined") { let oTokenNext = aTokenList[iKeyTree]; iKeyTree++; if (typeof(oTokenNext) !== "undefined") { - aLocution = aLocution[this._unifyStr(oTokenNext.sValue)]; + oLocNode = oLocNode[this._unifyStr(oTokenNext.sValue)]; } else { - aLocution = "undefined"; + oLocNode = "undefined"; } - if (typeof(aLocution) !== "undefined" && iKeyTree <= aTokenList.length) { - sTokenTmpKey = Object.keys(aLocution)[0]; + if (typeof(oLocNode) !== "undefined" && iKeyTree <= aTokenList.length) { + sTokenTmpKey = Object.keys(oLocNode)[0]; aTokenTempList.push(oTokenNext); - } else if (typeof(aLocution) == "undefined" || iKeyTree > aTokenList.length) { + } else { if (sTokenTmpKey.substring(0, 1) == ':') { bLocFound = true; } break; } @@ -396,14 +393,14 @@ for (let oTokenWord of aTokenTempList) { sWord += oTokenWord.sValue+' '; } iKey = iKey + aTokenTempList.length-1; let oTokenLocution = { - 'nEnd':aTokenTempList[aTokenTempList.length-1].nEnd, - 'nStart':aTokenTempList[0].nStart, - 'sType':"LOC", - 'sValue':sWord.replace('’ ','’').trim() + 'nEnd': aTokenTempList[aTokenTempList.length-1].nEnd, + 'nStart': aTokenTempList[0].nStart, + 'sType': "LOC", + 'sValue': sWord.replace('’ ','’').trim() }; if (bInfo) { let aFormatedTag = []; for (let sTagMulti of sTokenTmpKey.split('|') ){ aFormatedTag.push( this._formatTags(sTagMulti).replace(/( \(él.\))/g,'') ); @@ -416,11 +413,11 @@ } else { aElem.push(oTokenLocution); } } else { if (bInfo) { - aRes = this.getInfoForToken(oToken); + let aRes = this.getInfoForToken(oToken); if (aRes) { aElem.push(aRes); } } else { aElem.push(oToken);