-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] SPL

, 11 2017 . 14:32 +
, SPL : . .

, .

:

text = #.readtext("hamlet.txt")
words = #.split(text, " ", ".", ",", ";", "'", "!", "?", "-", "(", ")", "[", "]", #.crlf, #.quot)
> i, 1..#.size(words)
  >> words[i] = ""
  key = #.lower(words[i])
  dict[key] += 1
  total += 1
<
#.sortval(dict)
#.reverse(dict)
#.output(total, " ; ", #.size(dict), "  ")
> i, 1..10
  key = dict[i]
  #.output(i, " : ", key, " = ", dict[key])
<

:

32885 ; 4634  
1 : the = 1091
2 : and = 969
3 : to = 767
4 : of = 675
5 : i = 633
6 : a = 571
7 : you = 558
8 : my = 520
9 : in = 451
10 : it = 421

.

:

text = #.readtext("hamlet.txt")

hamlet.txt text.

:

words = #.split(text, " ", ".", ",", ";", "'", "!", "?", "-", "(", ")", "[", "]", #.crlf, #.quot)

"#.split" text words. "#.crlf" "#.quot", CRLF ( ) ".

, ">". :

> i, 1..#.size(words)

, i, 1 words, "#.size".

:

>> words[i] = ""

">>" , words[i] . , , .

key "#.lower":

key = #.lower(words[i])

:

dict[key] += 1

dict key 1, .

:

total += 1

, , total.

:

<

.

dict :

#.sortval(dict)

, :

#.reverse(dict)

, .

, , . :

#.output(total, " ; ", #.size(dict), "  ")

dict, "#.size", .

:

> i, 1..10

10 .

:

key = dict[i]

, ,

:

#.output(i, " : ", key, " = ", dict[key])

, . , , , .

:

<

.

, SPL , , . .

!
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/330678/

:  

: [1] []
 

:
: 

: ( )

:

  URL