@@ -17,26 +17,22 @@ msgstr ""
1717"Generated-By : Babel 2.17.0\n "
1818
1919#: ../../library/bisect.rst:2
20- #, fuzzy
2120msgid ":mod:`!bisect` --- Array bisection algorithm"
22- msgstr ":mod:`bisect` --- 배열 이진 분할 알고리즘"
21+ msgstr ":mod:`! bisect` --- 배열 이진 분할 알고리즘"
2322
2423#: ../../library/bisect.rst:10
2524msgid "**Source code:** :source:`Lib/bisect.py`"
2625msgstr "**소스 코드:** :source:`Lib/bisect.py`"
2726
2827#: ../../library/bisect.rst:14
29- #, fuzzy
3028msgid ""
3129"This module provides support for maintaining a list in sorted order "
3230"without having to sort the list after each insertion. For long lists of "
3331"items with expensive comparison operations, this can be an improvement "
3432"over linear searches or frequent resorting."
3533msgstr ""
3634"이 모듈은 정렬된 리스트를 삽입 후에 다시 정렬할 필요 없도록 관리할 수 있도록 지원합니다. 값비싼 비교 연산이 포함된 항목의 긴 "
37- "리스트의 경우, 이는 일반적인 방법에 비해 개선된 것입니다. 이 모듈은 기본적인 이진 분할 알고리즘을 사용하기 때문에 "
38- ":mod:`bisect`\\ 라고 불립니다. 소스 코드는 알고리즘의 실제 예로서 가장 유용할 수 있습니다 (경계 조건은 이미 "
39- "옳습니다!)."
35+ "리스트의 경우, 이는 선형 검색이나 빈번한 재정렬에 비해 개선된 것입니다."
4036
4137#: ../../library/bisect.rst:19
4238msgid ""
@@ -48,6 +44,10 @@ msgid ""
4844"found. Instead, the functions only call the :meth:`~object.__lt__` "
4945"method and will return an insertion point between values in an array."
5046msgstr ""
47+ "이 모듈은 기본적인 이진 분할 알고리즘을 사용하기 때문에 :mod:`bisect`\\ 라고 불립니다. 특정 값을 검색하는 다른 이진 "
48+ "분할 도구와 달리, 이 모듈의 함수는 삽입 지점을 찾도록 설계되었습니다. 따라서, 함수는 값을 찾았는지 판단하기 위해 "
49+ ":meth:`~object.__eq__` 메서드를 호출하지 않습니다. 대신, 함수는 :meth:`~object.__lt__` "
50+ "메서드만 호출하고 배열에 있는 값 사이의 삽입 지점을 반환합니다."
5151
5252#: ../../library/bisect.rst:29
5353msgid "The following functions are provided:"
@@ -69,15 +69,15 @@ msgstr ""
6969"``list.insert()``\\ 의 첫 번째 매개 변수로 사용하기에 적합합니다."
7070
7171#: ../../library/bisect.rst:41
72- #, fuzzy
7372msgid ""
7473"The returned insertion point *ip* partitions the array *a* into two "
7574"slices such that ``all(elem < x for elem in a[lo : ip])`` is true for the"
7675" left slice and ``all(elem >= x for elem in a[ip : hi])`` is true for the"
7776" right slice."
7877msgstr ""
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])``\\ 이 참이 되도록 만듭니다."
8181
8282#: ../../library/bisect.rst:46
8383msgid ""
@@ -96,27 +96,26 @@ msgstr ""
9696#: ../../library/bisect.rst:53 ../../library/bisect.rst:67
9797#: ../../library/bisect.rst:85 ../../library/bisect.rst:105
9898msgid "Added the *key* parameter."
99- msgstr ""
99+ msgstr "*key* 매개 변수를 추가했습니다. "
100100
101101#: ../../library/bisect.rst:60
102- #, fuzzy
103102msgid ""
104103"Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point"
105104" which comes after (to the right of) any existing entries of *x* in *a*."
106105msgstr ""
107- ":func:`bisect_left`\\ 와 비슷하지만, *a*\\ 에 있는 *x*\\ 의 기존 항목 뒤(오른쪽)에 오는 삽입 위치를 "
108- "반환합니다."
106+ ":py: func:`~bisect. bisect_left`\\ 와 비슷하지만, *a*\\ 에 있는 *x*\\ 의 기존 항목 뒤(오른쪽)에 "
107+ "오는 삽입 위치를 반환합니다."
109108
110109#: ../../library/bisect.rst:63
111- #, fuzzy
112110msgid ""
113111"The returned insertion point *ip* partitions the array *a* into two "
114112"slices such that ``all(elem <= x for elem in a[lo : ip])`` is true for "
115113"the left slice and ``all(elem > x for elem in a[ip : hi])`` is true for "
116114"the right slice."
117115msgstr ""
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])``\\ 이 참이 되도록 만듭니다."
120119
121120#: ../../library/bisect.rst:73
122121msgid "Insert *x* in *a* in sorted order."
@@ -142,11 +141,12 @@ msgid ""
142141msgstr ""
143142
144143#: ../../library/bisect.rst:92
145- #, fuzzy
146144msgid ""
147145"Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after"
148146" 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+ "삽입합니다."
150150
151151#: ../../library/bisect.rst:95
152152msgid ""
@@ -196,7 +196,6 @@ msgid ""
196196msgstr ""
197197
198198#: ../../library/bisect.rst:135
199- #, fuzzy
200199msgid ""
201200"The `SortedCollection recipe "
202201"<https://code.activestate.com/recipes/577197-sortedcollection/>`_ uses "
@@ -214,15 +213,14 @@ msgid "Searching Sorted Lists"
214213msgstr "정렬된 리스트 검색하기"
215214
216215#: ../../library/bisect.rst:145
217- #, fuzzy
218216msgid ""
219217"The above `bisect functions`_ are useful for finding insertion points but"
220218" can be tricky or awkward to use for common searching tasks. The "
221219"following five functions show how to transform them into the standard "
222220"lookups for sorted lists::"
223221msgstr ""
224- "위의 :func: `bisect` 함수는 삽입 위치를 찾는 데 유용하지만, 일반적인 검색 작업에 사용하기가 까다롭거나 어색할 수 "
225- "있습니다. 다음 다섯 함수는 정렬된 리스트에 대한 표준 조회로 변환하는 방법을 보여줍니다::"
222+ "위의 `bisect functions`_ \\ 는 삽입 위치를 찾는 데 유용하지만, 일반적인 검색 작업에 사용하기가 까다롭거나 어색할 "
223+ "수 있습니다. 다음 다섯 함수는 정렬된 리스트에 대한 표준 조회로 변환하는 방법을 보여줍니다::"
226224
227225#: ../../library/bisect.rst:150
228226msgid ""
@@ -261,23 +259,55 @@ msgid ""
261259" return a[i]\n"
262260" raise ValueError"
263261msgstr ""
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"
264296
265297#: ../../library/bisect.rst:187
266- #, fuzzy
267298msgid "Examples"
268- msgstr "다른 예제"
299+ msgstr "예제"
269300
270301#: ../../library/bisect.rst:191
271- #, fuzzy
272302msgid ""
273303"The :py:func:`~bisect.bisect` function can be useful for numeric table "
274304"lookups. This example uses :py:func:`~bisect.bisect` to look up a letter "
275305"grade for an exam score (say) based on a set of ordered numeric "
276306"breakpoints: 90 and up is an 'A', 80 to 89 is a 'B', and so on::"
277307msgstr ""
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' 등입니다::"
281311
282312#: ../../library/bisect.rst:196
283313msgid ""
@@ -288,6 +318,12 @@ msgid ""
288318">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n"
289319"['F', 'A', 'C', 'C', 'B', 'A', 'A']"
290320msgstr ""
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']"
291327
292328#: ../../library/bisect.rst:203
293329msgid ""
@@ -328,14 +364,42 @@ msgid ""
328364" Movie(name='Aliens', released=1986, director='Cameron'),\n"
329365" Movie(name='Titanic', released=1997, director='Cameron')]"
330366msgstr ""
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')]"
331396
332397#: ../../library/bisect.rst:237
333- #, fuzzy
334398msgid ""
335399"If the key function is expensive, it is possible to avoid repeated "
336400"function calls by searching a list of precomputed keys to find the index "
337401"of a record::"
338- msgstr "대신, 해당 레코드의 인덱스를 찾기 위해 미리 계산된 키 리스트를 검색하는 것이 좋습니다 ::"
402+ msgstr "키 함수가 비싸면, 미리 계산된 키 목록을 검색하여 레코드의 인덱스를 찾으면 반복돠는 함수 호출을 피할 수 있습니다 ::"
339403
340404#: ../../library/bisect.rst:240
341405msgid ""
@@ -351,6 +415,18 @@ msgid ""
351415">>> data[bisect_left(keys, 8)]\n"
352416"('yellow', 8)"
353417msgstr ""
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)"
354430
355431#~ msgid ""
356432#~ "Insert *x* in *a* in sorted order."
0 commit comments