@@ -17,26 +17,22 @@ msgstr ""
17
17
"Generated-By : Babel 2.17.0\n "
18
18
19
19
#: ../../library/bisect.rst:2
20
- #, fuzzy
21
20
msgid ":mod:`!bisect` --- Array bisection algorithm"
22
- msgstr ":mod:`bisect` --- 배열 이진 분할 알고리즘"
21
+ msgstr ":mod:`! bisect` --- 배열 이진 분할 알고리즘"
23
22
24
23
#: ../../library/bisect.rst:10
25
24
msgid "**Source code:** :source:`Lib/bisect.py`"
26
25
msgstr "**소스 코드:** :source:`Lib/bisect.py`"
27
26
28
27
#: ../../library/bisect.rst:14
29
- #, fuzzy
30
28
msgid ""
31
29
"This module provides support for maintaining a list in sorted order "
32
30
"without having to sort the list after each insertion. For long lists of "
33
31
"items with expensive comparison operations, this can be an improvement "
34
32
"over linear searches or frequent resorting."
35
33
msgstr ""
36
34
"이 모듈은 정렬된 리스트를 삽입 후에 다시 정렬할 필요 없도록 관리할 수 있도록 지원합니다. 값비싼 비교 연산이 포함된 항목의 긴 "
37
- "리스트의 경우, 이는 일반적인 방법에 비해 개선된 것입니다. 이 모듈은 기본적인 이진 분할 알고리즘을 사용하기 때문에 "
38
- ":mod:`bisect`\\ 라고 불립니다. 소스 코드는 알고리즘의 실제 예로서 가장 유용할 수 있습니다 (경계 조건은 이미 "
39
- "옳습니다!)."
35
+ "리스트의 경우, 이는 선형 검색이나 빈번한 재정렬에 비해 개선된 것입니다."
40
36
41
37
#: ../../library/bisect.rst:19
42
38
msgid ""
@@ -48,6 +44,10 @@ msgid ""
48
44
"found. Instead, the functions only call the :meth:`~object.__lt__` "
49
45
"method and will return an insertion point between values in an array."
50
46
msgstr ""
47
+ "이 모듈은 기본적인 이진 분할 알고리즘을 사용하기 때문에 :mod:`bisect`\\ 라고 불립니다. 특정 값을 검색하는 다른 이진 "
48
+ "분할 도구와 달리, 이 모듈의 함수는 삽입 지점을 찾도록 설계되었습니다. 따라서, 함수는 값을 찾았는지 판단하기 위해 "
49
+ ":meth:`~object.__eq__` 메서드를 호출하지 않습니다. 대신, 함수는 :meth:`~object.__lt__` "
50
+ "메서드만 호출하고 배열에 있는 값 사이의 삽입 지점을 반환합니다."
51
51
52
52
#: ../../library/bisect.rst:29
53
53
msgid "The following functions are provided:"
@@ -69,15 +69,15 @@ msgstr ""
69
69
"``list.insert()``\\ 의 첫 번째 매개 변수로 사용하기에 적합합니다."
70
70
71
71
#: ../../library/bisect.rst:41
72
- #, fuzzy
73
72
msgid ""
74
73
"The returned insertion point *ip* partitions the array *a* into two "
75
74
"slices such that ``all(elem < x for elem in a[lo : ip])`` is true for the"
76
75
" left slice and ``all(elem >= x for elem in a[ip : hi])`` is true for the"
77
76
" right slice."
78
77
msgstr ""
79
- "반환된 삽입 위치 *i*\\ 는 배열 *a*\\ 를 이분하여, 왼쪽은 ``all(val < x for val in a[lo:i])``,"
80
- " 오른쪽은 ``all(val >= x for val in a[i:hi])``\\ 이 되도록 만듭니다."
78
+ "반환된 삽입 위치 *ip*\\ 는 배열 *a*\\ 를 두 개의 조각으로 분할하여, 왼쪽에 대해서는 ``all(elem < x for "
79
+ "elem in a[lo : ip])``\\ 이 참이고, 오른쪽에 대해서는 ``all(elem >= x for elem in a[ip "
80
+ ": hi])``\\ 이 참이 되도록 만듭니다."
81
81
82
82
#: ../../library/bisect.rst:46
83
83
msgid ""
@@ -96,27 +96,26 @@ msgstr ""
96
96
#: ../../library/bisect.rst:53 ../../library/bisect.rst:67
97
97
#: ../../library/bisect.rst:85 ../../library/bisect.rst:105
98
98
msgid "Added the *key* parameter."
99
- msgstr ""
99
+ msgstr "*key* 매개 변수를 추가했습니다. "
100
100
101
101
#: ../../library/bisect.rst:60
102
- #, fuzzy
103
102
msgid ""
104
103
"Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point"
105
104
" which comes after (to the right of) any existing entries of *x* in *a*."
106
105
msgstr ""
107
- ":func:`bisect_left`\\ 와 비슷하지만, *a*\\ 에 있는 *x*\\ 의 기존 항목 뒤(오른쪽)에 오는 삽입 위치를 "
108
- "반환합니다."
106
+ ":py: func:`~bisect. bisect_left`\\ 와 비슷하지만, *a*\\ 에 있는 *x*\\ 의 기존 항목 뒤(오른쪽)에 "
107
+ "오는 삽입 위치를 반환합니다."
109
108
110
109
#: ../../library/bisect.rst:63
111
- #, fuzzy
112
110
msgid ""
113
111
"The returned insertion point *ip* partitions the array *a* into two "
114
112
"slices such that ``all(elem <= x for elem in a[lo : ip])`` is true for "
115
113
"the left slice and ``all(elem > x for elem in a[ip : hi])`` is true for "
116
114
"the right slice."
117
115
msgstr ""
118
- "반환된 삽입 위치 *i*\\ 는 배열 *a*\\ 를 이분하여, 왼쪽은 ``all(val <= x for val in "
119
- "a[lo:i])``, 오른쪽은 ``all(val > x for val in a[i:hi])``\\ 이 되도록 만듭니다."
116
+ "반환된 삽입 위치 *ip*\\ 는 배열 *a*\\ 를 두 개의 조각으로 분할하여, 왼쪽에 대해서는 ``all(elem <= x for "
117
+ "elem in a[lo : ip])``\\ 이 참이고, 오른쪽에 대해서는 ``all(elem > x for elem in a[ip :"
118
+ " hi])``\\ 이 참이 되도록 만듭니다."
120
119
121
120
#: ../../library/bisect.rst:73
122
121
msgid "Insert *x* in *a* in sorted order."
@@ -142,11 +141,12 @@ msgid ""
142
141
msgstr ""
143
142
144
143
#: ../../library/bisect.rst:92
145
- #, fuzzy
146
144
msgid ""
147
145
"Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after"
148
146
" any existing entries of *x*."
149
- msgstr ":func:`insort_left`\\ 와 비슷하지만, *a*\\ 에 *x*\\ 를 *x*\\ 의 기존 항목 다음에 삽입합니다."
147
+ msgstr ""
148
+ ":py:func:`~bisect.insort_left`\\ 와 비슷하지만, *a*\\ 에 *x*\\ 를 *x*\\ 의 기존 항목 다음에 "
149
+ "삽입합니다."
150
150
151
151
#: ../../library/bisect.rst:95
152
152
msgid ""
@@ -196,7 +196,6 @@ msgid ""
196
196
msgstr ""
197
197
198
198
#: ../../library/bisect.rst:135
199
- #, fuzzy
200
199
msgid ""
201
200
"The `SortedCollection recipe "
202
201
"<https://code.activestate.com/recipes/577197-sortedcollection/>`_ uses "
@@ -214,15 +213,14 @@ msgid "Searching Sorted Lists"
214
213
msgstr "정렬된 리스트 검색하기"
215
214
216
215
#: ../../library/bisect.rst:145
217
- #, fuzzy
218
216
msgid ""
219
217
"The above `bisect functions`_ are useful for finding insertion points but"
220
218
" can be tricky or awkward to use for common searching tasks. The "
221
219
"following five functions show how to transform them into the standard "
222
220
"lookups for sorted lists::"
223
221
msgstr ""
224
- "위의 :func: `bisect` 함수는 삽입 위치를 찾는 데 유용하지만, 일반적인 검색 작업에 사용하기가 까다롭거나 어색할 수 "
225
- "있습니다. 다음 다섯 함수는 정렬된 리스트에 대한 표준 조회로 변환하는 방법을 보여줍니다::"
222
+ "위의 `bisect functions`_ \\ 는 삽입 위치를 찾는 데 유용하지만, 일반적인 검색 작업에 사용하기가 까다롭거나 어색할 "
223
+ "수 있습니다. 다음 다섯 함수는 정렬된 리스트에 대한 표준 조회로 변환하는 방법을 보여줍니다::"
226
224
227
225
#: ../../library/bisect.rst:150
228
226
msgid ""
@@ -261,23 +259,55 @@ msgid ""
261
259
" return a[i]\n"
262
260
" raise ValueError"
263
261
msgstr ""
262
+ "def index(a, x):\n"
263
+ " 'x 와 정확히 같은 가장 왼쪽의 값을 찾습니다'\n"
264
+ " i = bisect_left(a, x)\n"
265
+ " if i != len(a) and a[i] == x:\n"
266
+ " return i\n"
267
+ " raise ValueError\n"
268
+ "\n"
269
+ "def find_lt(a, x):\n"
270
+ " 'x보다 작은 가장 오른쪽 값을 찾습니다'\n"
271
+ " i = bisect_left(a, x)\n"
272
+ " if i:\n"
273
+ " return a[i-1]\n"
274
+ " raise ValueError\n"
275
+ "\n"
276
+ "def find_le(a, x):\n"
277
+ " 'x보다 작거나 같은 가장 오른쪽 값을 찾습니다'\n"
278
+ " i = bisect_right(a, x)\n"
279
+ " if i:\n"
280
+ " return a[i-1]\n"
281
+ " raise ValueError\n"
282
+ "\n"
283
+ "def find_gt(a, x):\n"
284
+ " 'x보다 큰 가장 왼쪽 값을 찾습니다'\n"
285
+ " i = bisect_right(a, x)\n"
286
+ " if i != len(a):\n"
287
+ " return a[i]\n"
288
+ " raise ValueError\n"
289
+ "\n"
290
+ "def find_ge(a, x):\n"
291
+ " 'x보다 크거나 같은 가장 왼쪽 항목을 찾습니다'\n"
292
+ " i = bisect_left(a, x)\n"
293
+ " if i != len(a):\n"
294
+ " return a[i]\n"
295
+ " raise ValueError"
264
296
265
297
#: ../../library/bisect.rst:187
266
- #, fuzzy
267
298
msgid "Examples"
268
- msgstr "다른 예제"
299
+ msgstr "예제"
269
300
270
301
#: ../../library/bisect.rst:191
271
- #, fuzzy
272
302
msgid ""
273
303
"The :py:func:`~bisect.bisect` function can be useful for numeric table "
274
304
"lookups. This example uses :py:func:`~bisect.bisect` to look up a letter "
275
305
"grade for an exam score (say) based on a set of ordered numeric "
276
306
"breakpoints: 90 and up is an 'A', 80 to 89 is a 'B', and so on::"
277
307
msgstr ""
278
- ":func:`bisect` 함수는 숫자 테이블 조회에 유용할 수 있습니다. 이 예제는 :func:`bisect` \\ 를 사용하여 "
279
- "(가령) 시험 점수에 대한 문자 등급을 조회하는데, 정렬된 숫자 경계점 집합에 기반합니다: 90 이상은 'A', 80에서 89는 "
280
- "'B' 등입니다::"
308
+ ":py: func:`~ bisect.bisect ` 함수는 숫자 테이블 조회에 유용할 수 있습니다. 이 예제는 "
309
+ ":py:func:`~bisect.bisect` \\ 를 사용하여 (가령) 시험 점수에 대한 문자 등급을 조회하는데, 정렬된 숫자 경계점"
310
+ " 집합에 기반합니다: 90 이상은 'A', 80에서 89는 'B' 등입니다::"
281
311
282
312
#: ../../library/bisect.rst:196
283
313
msgid ""
@@ -288,6 +318,12 @@ msgid ""
288
318
">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n"
289
319
"['F', 'A', 'C', 'C', 'B', 'A', 'A']"
290
320
msgstr ""
321
+ ">>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):\n"
322
+ "... i = bisect(breakpoints, score)\n"
323
+ "... return grades[i]\n"
324
+ "...\n"
325
+ ">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n"
326
+ "['F', 'A', 'C', 'C', 'B', 'A', 'A']"
291
327
292
328
#: ../../library/bisect.rst:203
293
329
msgid ""
@@ -328,14 +364,42 @@ msgid ""
328
364
" Movie(name='Aliens', released=1986, director='Cameron'),\n"
329
365
" Movie(name='Titanic', released=1997, director='Cameron')]"
330
366
msgstr ""
367
+ ">>> from collections import namedtuple\n"
368
+ ">>> from operator import attrgetter\n"
369
+ ">>> from bisect import bisect, insort\n"
370
+ ">>> from pprint import pprint\n"
371
+ "\n"
372
+ ">>> Movie = namedtuple('Movie', ('name', 'released', 'director'))\n"
373
+ "\n"
374
+ ">>> movies = [\n"
375
+ "... Movie('Jaws', 1975, 'Spielberg'),\n"
376
+ "... Movie('Titanic', 1997, 'Cameron'),\n"
377
+ "... Movie('The Birds', 1963, 'Hitchcock'),\n"
378
+ "... Movie('Aliens', 1986, 'Cameron')\n"
379
+ "... ]\n"
380
+ "\n"
381
+ ">>> # 1960년 이후 개봉한 최초의 영화를 찾습니다\n"
382
+ ">>> by_year = attrgetter('released')\n"
383
+ ">>> movies.sort(key=by_year)\n"
384
+ ">>> movies[bisect(movies, 1960, key=by_year)]\n"
385
+ "Movie(name='The Birds', released=1963, director='Hitchcock')\n"
386
+ "\n"
387
+ ">>> # 정렬 순서를 유지하면서 영화를 삽입합니다\n"
388
+ ">>> romance = Movie('Love Story', 1970, 'Hiller')\n"
389
+ ">>> insort(movies, romance, key=by_year)\n"
390
+ ">>> pprint(movies)\n"
391
+ "[Movie(name='The Birds', released=1963, director='Hitchcock'),\n"
392
+ " Movie(name='Love Story', released=1970, director='Hiller'),\n"
393
+ " Movie(name='Jaws', released=1975, director='Spielberg'),\n"
394
+ " Movie(name='Aliens', released=1986, director='Cameron'),\n"
395
+ " Movie(name='Titanic', released=1997, director='Cameron')]"
331
396
332
397
#: ../../library/bisect.rst:237
333
- #, fuzzy
334
398
msgid ""
335
399
"If the key function is expensive, it is possible to avoid repeated "
336
400
"function calls by searching a list of precomputed keys to find the index "
337
401
"of a record::"
338
- msgstr "대신, 해당 레코드의 인덱스를 찾기 위해 미리 계산된 키 리스트를 검색하는 것이 좋습니다 ::"
402
+ msgstr "키 함수가 비싸면, 미리 계산된 키 목록을 검색하여 레코드의 인덱스를 찾으면 반복돠는 함수 호출을 피할 수 있습니다 ::"
339
403
340
404
#: ../../library/bisect.rst:240
341
405
msgid ""
@@ -351,6 +415,18 @@ msgid ""
351
415
">>> data[bisect_left(keys, 8)]\n"
352
416
"('yellow', 8)"
353
417
msgstr ""
418
+ ">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n"
419
+ ">>> data.sort(key=lambda r: r[1]) # 또는 operator.itemgetter(1) 를 "
420
+ "사용하세요.\n"
421
+ ">>> keys = [r[1] for r in data] # 미리 계산된 키 리스트.\n"
422
+ ">>> data[bisect_left(keys, 0)]\n"
423
+ "('black', 0)\n"
424
+ ">>> data[bisect_left(keys, 1)]\n"
425
+ "('blue', 1)\n"
426
+ ">>> data[bisect_left(keys, 5)]\n"
427
+ "('red', 5)\n"
428
+ ">>> data[bisect_left(keys, 8)]\n"
429
+ "('yellow', 8)"
354
430
355
431
#~ msgid ""
356
432
#~ "Insert *x* in *a* in sorted order."
0 commit comments