コード例 #1
0
ファイル: wordxrefstem.c プロジェクト: ptdecker/cbasics
static void step1ab() {

    char ch;

    if (b[k] == 's') {
        if (ends("\04" "sses"))
            k -= 2;
        else if (ends("\03" "ies"))
            setto("\01" "i");
        else if (b[k-1] != 's')
            k--;
    }

    if (ends("\03" "eed")) {
        if (m() > 0)
            k--;
    } else if ((ends("\02" "ed") || ends("\03" "ing") || ends("\02" "in")) && vowelinstem()) {
        k = j;
        if (ends("\02" "at"))
            setto("\03" "ate");
        else if (ends("\02" "bl"))
            setto("\03" "ble");
        else if (ends("\02" "iz"))
            setto("\03" "ize");
        else if (doublec(k)) {
            k--;
            ch = b[k];
            if (ch == 'l' || ch == 's' || ch == 'z')
                k++;
        } else if (m() == 1 && cvc(k))
            setto("\01" "e");
    }
}
コード例 #2
0
static void step1ab(struct stemmer * z) {
	char * b = z->b;
	if (b[z->k] == 's') {
		if (ends(z, "\04" "sses"))
			z->k -= 2;
		else if (ends(z, "\03" "ies"))
			setto(z, "\01" "i");
		else if (b[z->k - 1] != 's')
			z->k--;
	}
	if (ends(z, "\03" "eed")) {
		if (m(z) > 0)
			z->k--;
	} else if ((ends(z, "\02" "ed") || ends(z, "\03" "ing"))
			&& vowelinstem(z)) {
		z->k = z->j;
		if (ends(z, "\02" "at"))
			setto(z, "\03" "ate");
		else if (ends(z, "\02" "bl"))
			setto(z, "\03" "ble");
		else if (ends(z, "\02" "iz"))
			setto(z, "\03" "ize");
		else if (doublec(z, z->k)) {
			z->k--;
			{
				int ch = b[z->k];
				if (ch == 'l' || ch == 's' || ch == 'z')
					z->k++;
			}
		} else if (m(z) == 1 && cvc(z, z->k))
			setto(z, "\01" "e");
	}
}
コード例 #3
0
void step5()
{  j = k;
   if (b[k] == 'e')
   {  int a = m();
      if (a > 1 || a == 1 && !cvc(k-1)) k--;
   }
   if (b[k] == 'l' && doublec(k) && m() > 1) k--;
}
コード例 #4
0
 void Porter_Stemmer::step5() {
   j = k;
   if (b[k] == 'e') {
     int a = m();
     if (a > 1 || (a == 1 && !cvc(k-1))) k--;
   }
   if (b[k] == 'l' && doublec(k) && m() > 1) k--;
 }
