troubleshooting Question

Coldfusion Create the Structure of Arrays with a Distinct suggestions Words

Avatar of Dan Schimo
Dan SchimoFlag for United States of America asked on
XMLColdFusion LanguageRegular Expressions
7 Comments1 Solution338 ViewsLast Modified:
Hello Experts!

During one of my request for help , I have asked for a logic to convert an xml to Struct of arrays and it was very helpful ...

Related Question

Now we need an update the logic to contain ONLY DISTINCT values in the ARRAY
Please help ...

<suggestions elapsed-time="PT0.010333S">
<term original="dissorder">
<suggestion levenschtein-dist="1">Disorder</suggestion>
<suggestion levenschtein-dist="1">disorder</suggestion>
<suggestion levenschtein-dist="2">Disorders</suggestion>
<suggestion levenschtein-dist="2">disorders</suggestion>
<suggestion levenschtein-dist="2">distorter</suggestion>
<term original="sleep">
<suggestion levenschtein-dist="0">Sleep</suggestion>
<suggestion levenschtein-dist="0">sleep</suggestion>
<suggestion levenschtein-dist="1">asleep</suggestion>
<suggestion levenschtein-dist="1">seep</suggestion>
<suggestion levenschtein-dist="1">sleeps</suggestion>

<cfset terms = xmlSearch(xmlfile, "/suggestions/term")>					
					<cfset results  = structNew()>
          <cfloop array="#terms#" index="term">
            <cfset zeroLev = xmlSearch(term, "*[@levenschtein-dist='0']")>
            <cfif ArrayLen(zeroLev) EQ 0 >
                <cfset key = term.XmlAttributes.original >
                <cfset results[key] = []>
                <cfloop array="#term.xmlChildren#" index="child">
                      <cfset arrayAppend(results[key], child.xmlText)>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros