Skip to content

Instantly share code, notes, and snippets.

@mamorlis
Created December 3, 2016 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamorlis/782ff6f81b8d9f7df5bfcd15be76181d to your computer and use it in GitHub Desktop.
Save mamorlis/782ff6f81b8d9f7df5bfcd15be76181d to your computer and use it in GitHub Desktop.
lwlm-0.1 does not compile on Mac 10.12 with clang.
diff -urN lwlm-0.1.orig/hpylm.cpp lwlm-0.1/hpylm.cpp
--- lwlm-0.1.orig/hpylm.cpp 2010-03-18 01:41:57.000000000 +0900
+++ lwlm-0.1/hpylm.cpp 2016-12-03 10:38:06.000000000 +0900
@@ -141,7 +141,7 @@
double
HPYLM::hpy_probability (int *word, int *history)
{
- return hpy_probability ((witerator)word, (witerator)history);
+ return hpy_probability ((witerator&)word, (witerator&)history);
}
double
diff -urN lwlm-0.1.orig/io.h lwlm-0.1/io.h
--- lwlm-0.1.orig/io.h 2010-03-09 19:37:37.000000000 +0900
+++ lwlm-0.1/io.h 2016-12-03 10:55:44.000000000 +0900
@@ -5,14 +5,13 @@
*/
#ifndef _IO_H_
#define _IO_H_
-#include <ext/hash_map>
+#include <unordered_map>
#include "hpylm.h"
#define BYTE(x,n) *(((char *)&(x))+n)
using namespace std;
-using namespace __gnu_cxx;
-namespace __gnu_cxx {
+namespace std {
template <> struct hash<void *>
{
size_t operator() (const void *p) const
@@ -34,9 +33,9 @@
};
-typedef hash_map <int, int> lex_map;
-typedef hash_map <int, ngram *> node_map_rev;
-typedef hash_map <ngram *, int, hash<void *>, ptreq> node_map;
+typedef unordered_map <int, int> lex_map;
+typedef unordered_map <int, ngram *> node_map_rev;
+typedef unordered_map <ngram *, int, hash<void *>, ptreq> node_map;
bool lwlm_load_param (char *model, int *order, double *alpha);
diff -urN lwlm-0.1.orig/learn.cpp lwlm-0.1/learn.cpp
--- lwlm-0.1.orig/learn.cpp 2010-03-19 19:16:54.000000000 +0900
+++ lwlm-0.1/learn.cpp 2016-12-03 10:37:43.000000000 +0900
@@ -119,7 +119,7 @@
int
LWLM::slice_gibbs_draw (int *hidden, int *observed, int width)
{
- return slice_gibbs_draw ((witerator)hidden, (witerator)observed, width);
+ return slice_gibbs_draw ((witerator&)hidden, (witerator&)observed, width);
}
int
@@ -257,7 +257,7 @@
int
LWLM::gibbs_draw (int *hidden, int *observed, int width)
{
- return gibbs_draw ((witerator)hidden, (witerator)observed, width);
+ return gibbs_draw ((witerator&)hidden, (witerator&)observed, width);
}
int
diff -urN lwlm-0.1.orig/load.cpp lwlm-0.1/load.cpp
--- lwlm-0.1.orig/load.cpp 2010-03-23 12:32:29.000000000 +0900
+++ lwlm-0.1/load.cpp 2016-12-03 10:46:06.000000000 +0900
@@ -7,7 +7,7 @@
#include <fstream>
#include <string>
#include <utility>
-#include <ext/hash_map>
+#include <unordered_map>
#include <cstdio>
#include <cstring>
#include "lwlm.h"
diff -urN lwlm-0.1.orig/log.cpp lwlm-0.1/log.cpp
--- lwlm-0.1.orig/log.cpp 2010-03-12 02:22:38.000000000 +0900
+++ lwlm-0.1/log.cpp 2016-12-03 10:57:36.000000000 +0900
@@ -27,7 +27,7 @@
gethostname(hostname, BUFSIZ);
fprintf(lp, "init :");
- while (s = *argv++) fprintf(lp, " %s", s);
+ while ((s = *argv++)) fprintf(lp, " %s", s);
fprintf(lp, "\n");
fprintf(lp, "host : %s\n", hostname);
fprintf(lp, "start : %s", ctime(&timer));
diff -urN lwlm-0.1.orig/lwlm.cpp lwlm-0.1/lwlm.cpp
--- lwlm-0.1.orig/lwlm.cpp 2010-03-19 19:16:54.000000000 +0900
+++ lwlm-0.1/lwlm.cpp 2016-12-03 11:03:44.000000000 +0900
@@ -14,10 +14,9 @@
#include <cstring>
#include <cstdio>
#include <cmath>
-#include <ext/hash_map>
+#include <unordered_map>
using namespace std;
-using namespace __gnu_cxx;
static const char whitespace[] = " \t";
@@ -54,11 +53,11 @@
id_hash::iterator it;
if (id == EOS)
- return "<EOS>";
+ return (char *) "<EOS>";
if ((it = rdict.find(id)) == rdict.end())
{
- return "<null>";
+ return (char *) "<null>";
} else {
return (char *) it->second.c_str();
}
@@ -108,6 +107,7 @@
observed.push_back (s);
}
eprintf("done.\n");
+ return true;
}
bool
@@ -141,6 +141,7 @@
{
lm->add_customer (ht);
}
+ return true;
}
double
diff -urN lwlm-0.1.orig/lwlm.h lwlm-0.1/lwlm.h
--- lwlm-0.1.orig/lwlm.h 2010-03-18 17:17:29.000000000 +0900
+++ lwlm-0.1/lwlm.h 2016-12-03 10:54:00.000000000 +0900
@@ -10,18 +10,17 @@
#include "table.h"
#include <string>
#include <vector>
-#include <ext/hash_map>
+#include <unordered_map>
#define cons make_pair
#define push_front(v,x) (v).insert((v).begin(),x)
using namespace std;
-using namespace __gnu_cxx;
-typedef hash_map <int, string> id_hash;
-typedef hash_map <string, int> lex_hash;
+typedef unordered_map <int, string> id_hash;
+typedef unordered_map <string, int> lex_hash;
typedef vector<vector<int> *>::iterator siterator;
-namespace __gnu_cxx {
+namespace std {
template <> struct hash<string>
{
size_t operator() (const string &s) const
diff -urN lwlm-0.1.orig/save.cpp lwlm-0.1/save.cpp
--- lwlm-0.1.orig/save.cpp 2010-03-18 16:28:41.000000000 +0900
+++ lwlm-0.1/save.cpp 2016-12-03 10:54:37.000000000 +0900
@@ -6,7 +6,7 @@
*/
#include <cstdio>
#include <cstdlib>
-#include <ext/hash_map>
+#include <unordered_map>
#include <utility>
#include "hpylm.h"
#include "lwlm.h"
@@ -15,7 +15,6 @@
#include "io.h"
using namespace std;
-using namespace __gnu_cxx;
typedef struct {
int id;
diff -urN lwlm-0.1.orig/table.cpp lwlm-0.1/table.cpp
--- lwlm-0.1.orig/table.cpp 2010-03-18 01:41:57.000000000 +0900
+++ lwlm-0.1/table.cpp 2016-12-03 10:54:50.000000000 +0900
@@ -6,10 +6,9 @@
*/
#include "lwlm.h"
#include "util.h"
-#include <ext/hash_map>
+#include <unordered_map>
using namespace std;
-using namespace __gnu_cxx;
TransTable::TransTable (double alpha_)
{
diff -urN lwlm-0.1.orig/table.h lwlm-0.1/table.h
--- lwlm-0.1.orig/table.h 2010-03-15 16:28:17.000000000 +0900
+++ lwlm-0.1/table.h 2016-12-03 10:48:42.000000000 +0900
@@ -7,12 +7,11 @@
#ifndef _TABLE_H_
#define _TABLE_H_
#include <vector>
-#include <ext/hash_map>
+#include <unordered_map>
using namespace std;
-using namespace __gnu_cxx;
-typedef hash_map <long, int> val_hash;
+typedef unordered_map <long, int> val_hash;
struct LWLM;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment