Разработка программного обеспечения для реализации переводчика с естественного языка на язык программирования

Автор работы: Пользователь скрыл имя, 21 Июля 2015 в 12:25, курсовая работа

Описание работы

Спроектировать и программно реализовать транслятор с естественного языка на язык программирования - Limbo. Транслятор написан на языке программирования – С#.
Разработанная программа должна считывать определенные конструкции естественного языка, распознавать их и преобразовывать в аналогичные конструкции языка Limbo с учетом особенностей построения этих конструкции в языке программирования. После преобразования всех конструкций, программа должна вывести на экран полученный код на языке Limbo.

Содержание работы

1 ПОСТАНОВКА ЗАДАЧИ 3
2 АНАЛИЗ ТЕКСТА НА ЕСТЕСТВЕННОМ ЯЗЫКЕ 4
2.1 Пример текста на естественном языке………………………………………4
2.2 Пошаговый разбор текста на естественном языке………………………….4
3 ОПИСАНИЕ ВЫБРАННОГО ЯЗЫКА ПРОГРАММИРОВАНИЯ………….6
3.1 История выбранного языка…………………………………………………..6
3.2 Особенности выбранного языка……………………………………………..6
3.3 Основные конструкции выбранного языка…………………………………7
4 ПРИМЕР ТРАНСЛЯЦИИ ИСХОДНОГО ТЕКСТА………………….……....8
4.1 Исходный текст……………………………………………………………….8
4.2 Транслированный текст………………………………………………………8
5 АЛГОРИТМ РАЗРАБОТАННОЙ ПРОГРАММЫ 10
5.1 Блок-схема……………………………………………………………………10
5.2 Словесный алгоритм…………………………………………………….…..11
6 КОД ПРОГРАММЫ…………………………………………………………...12
7 ПРИМЕР РАБОТЫ РАЗРАБОТАННОЙ ПРОГРАММЫ…...……………...25
СПИСОК ЛИТЕРАТУРЫ 28

Файлы: 1 файл

Пример ПЗ по ЛПОС 2 часть.doc