コード例 #5
0
ファイル: Stemmer.cpp プロジェクト: ae77em/datos-2-2012-isl
/* paso1ab() quita los plurales y -ed e -ing.

       caresses  ->  caress
       ponies    ->  poni
       ties      ->  ti
       caress    ->  caress
       cats      ->  cat

       feed      ->  feed
       agreed    ->  agree
       disabled  ->  disable

       matting   ->  mat
       mating    ->  mate
       meeting   ->  meet
       milling   ->  mill
       messing   ->  mess

       meetings  ->  meet

*/
void Stemmer::paso1ab(){

	if (palabraEnProcesamiento.at(tamanioPalabra) == 's'){
		if ( terminaCon( 4, std::string("sses")))
			tamanioPalabra -= 2;
		else
		if ( terminaCon( 3, std::string("ies")))
			cambiarPor(1, std::string("i"));
		else
		if (palabraEnProcesamiento.at(tamanioPalabra-1) != 's')
			tamanioPalabra--;
	}

	if ( terminaCon( 3, std::string("eed"))) {
		if (m() > 0)
			tamanioPalabra--;
	}
	else
	if (vocalEnStem()){
		bool salir = true;
		/* elimino los sufijos que sobran */
		if( terminaCon( 2, std::string("ed"))){
			cambiarPor(1, std::string("\0"));
			salir=false;
		}
		else if( terminaCon( 3, std::string("ing"))){
			cambiarPor(1, std::string("\0"));
			salir=false;
		}

		if ( not salir ){
			tamanioPalabra = posUltimaLetra;
			if ( terminaCon( 2, std::string("at")))
				cambiarPor(3, std::string("ate"));
			else
			if ( terminaCon( 2, std::string("bl")))
				cambiarPor(3, std::string("ble"));
			else
			if ( terminaCon( 2, std::string("iz")))
				cambiarPor(3, std::string("ize"));
			else
			if (dobleConsonante(tamanioPalabra))
			{
				tamanioPalabra--;
				{
					int ch = palabraEnProcesamiento.at(tamanioPalabra);
					if (ch == 'l' || ch == 's' || ch == 'z')
						tamanioPalabra++;
				}
			}
			else
			if (m() == 1 && cvc(tamanioPalabra))
				cambiarPor(1, std::string("e"));
		}
	}
}
コード例 #6
0
static void step5(struct stemmer * z)
{
   char * b = z->b;
   z->j = z->k;
   if (b[z->k] == 'e')
   {  int a = m(z);
      if (a > 1 || (a == 1 && !cvc(z, z->k - 1))) z->k--;
   }
   if (b[z->k] == 'l' && doublec(z, z->k) && m(z) > 1) z->k--;
}
コード例 #7
0
ファイル: wordxrefstem.c プロジェクト: ptdecker/cbasics
static void step5() {

    size_t a;

    j = k;

    if (b[k] == 'e') {
      a = m();
      if (a > 1 || (a == 1 && !cvc(k - 1)))
          k--;
    }

    if (b[k] == 'l' && doublec(k) && m() > 1)
      k--;
}
コード例 #8
0
ファイル: Stemmer.cpp プロジェクト: ae77em/datos-2-2012-isl
/* paso5()
 * remueve las -e finales si m() > 1,
 * y cambia -ll por -l si m() > 1.
 * Ej:
  	(m>1) E					->	probate	->	probat
    							rate	->	rate
	(m=1 and not *o) E		->	cease	->	ceas

	(m > 1 and *d and *L)	->	single letter 	controll 	-> control
    		 	 	 	 	 					roll		->	roll
 *
 * */
void Stemmer::paso5(){

	posUltimaLetra = tamanioPalabra;
	int a = m();

	if (palabraEnProcesamiento.at(tamanioPalabra) == 'e'){
		/* remuevo la e final */
		if (a > 1 || ( a == 1 && !cvc(tamanioPalabra-1) ))
			tamanioPalabra--;

	}
	if (palabraEnProcesamiento.at(tamanioPalabra) == 'l' && dobleConsonante(tamanioPalabra) && a > 1)
		tamanioPalabra--;

}
コード例 #9
0
ファイル: porter-stemmer.c プロジェクト: hroptatyr/glod
/* step5() removes a final -e if m() > 1, and changes -ll to -l if
   m() > 1. */
static void
step5(void)
{
	j = k;

	if (b[k] == 'e') {
		size_t a = m();

		if (a > 1U || a == 1U && !cvc(k - 1)) {
			k--;
		}
	}
	if (b[k] == 'l' && doublec(k) && m() > 1U) {
		k--;
	}
	return;
}
コード例 #10
0
ファイル: stmr.c プロジェクト: wooorm/stmr.c
/* `step5()` removes a final `-e` if `getMeasure()` is
 * greater than `1`, and changes `-ll` to `-l` if
 * `getMeasure()` is greater than `1`. */
