}
}
}
}
LookupToken firstWordLookupToken = (LookupToken) wLookupTokenList.get(firstTokenIndex.intValue());
Iterator permItr = permCol.iterator();
while (permItr.hasNext())
{
// convert permutation idx back into LookupTokens
List tempList = new ArrayList();
List permutation = (List) permItr.next();
Iterator idxItr = permutation.iterator();
while (idxItr.hasNext())
{
int idx = ((Integer) idxItr.next()).intValue();
if (idx <= firstTokenIndex.intValue())
{
idx--;
}
LookupToken lt = (LookupToken) wLookupTokenList.get(idx);
tempList.add(lt);
}
List singleTokenList = new ArrayList();
singleTokenList.add(firstWordLookupToken);
String[] fwPerms = iv_phrBuilder.getPhrases(singleTokenList);
String[] phrArr = iv_phrBuilder.getPhrases(tempList);
for (int i = 0; i < phrArr.length; i++)
{
for (int fwPermIdx = 0; fwPermIdx < fwPerms.length; fwPermIdx++)
{
StringBuffer phraseSB = new StringBuffer();
phraseSB.append(fwPerms[fwPermIdx]);
phraseSB.append(' ');
phraseSB.append(phrArr[i]);
String phrase = phraseSB.toString().trim().toLowerCase();
Set mdhSet = (Set) mdhMap.get(phrase);
if (mdhSet != null)
{
Iterator mdhIterator = mdhSet.iterator();
while (mdhIterator.hasNext())
{
MetaDataHit mdh = (MetaDataHit) mdhIterator.next();
// figure out start and end offsets
Collections.sort(permutation);
int startOffset;
if (permutation.size() > 0)
{
int firstIdx = ((Integer) permutation.get(0)).intValue();
if (firstIdx <= firstTokenIndex.intValue())
{
firstIdx--;
}
LookupToken lt = (LookupToken) wLookupTokenList.get(firstIdx);
if (lt.getStartOffset() < firstWordLookupToken.getStartOffset())
{
startOffset = lt.getStartOffset();
}
else
{
startOffset = firstWordLookupToken.getStartOffset();
}
}
else
{
startOffset = firstWordLookupToken.getStartOffset();
}
int endOffset;
if (permutation.size() > 0)
{
int lastIdx = ((Integer) permutation.get(permutation.size() - 1)).intValue();
if (lastIdx <= firstTokenIndex.intValue())
{
lastIdx--;
}
LookupToken lt = (LookupToken) wLookupTokenList.get(lastIdx);
if (lt.getEndOffset() > firstWordLookupToken.getEndOffset())
{
endOffset = lt.getEndOffset();
}
else
{
endOffset = firstWordLookupToken.getEndOffset();
}