— 352.00 Кб (Скачать файл)

                                    }

                                    else

                                    {

                                        Lex = Lex + c3;

                                        j = y+1;

                                    }

                                }

                                result += "-" + Lex + ";";

                                Lex = "";

                            }

                            else

                            {

                            }

                        }

                        result += "\r\n";

                    }

 

                    if (Lexical == "цикл")// *************************************************************Цикл

                    {

                        Lexical = "";

                        i = i + 2;

                        int j;

                        string Lex = "";

                        for (j = i; j > i - 1; j++)

                        {

                            char c2 = input[j];

                            Lex = Lex + c2;

                            if (c2 == '☺')

                            {

                                breaking = true;

                                j = j - 500;

                            }

                            else if (c2 == '\r' || c2 == '\n')

                            {

                                j = j - 500;

                            }

                            else if (c2 == ' ')

                            {

                                Lex = "";

                            }

                            if (Lex == "по")

                            {

                                Lex = "";

                                j = j + 2;

                                int y;

                                for (y = j; y > j - 1; y++)

                                {

                                    char c3 = input[y];

                                    if (c3 == '☺')

                                    {

                                        breaking = true;

                                        y = y - 500;

                                    }

                                    else if (c3 == '\r' || c3 == '\n' || c3 == ' ')

                                    {

                                        y = y - 500;

                                    }

                                    else

                                    {

                                        Lex = Lex + c3;

                                        j = y+1;

                                    }

                                }

                                cikl = Lex;

                                Lex = "";

                            }

                            if (Lex == "от")

                            {

                                Lex = "";

                                j = j + 2;

                                int y;

                                for (y = j; y > j - 1; y++)

                                {

                                    char c3 = input[y];

                                    if (c3 == '☺')

                                    {

                                        breaking = true;

                                        y = y - 500;

                                    }

                                    else if (c3 == '\r' || c3 == '\n' || c3 == ' ')

                                    {

                                        y = y - 500;

                                    }

                                    else

                                    {

                                        Lex = Lex + c3;

                                        j = y+1;

                                    }

                                }

                                cikl2 = Lex;

                                Lex = "";

                            }

                            if (Lex == "до")

                            {

                                Lex = "";

                                j = j + 2;

                                int y;

                                for (y = j; y > j - 1; y++)

                                {

                                    char c3 = input[y];

                                    if (c3 == '☺')

                                    {

                                        breaking = true;

                                        y = y - 500;

                                    }

                                    else if (c3 == '\r' || c3 == '\n' || c3 == ' ')

                                    {

                                        y = y - 500;

                                    }

                                    else

                                    {

                                        Lex = Lex + c3;

                                        j = y+1;

                                    }

                                }

                                cikl3 = Lex;

                                Lex = "";

                            }

                            if (Lex == "шаг")

                            {

                               

                                Lex = "";

                                j = j + 2;

                                int y;

                                for (y = j; y > j - 1; y++)

                                {

                                    char c3 = input[y];

                                    if (c3 == '☺')

                                    {

                                        breaking = true;

                                        y = y - 500;

                                    }

                                    else if (c3 == '\r' || c3 == '\n' || c3 == ' ')

                                    {

                                        y = y - 500;

                                    }

                                    else

                                    {

                                        Lex = Lex + c3;

                                        j = y+1;

                                    }

                                }

                                cikl4 = Lex;

                                Lex = "";

                            }

                            else

                            {

                            }

                        }

                        result += "\r\n" + "for ("+ cikl + "=" + cikl2 + "; "+ cikl +  " < " + cikl3 + "; "+ cikl +"+"+ cikl4+")";

                        result += "\r\n";

 

                    }

 

                    if (Lexical == "начало цикла")// ******************************************************Начало Цикла

                    {

                        result += "{";

                        result += "\r\n";

                        Lexical = "";

                    }

 

                    if (Lexical == "конец цикла")// ******************************************************Конец Цикла

                    {

                        result += "}";

                        result += "\r\n";

                        Lexical = "";

                    }

 

                    if (Lexical == "инкремент")// ******************************************************Инкремент

                    {

                        int y;

                        i = i + 2;

                        string Lex = "";

                        for (y = i; y > i - 1; y++)

                        {

                            char c3 = input[y];

                            if (c3 == '☺')

                            {

                                breaking = true;

                                y = y - 500;

                            }

                            else if (c3 == '\r' || c3 == '\n' || c3 == ' ')

                            {

                                y = y - 500;

                            }

                            else

                            {

                                Lex = Lex + c3;

                                i = y+1;

                            }

                        }

                        result += Lex +"++";

                        result += "\r\n";

                        Lexical = "";

                    }

 

                    if (Lexical == "декремент")// ******************************************************Декремент

                    {

                        result += " ";

                        int y;

                        i = i + 2;

                        string Lex = "";

                        for (y = i; y > i - 1; y++)

                        {

                            char c3 = input[y];

                            if (c3 == '☺')

                            {

                                breaking = true;

                                y = y - 500;

                            }

                            else if (c3 == '\r' || c3 == '\n' || c3 == ' ')

                            {

                                y = y - 500;

                            }

                            else

                            {

                                Lex = Lex + c3;

                                i = y+1;

                            }

                        }

                        result += Lex + "--";

                        result += "\r\n";

                        Lexical = "";

                    }

 

                    if (Lexical == "если")// ******************************************************если

                    {

                        result += "\r\n" + "If (";

                        int y;

                        i = i + 2;

                        string Lex = "";

                        for (y = i; y > i - 1; y++)

                        {

                            char c3 = input[y];

                            if (c3 == '☺')

                            {

                                breaking = true;

                                y = y - 500;

                            }

                            else if (c3 == '\r' || c3 == '\n' || c3 == ' ')

                            {

                                y = y - 500;

                            }

                            else

                            {

                                Lex = Lex + c3;

                                i = y+1;

                            }

                        }

                       

                        result += Lex ;

                        Lexical = "";

                        i = i + 1;

                        int j;

                        Lex = "";

                        for (j = i; j > i - 1; j++)

                        {

                            char c2 = input[j];

                            Lex = Lex + c2;

                            if (c2 == '☺')

                            {

                                breaking = true;

                                j = j - 500;

                            }

                            else if (c2 == '\r' || c2 == '\n')

                            {

                                j = j - 500;

                            }

                            else if (c2 == ' ')

                            {

                                Lex = "";

                            }

                            if (Lex == "меньше")

                            {

                                Lex = "";

                                j = j + 2;

                                int y2;

                                for (y2 = j; y2 > j - 1; y2++)

                                {

                                    char c3 = input[y2];

                                    if (c3 == '☺')

                                    {

                                        breaking = true;

                                        y2 = y2 - 500;

                                    }

                                    else if (c3 == '\r' || c3 == '\n' || c3 == ' ')

                                    {

Информация о работе Разработка программного обеспечения для реализации переводчика с естественного языка на язык программирования