static void
step5() {
  int a;

  j = k;

  if (b[k] == 'e') {
    a = getMeasure();

    if (a > 1 || (a == 1 && !cvc(k - 1))) {
      k--;
    }
  }

  if (b[k] == 'l' && isDoubleConsonant(k) && getMeasure() > 1) {
    k--;
  }
}
コード例 #11
0
ファイル: stmr.c プロジェクト: wooorm/stmr.c
/* `step1ab()` gets rid of plurals, `-ed`, `-ing`.
 *
 * Such as:
 *
 *   caresses  ->  caress
 *   ponies    ->  poni
 *   ties      ->  ti
 *   caress    ->  caress
 *   cats      ->  cat
 *
 *   feed      ->  feed
 *   agreed    ->  agree
 *   disabled  ->  disable
 *
 *   matting   ->  mat
 *   mating    ->  mate
 *   meeting   ->  meet
 *   milling   ->  mill
 *   messing   ->  mess
 *
 *   meetings  ->  meet
 */
static void
step1ab() {
  int character;

  if (b[k] == 's') {
    if (ends("\04" "sses")) {
      k -= 2;
    } else if (ends("\03" "ies")) {
      setTo("\01" "i");
    } else if (b[k - 1] != 's') {
      k--;
    }
  }

  if (ends("\03" "eed")) {
    if (getMeasure() > 0) {
      k--;
    }
  } else if ((ends("\02" "ed") || ends("\03" "ing")) && vowelInStem()) {
    k = j;

    if (ends("\02" "at")) {
      setTo("\03" "ate");
    } else if (ends("\02" "bl")) {
      setTo("\03" "ble");
    } else if (ends("\02" "iz")) {
      setTo("\03" "ize");
    } else if (isDoubleConsonant(k)) {
      k--;

      character = b[k];

      if (character == 'l' || character == 's' || character == 'z') {
        k++;
      }
    } else if (getMeasure() == 1 && cvc(k)) {
      setTo("\01" "e");
    }
  }
}
コード例 #12
0
ファイル: porter-stemmer.c プロジェクト: hroptatyr/glod
/* step1ab() gets rid of plurals and -ed or -ing. e.g.

       caresses  ->  caress
       ponies    ->  poni
       ties      ->  ti
       caress    ->  caress
       cats      ->  cat

       feed      ->  feed
       agreed    ->  agree
       disabled  ->  disable

       matting   ->  mat
       mating    ->  mate
       meeting   ->  meet
       milling   ->  mill
       messing   ->  mess

       meetings  ->  meet

*/
static void
step1ab(void)
{
	if (b[k] == 's') {
		if (ends("\04" "sses")) {
			k -= 2;
		} else if (ends("\03" "ies")) {
			setto("\01" "i"); 
		} else if (b[k-1] != 's') {
			k--;
		}
	}
	if (ends("\03" "eed")) {
		if (m() > 0U) {
			k--;
		}
	} else if ((ends("\02" "ed") || ends("\03" "ing")) && vowelinstem()) {
		k = j;
		if (ends("\02" "at")) {
			setto("\03" "ate");
		} else if (ends("\02" "bl")) {
			setto("\03" "ble");
		} else if (ends("\02" "iz")) {
			setto("\03" "ize");
		} else if (doublec(k)) {
			k--;
			{
				int ch = b[k];
				if (ch == 'l' || ch == 's' || ch == 'z') {
					k++;
				}
			}
		} else if (m() == 1U && cvc(k)) {
			setto("\01" "e");
		}
	}
	return;
}
コード例 #13
0
 void PorterStemmer::step1() {
   if (b[k] == _T('s')) {
     if (ends(_T("sses"))) k -= 2;
     else if (ends(_T("ies"))) setto(_T("i"));
     else if (b[k-1] != _T('s')) k--;
   }
   if (ends(_T("eed"))) {
     if (m() > 0)
       k--;
   }
   else if ((ends(_T("ed")) || ends(_T("ing"))) && vowelinstem()) {
     k = j;
     if (ends(_T("at"))) setto(_T("ate"));
     else if (ends(_T("bl"))) setto(_T("ble"));
     else if (ends(_T("iz"))) setto(_T("ize"));
     else if (doublec(k)) {
       int32_t ch = b[k--];
       if (ch == _T('l') || ch == _T('s') || ch == _T('z'))
         k++;
     }
     else if (m() == 1 && cvc(k))
       setto(_T("e"));
   }
 }
