Расчет параметров текстового источника сообщения. Вариант 10

Страницы работы

5 страниц (Word-файл)

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

РАСЧЁТ ПАРАМЕТРОВ ТЕКСТОВОГО ИСТОЧНИКА СООБЩЕНИЯ

> restart:

N:=10:

pathToFile:="SymArray.txt":

ABC:=["а","б","в","г","д","е","ж","з","и","к","л","м","н","о","п","р","с","т","у","ф","х","ч","ш","ю","я"," "]:

ABCSet:={"А","а","Б","б","В","в","Г","г","Д","д","Е","е","Ё","ё","Ж","ж","З","з","И","и","Й","й","К","к","Л","л","М","м","Н","н","О","о","П","п","Р","р","С","с","Т","т","У","у","Ф","ф","Х","х","Ч","ч","Ш","ш","Ю","ю","Я","я"," "}:

ABCEqu:=table(["ё"="е","й"="и"]):

ABCCase:=table(["А"="а","Б"="б","В"="в","Г"="г","Д"="д","Е"="е","Ё"="ё","Ж"="ж","З"="з","И"="и","Й"="й","К"="к","Л"="л","М"="м","Н"="н","О"="о","П"="п","Р"="р","С"="с","Т"="т","У"="у","Ф"="ф","Х"="х","Ч"="ч","Ш"="ш","Ю"="ю","Я"="я"," "=" "]):

fIn:=FileTools[Text][Open](value(pathToFile)):

while (not feof(fIn)) do

 scStr:=eval(FileTools[Text][ReadString](fIn)):

 if (scStr=NULL) then break: end if:

 scStrP:="":

 for nC from 1 by 1 to (length(scStr)) do

  if (member(eval(scStr[nC]),ABCSet)) then

   scStrP:=cat(scStrP,scStr[nC]):

   toLow:='toLow':

   toEqu:='toEqu':

   toLow:=eval(ABCCase[value(scStr[nC])]):  

   if (type(toLow,string)) then toEqu:=eval(ABCEqu[toLow]):

                                if (not type(toEqu,string)) then toEqu:=eval(toLow): end if:

   else toEqu:=eval(ABCEqu[value(scStr[nC])]):

        if (not type(toEqu,string)) then toEqu:=eval(scStr[nC]): end if:

   end if:

   if (not type(ABCC[value(toEqu)],integer)) then ABCC[value(toEqu)]:=0: end if:

   ABCC[value(toEqu)]:=eval(ABCC[value(toEqu)]+1):  

  end if:

 end do:

 scStr:=eval(cat(" ",scStrP," ")):

 if (not type(ABCC[" "],integer)) then ABCC[" "]:=0: end if:

 ABCC[" "]:=eval(ABCC[" "]+1):

 for nC from 1 by 1 to (length(scStr)-1) do

  indX:="": 

  for nS in eval([scStr[nC],scStr[nC+1]]) do  

   toLow:='toLow':

   toEqu:='toEqu':

   toLow:=eval(ABCCase[value(nS)]):  

   if (type(toLow,string)) then toEqu:=eval(ABCEqu[toLow]):

                                if (not type(toEqu,string)) then toEqu:=eval(toLow): end if:

   else toEqu:=eval(ABCEqu[nS]):

        if (not type(toEqu,string)) then toEqu:=eval(nS): end if:

   end if:  

   indX:=eval(cat(indX,toEqu)):

  end do:

  if (not type(ABCS[indX],integer)) then ABCS[indX]:=0: end if:

  incS:=eval(ABCS[indX]+1):

  ABCS[indX]:=eval(incS): 

Похожие материалы

Информация о работе

Тип:
Отчеты по лабораторным работам
Размер файла:
39 Kb
Скачали:
0