rpms/zinnia/F-12 Makefile.tomoe, NONE, 1.1 always-store-data-in-little-endian-format.patch, NONE, 1.1 tomoe2s.pl, NONE, 1.1 zinnia-0.06-fixes-ppc-float.patch, NONE, 1.1 .cvsignore, 1.2, 1.3 sources, 1.2, 1.3 zinnia.spec, 1.1, 1.2
Peng Wu
pwu at fedoraproject.org
Fri Jul 16 09:16:14 UTC 2010
Author: pwu
Update of /cvs/pkgs/rpms/zinnia/F-12
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv17078
Modified Files:
.cvsignore sources zinnia.spec
Added Files:
Makefile.tomoe always-store-data-in-little-endian-format.patch
tomoe2s.pl zinnia-0.06-fixes-ppc-float.patch
Log Message:
* Fri Jul 16 2010 Peng Wu <pwu at redhat.com> - 0.06-6
- Import from devel.
--- NEW FILE Makefile.tomoe ---
TOMOE_MODEL_PATH = /usr/share/tomoe/recognizer/
build: handwriting-ja.model handwriting-zh_CN.model tomoe2s.pl
handwriting-ja.model: $(TOMOE_MODEL_PATH)/handwriting-ja.xml
perl tomoe2s.pl $(TOMOE_MODEL_PATH)/handwriting-ja.xml > handwriting-ja.s
LD_LIBRARY_PATH=.libs/ ./zinnia_learn handwriting-ja.s handwriting-ja.model
LD_LIBRARY_PATH=.libs/ ./zinnia_convert handwriting-ja.model.txt handwriting-ja.model
handwriting-zh_CN.model: $(TOMOE_MODEL_PATH)/handwriting-zh_CN.xml
perl tomoe2s.pl $(TOMOE_MODEL_PATH)/handwriting-zh_CN.xml > handwriting-zh_CN.s
LD_LIBRARY_PATH=.libs/ ./zinnia_learn handwriting-zh_CN.s handwriting-zh_CN.model
LD_LIBRARY_PATH=.libs/ ./zinnia_convert handwriting-zh_CN.model.txt handwriting-zh_CN.model
install: build
install -d $(DESTDIR)/usr/share/zinnia//model/tomoe
install -m 0644 -p handwriting-ja.model handwriting-zh_CN.model $(DESTDIR)/usr/share/zinnia//model/tomoe
always-store-data-in-little-endian-format.patch:
configure.in | 5 +++++
recognizer.cpp | 24 ++++++++++++++++++++++--
trainer.cpp | 49 +++++++++++++++++++++++++++++++++++++------------
3 files changed, 64 insertions(+), 14 deletions(-)
--- NEW FILE always-store-data-in-little-endian-format.patch ---
>From 09f01b0afcb4408af2e1af0294425eac420cd7a5 Mon Sep 17 00:00:00 2001
From: Peng Huang <shawn.p.huang at gmail.com>
Date: Fri, 23 Apr 2010 16:09:07 +0800
Subject: [PATCH] Always store data in little endian format
---
configure.in | 5 +++++
recognizer.cpp | 24 ++++++++++++++++++++++--
trainer.cpp | 48 +++++++++++++++++++++++++++++++++++++-----------
3 files changed, 64 insertions(+), 13 deletions(-)
diff --git a/configure.in b/configure.in
index 2731d36..f25c83a 100644
--- a/configure.in
+++ b/configure.in
@@ -14,6 +14,11 @@ AC_PROG_LIBTOOL
dnl Checks for libraries.
+dnl Checks endian
+AC_C_BIGENDIAN([], [
+ AC_DEFINE(WORDS_LITENDIAN, 1, [Define if target is little endian])
+])
+
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(string.h stdlib.h unistd.h fcntl.h \
diff --git a/recognizer.cpp b/recognizer.cpp
index b4d292a..b231607 100644
--- a/recognizer.cpp
+++ b/recognizer.cpp
@@ -5,6 +5,9 @@
//
// Copyright(C) 2008 Taku Kudo <taku at chasen.org>
//
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include <iostream>
#include <vector>
#include <cmath>
@@ -23,11 +26,28 @@ static inline char *read_ptr(char **ptr, size_t size) {
return r;
}
-template <class T>
-static inline void read_static(char **ptr, T *value) {
+template <typename T>
+inline void read_static(char **ptr, T *value) {
char *r = read_ptr(ptr, sizeof(T));
memcpy(value, r, sizeof(T));
}
+
+#ifndef WORDS_LITENDIAN
+template <>
+inline void read_static<unsigned int>(char **ptr, unsigned int *value) {
+ unsigned char *buf = reinterpret_cast<unsigned char *>(*ptr);
+ *value = (buf[0]) | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
+ *ptr += 4;
+}
+
+template <>
+inline void read_static<float>(char **ptr, float *value) {
+ unsigned int x;
+ read_static<unsigned int>(ptr, &x);
+ memcpy(value, &x, sizeof(x));
+}
+#endif
+
}
namespace zinnia {
diff --git a/trainer.cpp b/trainer.cpp
index 287a882..e150760 100644
--- a/trainer.cpp
+++ b/trainer.cpp
@@ -243,6 +243,31 @@ bool Trainer::makeHeader(const char *text_filename,
return true;
}
+template<typename T>
+inline void write_static(std::ofstream & bofs, const T value)
+{
+ bofs.write(reinterpret_cast<const char *>(&value), sizeof(T));
+}
+
+#ifndef WORDS_LITENDIAN
+template<>
+inline void write_static<unsigned int>(std::ofstream & bofs, const unsigned int value)
+{
+ bofs.put ((value) & 0xff);
+ bofs.put ((value >> 8) & 0xff);
+ bofs.put ((value >> 16) & 0xff);
+ bofs.put ((value >> 24) & 0xff);
+}
+
+template<>
+inline void write_static<float>(std::ofstream & bofs, const float value)
+{
+ unsigned int x;
+ memcpy(&x, &value, sizeof(x));
+ write_static<unsigned int>(bofs, x);
+}
+#endif
+
bool Trainer::convert(const char *text_filename,
const char *binary_filename,
double compression_threshold) {
@@ -261,9 +286,9 @@ bool Trainer::convert(const char *text_filename,
unsigned int magic = 0;
const unsigned int version = DIC_VERSION;
unsigned int msize = 0;
- bofs.write(reinterpret_cast<const char *>(&magic), sizeof(magic));
- bofs.write(reinterpret_cast<const char *>(&version), sizeof(version));
- bofs.write(reinterpret_cast<const char *>(&msize), sizeof(msize));
+ write_static<unsigned int> (bofs, magic);
+ write_static<unsigned int> (bofs, version);
+ write_static<unsigned int> (bofs, msize);
std::string line;
const size_t array_size = 8192 * 16;
@@ -277,19 +302,19 @@ bool Trainer::convert(const char *text_filename,
char character[16];
std::strncpy(character, col[0], sizeof(character));
bofs.write(character, sizeof(character));
- bofs.write(reinterpret_cast<const char *>(&bias), sizeof(bias));
+ write_static<float> (bofs, bias);
for (size_t i = 2; i < size; i += 2) {
const int index = std::atoi(col[i]);
const float value = std::atof(col[i + 1]);
if (fabs(value) > compression_threshold) {
- bofs.write(reinterpret_cast<const char *>(&index), sizeof(index));
- bofs.write(reinterpret_cast<const char *>(&value), sizeof(value));
+ write_static<int> (bofs, index);
+ write_static<float> (bofs, value);
}
}
const int index = -1;
const float value = 0.0;
- bofs.write(reinterpret_cast<const char *>(&index), sizeof(index));
- bofs.write(reinterpret_cast<const char *>(&value), sizeof(value));
+ write_static<int> (bofs, index);
+ write_static<float> (bofs, value);
++msize;
}
@@ -297,9 +322,10 @@ bool Trainer::convert(const char *text_filename,
bofs.seekp(0);
magic ^= DIC_MAGIC_ID;
bofs.seekp(0);
- bofs.write(reinterpret_cast<const char *>(&magic), sizeof(magic));
- bofs.write(reinterpret_cast<const char *>(&version), sizeof(version));
- bofs.write(reinterpret_cast<const char *>(&msize), sizeof(msize));
+
+ write_static<unsigned int> (bofs, magic);
+ write_static<unsigned int> (bofs, version);
+ write_static<unsigned int> (bofs, msize);
return true;
}
--
1.7.0.1
--- NEW FILE tomoe2s.pl ---
#!/usr/bin/perl
use utf8;
my $value;
my $stroke;
my $strokes;
while (<>) {
if (/<character>/) {
while (<>) {
if (/<utf8>([^<]+)<\/utf8>/) {
$value = $1;
$value =~ s/^&#x//;
$value = pack("U", hex($value));
utf8::encode($value);
$stroke = "";
$strokes = "";
} elsif (/<point x=\"(\d+)\" y=\"(\d+)\"/) {
my $x = $1;
my $y = $2;
# print "$x $y\n";
$stroke .= "($x $y)";
} elsif (/<\/stroke>/) {
$strokes .= "($stroke)";
$stroke = "";
} elsif (/<\/character>/) {
if ($value !~ /[\(\)]/) {
print "(character (value $value)(width 1000)(height 1000)(strokes $strokes))\n";
}
$value = "";
last;
}
}
}
}
zinnia-0.06-fixes-ppc-float.patch:
feature.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- NEW FILE zinnia-0.06-fixes-ppc-float.patch ---
Index: zinnia-0.06/feature.cpp
===================================================================
--- zinnia-0.06.orig/feature.cpp
+++ zinnia-0.06/feature.cpp
@@ -42,7 +42,7 @@ float minimum_distance(const Node *first
const float a = last->x - first->x;
const float b = last->y - first->y;
- const float c = last->y * first->x - last->x * first->y;
+ const float c = (double)last->y * first->x - (double)last->x * first->y;
float max = -1.0;
for (const Node *n = first; n != last; ++n) {
Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/zinnia/F-12/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- .cvsignore 11 Mar 2010 01:43:16 -0000 1.2
+++ .cvsignore 16 Jul 2010 09:16:14 -0000 1.3
@@ -1 +1 @@
-zinnia-0.05.tar.gz
+zinnia-0.06.tar.gz
Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/zinnia/F-12/sources,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- sources 11 Mar 2010 01:43:17 -0000 1.2
+++ sources 16 Jul 2010 09:16:14 -0000 1.3
@@ -1 +1 @@
-78462a619ad63772683666e3eefc092e zinnia-0.05.tar.gz
+5ed6213e2b879465783087a0cf6d5fa0 zinnia-0.06.tar.gz
Index: zinnia.spec
===================================================================
RCS file: /cvs/pkgs/rpms/zinnia/F-12/zinnia.spec,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- zinnia.spec 11 Mar 2010 01:43:17 -0000 1.1
+++ zinnia.spec 16 Jul 2010 09:16:14 -0000 1.2
@@ -4,18 +4,23 @@
%endif
Name: zinnia
-Version: 0.05
-Release: 4%{?dist}
+Version: 0.06
+Release: 6%{?dist}
Summary: Online handwriting recognition system with machine learning
Group: System Environment/Libraries
License: BSD
URL: http://zinnia.sourceforge.net/
Source0: http://downloads.sourceforge.net/zinnia/%{name}-%{version}.tar.gz
+Source1: http://zinnia.svn.sourceforge.net/viewvc/zinnia/zinnia/tomoe2s.pl
+Source2: Makefile.tomoe
Patch0: zinnia-0.05-bindings.patch
+Patch1: zinnia-0.06-fixes-ppc-float.patch
+Patch2: always-store-data-in-little-endian-format.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: db4-devel, python2-devel
BuildRequires: perl(ExtUtils::MakeMaker)
+BuildRequires: tomoe
%description
Zinnia provides a simple, customizable, and portable dynamic OCR
@@ -75,11 +80,24 @@ Requires: %{name} = %{version}-%{release
%description python
This package contains python bindings for %{name}.
+%package tomoe
+Summary: Tomoe model file for %{name}
+Group: System Environment/Libraries
+Requires: %{name} = %{version}-%{release}
+BuildArch: noarch
+
+%description tomoe
+This package contains tomoe model files for %{name}.
+
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1 -b .bindings
+%patch1 -p1 -b .ppc
+%patch2 -p1 -R -b .little-endian
find . -type f -name ChangeLog -size 0c -exec rm -f {} ';'
find . -type f -name "*.pyc" -exec rm -f {} ';'
+cp %{SOURCE1} .
+cp %{SOURCE2} .
pushd doc
iconv -f latin1 -t utf8 zinnia.css > zinnia.css.bak
mv -f zinnia.css.bak zinnia.css
@@ -89,7 +107,8 @@ popd
%configure --disable-static
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
-make %{?_smp_mflags}
+make CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" %{?_smp_mflags}
+make -f Makefile.tomoe build
pushd perl
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS"
@@ -103,6 +122,7 @@ popd
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
+make -f Makefile.tomoe install DESTDIR=$RPM_BUILD_ROOT
#install -d -m 0755 -p $RPM_BUILD_ROOT%{_docdir}/%{name}
#cp -pfr doc $RPM_BUILD_ROOT%{_docdir}/%{name}
@@ -166,8 +186,33 @@ rm -rf $RPM_BUILD_ROOT
%{python_sitearch}/_%{name}.so
%{python_sitearch}/%{name}*
+%files tomoe
+%defattr(-,root,root,-)
+%dir %{_datadir}/zinnia/model/tomoe/
+%{_datadir}/zinnia/model/tomoe/handwriting-ja.model
+%{_datadir}/zinnia/model/tomoe/handwriting-zh_CN.model
%changelog
+* Fri Jul 16 2010 Peng Wu <pwu at redhat.com> - 0.06-6
+- revert patch always-store-data-in-little-endian-format.patch for ppc build.
+
+* Tue Jun 08 2010 Liang Suilong <liangsuilong at gmail.com> - 0.06-5
+- Force to use default compiling macro
+
+* Fri Jun 04 2010 Peng Wu <pwu at redhat.com> - 0.06-4
+- Add a patch(zinnia-0.06-fixes-ppc-float.patch),
+ to fixes ppc/ppc64 zinnia tomoe model generating error.
+
+* Wed Jun 02 2010 Marcela Maslanova <mmaslano at redhat.com> - 0.06-3
+- Mass rebuild with perl-5.12.0
+
+* Thu May 20 2010 Peng Wu <pwu at redhat.com> - 0.06-2
+- Auto generate zinnia tomoe model files,
+ and includes all model files in zinnia-tomoe noarch sub-package.
+
+* Thu May 20 2010 Peng Wu <pwu at redhat.com> - 0.06-1
+- Update to version 0.06.
+
* Wed Mar 10 2010 Liang Suilong <liangsuilong at gmail.com> - 0.05-4
- Fix the bugs of SPEC file
More information about the scm-commits
mailing list