Changeset ac7d970 for app/src


Ignore:
Timestamp:
04/08/08 13:53:51 (16 years ago)
Author:
pawelk <pawelk@…>
Branches:
master, help
Children:
0214596
Parents:
317d53b
git-author:
pawelk <pawelk@…> (04/08/08 13:53:51)
git-committer:
pawelk <pawelk@…> (04/08/08 13:53:51)
Message:

Uaktualnilismy kora.

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@23 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

Location:
app/src
Files:
9 added
4 edited

Legend:

Unmodified
Added
Removed
  • app/src/common/common.h

    r25ae32e rac7d970  
    44#include <stdio.h> 
    55#include <ctype.h> 
     6#include <string.h> 
     7#include <stdlib.h> 
    68 
    79#include "../lib/const.h" 
  • app/src/lib/word.cc

    r25ae32e rac7d970  
    2323 
    2424//--------------------------------------------------------------------------- 
    25 int Word::cmp_w(Word a, Word b) { 
     25bool Word::cmp_w(Word a, Word b) { 
    2626  return (a.w_suf() > b.w_suf()); 
    2727} 
     
    124124    tab.resize(tab.size()*2); 
    125125   
    126   tab[cnt].form(fo); 
    127   tab[cnt].w_suf(0.0); 
     126 
     127  Word o; 
     128  o.form(fo); 
     129  o.w_suf(0.0); 
     130  tab.push_back(o); 
     131//  tab[cnt].form(fo); 
     132//  tab[cnt].w_suf(0.0); 
     133 
    128134 
    129135  //  if(cnt<MAX-1) { 
     
    132138    tab[cnt]->w_suf(0.0); 
    133139    tab[cnt]->w_pref(0.0);*/ 
     140    return cnt++; 
     141    //  } 
     142    //return -1; 
     143} 
     144 
     145//--------------------------------------------------------------------------- 
     146 
     147 //TYMCZASOWO TAK(DLA CORA) 
     148int Words::add(const char* fo, float weight) 
     149{ 
     150  int i = find(fo); 
     151  if(i!=-1) { 
     152    return i; 
     153  } 
     154   
     155  if (cnt>=tab.capacity()-1) 
     156    tab.resize(tab.size()*2); 
     157   
     158  Word o; 
     159  o.form(fo); 
     160  o.w_suf(weight); 
     161  tab.push_back(o); 
     162//  tab[cnt].form(fo); 
     163//  tab[cnt].w_suf(weight); 
     164   
    134165    return cnt++; 
    135166    //  } 
  • app/src/lib/word.h

    r25ae32e rac7d970  
    1212 
    1313using namespace std; 
     14 
     15 
    1416 
    1517class Word 
     
    3739  //  float _w_pref; 
    3840public: 
    39   static int cmp_w(Word a, Word b); 
     41  static bool cmp_w(Word a, Word b); 
    4042 
    4143  Word() : _len_suf(-1) { *f='\0'; returned=0; }; 
     
    7678 
    7779}; 
     80 
    7881 
    7982inline Word::Word(const Word& word) 
     
    119122  void clear() { cnt=0; tab.clear(); } 
    120123  int add(const char* fo); 
     124  int add(const char* fo, float weight); 
    121125  int add(const char* fo, const char* des); 
    122126 
  • app/src/tok/tok

    r20b4e44 rac7d970  
    1111use File::HomeDir; 
    1212 
     13my $max_form_length = 50; 
     14 
    1315my $interactive=0; 
    1416my $help; 
     
    2123my $file; 
    2224foreach $file ($systemconfigfile, $userconfigfile){ 
    23         if(open(CONFIG, $configfile1)){ 
     25        if(open(CONFIG, $file)){ 
    2426                while (<CONFIG>) { 
    2527                        chomp; 
     
    7577#       | [^[:print:]]   (?{seg("B",$&)}) 
    7678 
     79sub min { 
     80  my ($val1, $val2) = @_; 
     81  if($val1 < $val2) { 
     82        return $val1; 
     83  } 
     84  else { 
     85        return $val2; 
     86  } 
     87} 
     88 
    7789 
    7890sub seg 
    7991{ 
    8092    my ($tag,$match) = @_; 
    81     my $len=length $match; 
    82     printf "%04d %02d %s ", $offset, $len, $tag; 
     93    my $length = length $match; 
     94    my $idx = 0; 
     95    while($idx < $length) { 
     96        my $l = min $max_form_length, $length - $idx; 
     97        my $m = substr $match, $idx, $l; 
     98     
     99        printf "%04d %02d %s ", $offset + $idx, $l, $tag; 
    83100    if($tag eq 'S') 
    84101    { 
    85         for(my $i=0; $i<$len; ++$i) 
     102        for(my $i=0; $i<$l; ++$i) 
    86103        { 
    87             my $c = substr $match, $i, 1; 
     104            my $c = substr $m, $i, 1; 
    88105            print '_' if $c eq ' '; 
    89106            print '\n' if $c eq "\n"; 
     
    95112    elsif($tag eq 'B') 
    96113    { 
    97         printf "\\x%02X", ord($match); 
     114        printf "\\x%02X", ord($m); 
    98115    } 
    99116    else 
    100117    { 
    101         print $match; 
     118        print $m; 
    102119    } 
    103120    print "\n"; 
    104     $offset += $len; 
    105 } 
     121    $idx += $l; 
     122    } # while($idx < $length) 
     123    $offset += $length; 
     124} #sub seg 
     125 
Note: See TracChangeset for help on using the changeset viewer.