github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

brendano / awkspeed

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 4
    • 3
  • Source
  • Commits
  • Network (3)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Speed testing for a data munging task — Read more

  cancel

http://anyall.org/blog/?p=652

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

fix flushing in Java version 
DRMacIver (author)
Thu Sep 10 06:05:04 -0700 2009
commit  474264d36c92f2ab6e7f9195a9afe8119ab2ccf9
tree    7537526b60e86396fdfa78fa66a3c98e2757efea
parent  4f672dfbff8e20a7de0587a6e15627e64c7c1560
awkspeed / 2num.cc 2num.cc
100644 50 lines (49 sloc) 1.39 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
using namespace std;
#include <ext/hash_map>
using namespace __gnu_cxx;
// You have to define a hashing function to use string keys in a hash_map? Are you kidding me?! http://www.gamedev.net/community/forums/topic.asp?topic_id=119766
namespace __gnu_cxx {
  template<>
  struct hash< std::string > {
    size_t operator( )( std::string const & s ) const {
      return __stl_hash_string( s.c_str( ) );
    }
  };
}
int main(int argc, const char **argv)
{
  hash_map<string, int> imap;
  hash_map<string, int> jmap;
  hash_map<string, int> I;
  int J=0;
  ofstream vocab("vocab");
  for (int file_i=1; file_i<argc; file_i++) {
    string filename = argv[file_i];
    cout <<filename<<endl;
    ifstream in(argv[file_i]);
    string outname = argv[file_i];
    outname += "n";
    ofstream out(outname.c_str(), ofstream::out);
    string line;
    while (getline(in, line)) {
      string item, feat, val;
      istringstream linestr(line);
      linestr >> item >> feat >> val;
      string key = filename + " " + item;
      imap.find(key);
      if (imap.find(key) == imap.end()) {
        imap[key] = ++I[filename];
      }
      if (jmap.find(feat) == jmap.end()) {
        jmap[feat] = ++J;
        vocab << feat << endl;
      }
      out <<imap[key]<<" "<<jmap[feat]<<" "<<val<<endl;
    }
  }
  return 0;
}
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server