コード例 #14
0
int Circle::check_collision_with_bat( Bat& bat, PotentialMove **pm, double ftr)
{ 
   int current_ticks;
   int n;
   float future_x_at_bat_y;
   int vn;
   int result;
   double dx; /* Need to get this from the Bat Class - how far the bat moves horizontally. */
   double cmx, cmy;
   double circle_to_bat_angle = principal_value_2(atan2( bat.cy - cc_y, bat.cx - cc_x ));
   
   
   
   PotentialMove *m;
   
   vector <PotentialMove *> moves(0);
   
   int move_number = 0;
   
   
   
   switch( bat.direction ) 
   {
      case BAT_NOT_MOVING:
         dx = 0.0f;
		 break;
	  case BAT_MOVING_LEFT:
	     //logfile << "setting \n";
	     dx = - bat.movement_inc * ftr;
	     break;
	  case BAT_MOVING_RIGHT:
	     dx = bat.movement_inc * ftr;
	     break;
		 
   }   
     
   /* check for collision against edges of bat */
	  
	 
   for(vn = 0; vn < 4; ++vn)
   {
	  if( circle_and_line_collision( PONGPING_TRANSLATION, bat.bat_vertices[vn], bat.bat_vertices[vn + 1], bat.get_bat_midpoint_x(), 
	                                 bat.get_bat_midpoint_y(), 0, dx, 0.0, this, *pm, 0, ftr) )
      {
	     /* Do I need to distinguish between side collisions and vertex collisions ? */
	  
		 (*pm)->set_hit_type_and_side(PONGPING_BAT_COLLISION, vn);
		 
		 return 1;
	  }
   }
   
   
   
   
	  
	  
   /* check for collision against vertices of bat */
   
   m = new PotentialMove();
   
   moves.push_back(m);
   
   for(vn = 0; vn < 4; ++vn)
   {
       logfile << "checking vertex " << vn << "\n\n";
       /*
	   int (const unsigned char vertex_move,
                                 	   const double cx, 
									   const double cy, 
									   const int use_centre_of_mass, 
									   const double cmx, 
									   const double cmy, 
									   const Point v, 
									   const double angle, 
									   const int dx, 
									   const int dy, 
									   Circle *c, 
									   PotentialMove& move);
       */
	   
	   
	   
	   
	   
       if(cvc( PONGPING_TRANSLATION, 0.0, 0.0, PONGPING_USE_CENTRE_OF_MASS, bat.get_bat_midpoint_x(), bat.get_bat_midpoint_y(), bat.get_mass(),  bat.bat_vertices[vn], 0.0, dx, 0.0, this, moves[move_number], ftr))
	   {
	      moves[move_number]->set_hit_type_and_side(PONGPING_BAT_COLLISION, vn);
	   
	      ++move_number;
	      
		  //logfile << "move_number = " << move_number << "\n";
		  
		  //pm.hit_type = PONGPING_BAT_COLLISION;
	      
		  m = new PotentialMove();
   
          moves.push_back(m);
		  
	      //return 1;
	   }
      
   }
   
   vector< PotentialMove* >::iterator it = moves.end();
   
   
   
   if(move_number > 0)
   {  
      --it;
      sort(moves.begin(), it, compare_distance);
	  
	  (*pm) = moves[0]; 
	 
	  //logfile << "got a vertex hit.\n";
	  //eek();
	  
	  return 1;
   }
   
   

   return 0;
}
コード例 #15
0
ファイル: VectorTest.cpp プロジェクト: Spencerx/openBliSSART
bool VectorTest::performTest()
{
    srand((unsigned)time(NULL));

    const Elem cv_data[] = {  1, 2, 3 };
    const Elem rv_data[] = { -4, 0, 8 };
    ColVector cv(3, cv_data);
    RowVector rv(3, rv_data);
    cout << "Vector cv: " << cv << endl
         << "Vector rv: " << rv << endl;

    // Shift
    {
        const Elem cv_left[] = { 2, 3, 0 };
        const Elem cv_right[] = { 0, 1, 2 };
        ColVector cvl(cv);
        cvl.shiftLeft();
        cout << "Vector rv shifted left: " << cvl << endl;
        if (ColVector(3, cv_left) != cvl) return false;
        ColVector cvr(cv);
        cvr.shiftRight();
        cout << "Vector rv shifted right: " << cvr << endl;
        if (ColVector(3, cv_right) != cvr) return false;
    }


    // rv + rv
    {
        RowVector result = rv + rv;
        cout << "rv + rv = " << result << endl;
        for (unsigned int i = 0; i < rv.dim(); i++) {
            if (!epsilonCheck(result(i), rv(i) + rv(i)))
                return false;
        }
    }

    // rv - rv
    {
        RowVector result = rv - rv;
        cout << "rv - rv = " << result << endl;
        for (unsigned int i = 0; i < rv.dim(); i++) {
            if (!epsilonCheck(result(i), rv(i) - rv(i)))
                return false;
        }
    }

    // cv + cv
    {
        ColVector result = cv + cv;
        cout << "cv + cv = " << result << endl;
        for (unsigned int i = 0; i < cv.dim(); i++) {
            if (!epsilonCheck(result(i), cv(i) + cv(i)))
                return false;
        }
    }

    // cv - cv
    {
        ColVector result = cv - cv;
        cout << "cv - cv = " << result << endl;
        for (unsigned int i = 0; i < cv.dim(); i++) {
            if (!epsilonCheck(result(i), cv(i) - cv(i)))
                return false;
        }
    }

    // Operators += and -=
    {
        ColVector cvc(cv);
        cout << "cvc = " << cvc << endl;

        cvc += cv;
        cout << "cvc += cv => " << cvc << endl;
        if (!epsilonCheck(cvc(0), 2) ||
            !epsilonCheck(cvc(1), 4) ||
            !epsilonCheck(cvc(2), 6))
            return false;

        cvc -= cv;
        cout << "cvc -= cv => " << cvc << endl;
        if (!epsilonCheck(cvc(0), 1) ||
            !epsilonCheck(cvc(1), 2) ||
            !epsilonCheck(cvc(2), 3))
            return false;

        RowVector rvc(rv); // -4 0 8
        cout << "rvc = " << rvc << endl;

        rvc += rv;
        cout << "rvc += rv => " << rvc << endl;
        if (!epsilonCheck(rvc(0), -8) ||
            !epsilonCheck(rvc(1), 0) ||
            !epsilonCheck(rvc(2), 16))
            return false;

        rvc -= rv;
        cout << "rvc -= rv => " << rvc << endl;
        if (!epsilonCheck(rvc(0), -4) ||
            !epsilonCheck(rvc(1), 0) ||
            !epsilonCheck(rvc(2), 8))
            return false;
    }

    // Operator *=
    {
        ColVector cvc(cv);
        cout << "cvc = " << cvc << endl;
        cvc *= 5;
        cout << "cvc *= 5 => " << cvc << endl;
        if (!epsilonCheck(cvc(0), 5) ||
            !epsilonCheck(cvc(1), 10) ||
            !epsilonCheck(cvc(2), 15))
            return false;
    }

    // rv * cv
    {
        const Elem inner_prod = rv * cv;
        cout << "rv * cv = " << inner_prod << endl;
        if (!epsilonCheck(inner_prod, 20))
            return false;
    }

    // cv * rv
    {
        const Matrix cvrv(cv * rv);
        cout << "cv * rv = " << endl << cvrv;
        const Elem correct_cvrv_data[] = {  -4, 0,  8,
                                              -8, 0, 16,
                                             -12, 0, 24 };
        const Matrix correct_cvrv(3, 3, correct_cvrv_data);
        if (correct_cvrv != cvrv)
            return false;
    }

    // cv * rv larger test
    {
        int n_tests = 100;
        for (int k = 0; k < n_tests; ++k) {
            cout << "cv * rv #" << k << endl;
            const int m = 25;
            const int n = 500;
            double* data1 = new double[m];
            double* data2 = new double[n];
            for (int i = 0; i < m; ++i)
                data1[i] = generators::random(i);
            for (int i = 0; i < n; ++i)
                data2[i] = generators::random(i);
            ColVector randomCv(m, data1);
            RowVector randomRv(n, data2);
            Matrix cvAsMatrix(m, 1, data1);
            Matrix rvAsMatrix(1, n, data2);
            Matrix ref(m, n);
            cvAsMatrix.multWithMatrix(rvAsMatrix, &ref);
            Matrix res(randomCv * randomRv);
            if (ref != res) 
                return false;
            delete[] data2;
            delete[] data1;
        }
    }

    // cv * 5
    {
        ColVector tmp = cv * 5;
        cout << "cv * 5 = " << tmp << endl;
        if (!epsilonCheck(tmp(0), 5) ||
            !epsilonCheck(tmp(1), 10) ||
            !epsilonCheck(tmp(2), 15))
            return false;
    }

    // 4 * cv
    {
        ColVector tmp = 4 * cv;
        cout << "4 * cv = " << tmp << endl;
        if (!epsilonCheck(tmp(0), 4) ||
            !epsilonCheck(tmp(1), 8) ||
            !epsilonCheck(tmp(2), 12))
            return false;
    }

    // rv * 5
    {
        RowVector tmp = rv * 5;
        cout << "rv * 5 = " << tmp << endl;
        if (!epsilonCheck(tmp(0), -20) ||
            !epsilonCheck(tmp(1), 0) ||
            !epsilonCheck(tmp(2), 40))
            return false;
    }

    // 4 * rv
    {
        RowVector tmp = 4 * rv;
        cout << "4 * rv = " << tmp << endl;
        if (!epsilonCheck(tmp(0), -16) ||
            !epsilonCheck(tmp(1), 0) ||
            !epsilonCheck(tmp(2), 32))
            return false;
    }

    // Maximum, minimum
    const Elem mv_data[] = { -16, -1, 4, 8 };
    RowVector mv(4, mv_data);
    cout << "mv = " << mv << endl;

    Elem m = mv.minimum();
    cout << "Minimum of mv:            " << m << endl;
    if (m != -16)
        return false;
    
    m = mv.minimum(true);
    cout << "Minimum of mv (absolute): " << m << endl;
    if (m != -1)
        return false;

    m = mv.maximum();
    cout << "Maximum of mv:            " << m << endl;
    if (m != 8)
        return false;
    
    m = mv.maximum(true);
    cout << "Maximum of mv (absolute): " << m << endl;
    if (m != -16)
        return false;

    // Length
    cout << "Length of rv: " << rv.length() << endl;
    if (!epsilonCheck(rv.length(), 8.94427191))
        return false;
    
    // Angle between cv and rv
    cout << "Angle between cv and rv: " << Vector::angle(cv, rv) << endl;
    if (!epsilonCheck(Vector::angle(cv, rv), 0.930274014115))
        return false;
    
    // Random vector of unit length
    ColVector randcv(3, generators::random);
    cout << "Random vector: " << randcv << endl;

    // Silent operator() check
    // In case of errors this would fail during compile time
    {
    	ColVector a(5);
    	const ColVector b(3);
    	a(1) = b(2);
    }
    
    // Dump and read
    {
        const Elem v_data[] = {   3, 2.5, 1.5,   -1, -2.5, -1.5 };
        RowVector rv(6, v_data);
        ColVector cv(6, v_data);
        Poco::TemporaryFile rvTmpFile, cvTmpFile;
        rv.dump(rvTmpFile.path());
        cv.dump(cvTmpFile.path());
        RowVector rv2(rvTmpFile.path());
        ColVector cv2(cvTmpFile.path());
        cout << "---" << endl
             << "rv = " << rv << endl
             << "cv = " << cv << endl
             << "rv from file: " << rv2 << endl
             << "cv from file: " << cv2 << endl;
        for (unsigned int i = 0; i < 6; ++i)
            if (rv(i) != rv2(i) || cv(i) != cv2(i))
                return false;
    }
    
    return true;
}