Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spell checker turbo c++!!
Author Message
amce00 Offline
Novi korisnik
*

Posts: 16
Joined: Dec 2009
Reputation: 0
Post: #1
Spell checker turbo c++!!
Vozdra raja,
ovako imam problem i malo vremena. Profu opalila luda sad na kraju godine i dao mi zadatak da napravim spell checker u Turbo c++. Kraj skole imam testova kao konj odvjio sam vremena i pokusao napravit spell checker. Program treba da sadrzi naprimjer: spell.dic u kojem se nalazi nekoliko rijeci i naprimjer: spell.dat u kojem se nalazi recenica i on treba ispisati, koje rijeci su nepoznate...

Ja evo se ubijam prolistao google, a nikako da nadem da radi, a malo vremena imam. Nikog naravno ne molim da radi moj zadatak, vec ako neko ima uraden ili sajt da preuzmem barem neki izvorni kod. Nemora biti ovakav spell checker, bilo sta ili barem neki savjet kako da uradim kako treba. Hvala u svakom slucaju!!
18-04-2010 07:47 PM
Find all posts by this user Quote this message in a reply
danielvast Offline
Forumaš
***

Posts: 432
Joined: Dec 2009
Reputation: 22
Post: #2
RE: Spell checker turbo c++!!
Code:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;

vector<string> explode( const string &znak, const string &recenica)
{
    vector<string> polje;

    int duljinar = recenica.length();
    int duljinaz = znak.length();
    if (duljinaz==0)
        return polje;

    int i=0;
    int k=0;
    while( i<duljinar )
    {
        int j=0;
        while (i+j<duljinar && j<duljinaz && recenica[i+j]==znak[j])
            j++;
        if (j==duljinaz)
        {
            polje.push_back(  recenica.substr(k, i-k) );
            i+=duljinaz;
            k=i;
        }
        else
        {
            i++;
        }
    }
    polje.push_back( recenica.substr(k, i-k) );
    return polje;
}


int trazi(const vector< string > &sto, const vector< string > &gdje, int j)
{
    int max=gdje.size();

    if (max==0) return false;

    for(int i=0; i<max; i++)
        if (gdje[i]==sto[j])
            return true;
    return false;
}


main(){
       string recenica,rjecnik,nep_rijeci="";
       int k=0;
       cout << "Unesite recenicu ";
       getline(cin, recenica);
       fstream dat;
       dat.open("text.txt",ios::in);
       getline(dat,rjecnik);
       vector<string> rijeci_unos = explode(" ",recenica);
       vector<string> rijeci_iz_dat = explode(" ",rjecnik);
       for(int i=0; i < rijeci_unos.size(); i++)
       {
               if(!trazi(rijeci_unos,rijeci_iz_dat,i))
               {
                           nep_rijeci +=rijeci_unos[i];
                           nep_rijeci +=" ";                                          
               }
       }
       cout << "Nepoznate rijeci su " << nep_rijeci << endl;  
       system("pause");      
}

Evo neda mi se sada objasnjavati (kasno je), malo sam se pomucio Namigivanje malo prouci kod biti ce ti sve jasno! Nadam se da ce pomoci pozz

"When all else fails, read the manual."
18-04-2010 11:31 PM
Find all posts by this user Quote this message in a reply
amce00 Offline
Novi korisnik
*

Posts: 16
Joined: Dec 2009
Reputation: 0
Post: #3
RE: Spell checker turbo c++!!
Buraz hvala!!
20-04-2010 08:56 PM
Find all posts by this user Quote this message in a reply
danielvast Offline
Forumaš
***

Posts: 432
Joined: Dec 2009
Reputation: 22
Post: #4
RE: Spell checker turbo c++!!
Nema problema!:up:Bila dobra vjezbaNamigivanje

"When all else fails, read the manual."
(This post was last modified: 20-04-2010 09:32 PM by danielvast.)
20-04-2010 09:31 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)