我有一个字典程序.请帮我解决错误! [英] i have a dictionary program. please help me in errors!

查看:84
本文介绍了我有一个字典程序.请帮我解决错误!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

8   IntelliSense: identifier &quot;cmp&quot; is undefined c:\documents and settings\user\desktop\aryan\aryan\aryan.cpp    32</pre>
<pre lang="msil">10  IntelliSense: no operator &quot;==&quot; matches these operands   c:\documents and settings\user\desktop\aryan\aryan\aryan.cpp    52</pre>
<pre lang="msil">12  IntelliSense: identifier &quot;a&quot; is undefined   c:\documents and settings\user\desktop\aryan\aryan\aryan.cpp    71</pre>

<pre lang="vb">6   IntelliSense: a value of type &quot;char *&quot; cannot be assigned to an entity of type &quot;char&quot;   c:\documents and settings\user\desktop\aryan\aryan\aryan.cpp    21


我希望该程序翻译单词,但我不知道该程序何时从用户那里获得单词.如何将单词赋予字典!例如(s,h)->在我的程序中


I want that this program translate words but i dont know when the program get a word from users. How it can give the words to the dictionary ! for example(s,h ) ->in my program

#include<iostream>
#include<conio.h>
#include <fstream>
using namespace std;
int main()
{
    //aval bayad az user ye file txt bekhahim

    char sentence[1000];
    char wordi[100][100];
    int wordC = 0;

    cout<<"please enter your sentence, and end it with dot: \n";
    for( int i = 0 ; i < 1000 ; i++ )
    {
        cin>>sentence[i];
        if( cmp( sentence[i] , ' ' ) == 0  )
        {
            wordi[ wordC ][ i ] = sentence
        }

        if( cmp( sentence[i] , '.' ) == 0 )
            break;

    }


    for( int j = 0 ; j < 100 ; j++ )
    {
        if( cmp( wordi) )
    }

    char s,h;
    fstream m[8];
    char *n[8];
    n[0]="noun";
    n[1]="verb";
    n[2]="adj";
    n[3]="adv";
    n[4]="art";
    n[5]="conj";
    n[6]="prep";
    n[7]="pron";
    string w;
    char *c;
    for(int i=0 ; i<8;i++)
    {
        //word vared shode dar file peyda shod

        if(w == n[i])
        {
        m[i].open(n[i],ios::in);
        while(!m[i].eof())
        {
        m[i].getline(c,20,'/');
        if(w == c)
        m[i].getline(c,20,'\n');
        cout<<c;
        }
        }

        //dar sorati ke peyda nashod
        //1.ghalate emlai dare -> kalamate moshabeh ro be kar bar neshon mide ta kalame dorosto entekhab kone  -> pattern matching
        //2.kalame jadido az kar bar begire be dic ma ezafe kone
        else
        {
            int lcs(string a,string b);
{
    int l[a.size()+1][b.size()+1];
    for(int i=a.size();i>=0;i--)
        for(int j=b.size();j>=0;j--)
        {
            if((a[i]==0)|(b[j]==0))
                l[i][j]=0;
            else
            {
                if(a[i]==b[j])
                    l[i][j]=1+l[i+1][j+1];
                else
                    l[i][j]=max(l[i+1][j],l[i][j+1]);
            }
        }
    return l[0][0];
}
        }
                else
                {
                    cout<<"sorry i can not find this word !"<<"\n"<< "please tell me it is noun,verb,...? :"
                        <<=s<<"\n"<<"what is the meaninig of it? :"<<=h;
                    cin>>s>>h;  // s,h ro berize to dic
                    }
    }
    for(int i=0;i<8;i++)
    m[i].close();

}
//az nazare grammer drostesh kone

推荐答案

第一个建议是像我这样的愚蠢的人在任何时候只能在我们的工作记忆中保存7件东西.尝试将代码分解为仅涉及7个或更少内容的代码.

那么如何将代码编写为:

The first bit of advice is that stupid people like me can only hold 7 things in our working memory at any one time. Try breaking your code up into chunks that only involve thinking about 7 or less things.

So how about writing your code as:

int main()
{
    std::ifstream dictionary_file( "dictionary.txt" );
    dictionary d( dictionary_file );

    std::ifstream file_to_analyse( "text.txt" );
    std::vector<std::string> words_not_found(
        d.words_not_in_dictionary( file_to_analyse ) );

    std::copy( words_not_found.begin(),
               words_not_found.end(),
               std::ostream_iterator<std::string>( std::cout ) );
}



您要做的全部"就是实现字典类.

现在,我可能已经得到了您尝试做的错误的事情.但是,尝试编写代码以反映您要实现的目标,而不是要如何实现(所有这些指针,数组和其他guff距汇编语言仅一步之遥),您会发现它更容易解决问题.

干杯,

Ash



"All" that you have to do is implement the dictionary class.

Now I might have got the sort of thing you''re trying to do incorrect. However try and write your code to reflect what you''re trying to achieve rather than how you''re trying to achieve it (all those pointers, arrays and other guff one step away from assembly language) you''ll find it easier to work through problems.

Cheers,

Ash


它看起来像一个基本的启发式数据库,但是问题的表现会让人发疯.

总结在顶部,然后将代码放在下面.
It looks like a basic heuristic database, but the presentation of your problem will drive people mad.

Summarise at the top, and put the code below.


这篇关于我有一个字典程序.请帮我解决错误!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