Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here we go, you've just got good compiler. mingw32-gcc compiler (which is DevCpp built-in compiler) just giving some error like this</p> <pre><code>error: dependent-name ` T::int' is parsed as a non-type, but instantiation yields a type </code></pre> <p>It does not take <code>map &lt;T, int&gt;::iterator</code> as a type because thats depends on Templates, you need to use <a href="http://www.cppreference.com/wiki/keywords/typename" rel="nofollow noreferrer">typename</a> keyword for dependent names</p> <p>So, use <code>typename map &lt;T, int&gt;::iterator</code></p> <p>I have done test compiled <a href="http://test.my-mm.org/so/2627388/" rel="nofollow noreferrer">here</a>. there is source main.cpp file and compiled .exe file and a data file.</p> <p>And looks like you got those codes from here</p> <p><a href="http://www.chasen.org/~taku/software/prefixspan/" rel="nofollow noreferrer">http://www.chasen.org/~taku/software/prefixspan/</a></p> <p>its GPL v2, you might need to add those license to your code too.</p> <p><strong>Edit</strong>: Adding fixed codes for later reference</p> <pre><code>/* PrefixSpan: An efficient algorithm for sequential pattern mining $Id: prefixspan.cpp,v 1.8 2002/04/03 13:35:23 taku-ku Exp $; Copyright (C) 2002 Taku Kudo All rights reserved. This is free software with ABSOLUTELY NO WARRANTY. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;vector&gt; #include &lt;string&gt; #include &lt;string.h&gt; #include &lt;strstream&gt; #include &lt;unistd.h&gt; #include &lt;stdlib.h&gt; using namespace std; template &lt;class T&gt; class PrefixSpan { private: vector &lt; vector &lt;T&gt; &gt; transaction; vector &lt; pair &lt;T, unsigned int&gt; &gt; pattern; unsigned int minsup; unsigned int minpat; unsigned int maxpat; bool all; bool where; string delimiter; bool verbose; ostream *os; void report (vector &lt;pair &lt;unsigned int, int&gt; &gt; &amp;projected){ if (minpat &gt; pattern.size()) return; // print where &amp; pattern if (where) { *os &lt;&lt; "&lt;pattern&gt;" &lt;&lt; endl; // what: if (all) { *os &lt;&lt; "&lt;freq&gt;" &lt;&lt; pattern[pattern.size()-1].second &lt;&lt; "&lt;/freq&gt;" &lt;&lt; endl; *os &lt;&lt; "&lt;what&gt;"; for (unsigned int i = 0; i &lt; pattern.size(); i++) *os &lt;&lt; (i ? " " : "") &lt;&lt; pattern[i].first; } else { *os &lt;&lt; "&lt;what&gt;"; for (unsigned int i = 0; i &lt; pattern.size(); i++) *os &lt;&lt; (i ? " " : "") &lt;&lt; pattern[i].first &lt;&lt; delimiter &lt;&lt; pattern[i].second; } *os &lt;&lt; "&lt;/what&gt;" &lt;&lt; endl; // where *os &lt;&lt; "&lt;where&gt;"; for (unsigned int i = 0; i &lt; projected.size(); i++) *os &lt;&lt; (i ? " " : "") &lt;&lt; projected[i].first; *os &lt;&lt; "&lt;/where&gt;" &lt;&lt; endl; *os &lt;&lt; "&lt;/pattern&gt;" &lt;&lt; endl; } else { // print found pattern only if (all) { *os &lt;&lt; pattern[pattern.size()-1].second; for (unsigned int i = 0; i &lt; pattern.size(); i++) *os &lt;&lt; " " &lt;&lt; pattern[i].first; } else { for (unsigned int i = 0; i &lt; pattern.size(); i++) *os &lt;&lt; (i ? " " : "") &lt;&lt; pattern[i].first &lt;&lt; delimiter &lt;&lt; pattern[i].second; } *os &lt;&lt; endl; } } void project (vector &lt;pair &lt;unsigned int, int&gt; &gt; &amp;projected){ if (all) report(projected); map &lt;T, vector &lt;pair &lt;unsigned int, int&gt; &gt; &gt; counter; for (unsigned int i = 0; i &lt; projected.size(); i++) { int pos = projected[i].second; unsigned int id = projected[i].first; unsigned int size = transaction[id].size(); map &lt;T, int&gt; tmp; for (unsigned int j = pos + 1; j &lt; size; j++) { T item = transaction[id][j]; if (tmp.find (item) == tmp.end()) tmp[item] = j ; } for (typename map &lt;T, int&gt;::iterator k = tmp.begin(); k != tmp.end(); ++k) counter[k-&gt;first].push_back (make_pair &lt;unsigned int, int&gt; (id, k-&gt;second)); } for (typename map &lt;T, vector &lt;pair &lt;unsigned int, int&gt; &gt; &gt;::iterator l = counter.begin (); l != counter.end (); ) { if (l-&gt;second.size() &lt; minsup) { typename map &lt;T, vector &lt;pair &lt;unsigned int, int&gt; &gt; &gt;::iterator tmp = l; tmp = l; ++tmp; counter.erase (l); l = tmp; } else { ++l; } } if (! all &amp;&amp; counter.size () == 0) { report (projected); return; } for (typename map &lt;T, vector &lt;pair &lt;unsigned int, int&gt; &gt; &gt;::iterator l = counter.begin (); l != counter.end(); ++l) { if (pattern.size () &lt; maxpat) { pattern.push_back (make_pair &lt;T, unsigned int&gt; (l-&gt;first, l-&gt;second.size())); project (l-&gt;second); pattern.erase (pattern.end()); } } } public: PrefixSpan (unsigned int _minsup = 1, unsigned int _minpat = 1, unsigned int _maxpat = 0xffffffff, bool _all = false, bool _where = false, string _delimiter = "/", bool _verbose = false): minsup(_minsup), minpat (_minpat), maxpat (_maxpat), all(_all), where(_where), delimiter (_delimiter), verbose (_verbose) {}; ~PrefixSpan () {}; istream&amp; read (istream &amp;is){ string line; vector &lt;T&gt; tmp; T item; while (getline (is, line)) { tmp.clear (); istrstream istrs ((char *)line.c_str()); while (istrs &gt;&gt; item) tmp.push_back (item); transaction.push_back (tmp); } return is; } ostream&amp; run (ostream &amp;_os){ os = &amp;_os; if (verbose) *os &lt;&lt; transaction.size() &lt;&lt; endl; vector &lt;pair &lt;unsigned int, int&gt; &gt; root; for (unsigned int i = 0; i &lt; transaction.size(); i++) root.push_back (make_pair (i, -1)); project (root); return *os; } void clear (){ transaction.clear (); pattern.clear (); } }; int main (int argc, char **argv){ extern char *optarg; unsigned int minsup = 1; unsigned int minpat = 1; unsigned int maxpat = 0xffffffff; bool all = false; bool where = false; string delimiter = "/"; bool verbose = false; string type = "string"; int opt; while ((opt = getopt(argc, argv, "awvt:M:m:L:d:")) != -1){ switch(opt) { case 'a': all = true; break; case 'w': where = true; break; case 'v': verbose = true; break; case 'm': minsup = atoi (optarg); break; case 'M': minpat = atoi (optarg); break; case 'L': maxpat = atoi (optarg); break; case 't': type = string (optarg); break; case 'd': delimiter = string (optarg); break; default: cout &lt;&lt; "Usage: " &lt;&lt; argv[0] &lt;&lt; " [-m minsup] [-M minpat] [-L maxpat] [-a] [-w] [-v] [-t type] [-d delimiter] &lt; data .." &lt;&lt; endl; return -1; } } if (type == "int") { PrefixSpan&lt;unsigned int&gt; prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose); prefixspan.read (cin); prefixspan.run (cout); }else if (type == "short") { PrefixSpan&lt;unsigned short&gt; prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose); prefixspan.read (cin); prefixspan.run (cout); } else if (type == "char") { PrefixSpan&lt;unsigned char&gt; prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose); prefixspan.read (cin); prefixspan.run (cout); } else if (type == "string") { PrefixSpan&lt;string&gt; prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose); prefixspan.read (cin); prefixspan.run (cout); } else { cerr &lt;&lt; "Unknown Item Type: " &lt;&lt; type &lt;&lt; " : choose from [string|int|short|char]" &lt;&lt; endl; return -1; } return 0; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload