Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
af04a90
add site/ko/swift/python_interoperability.ipynb
FKgk Oct 1, 2019
39fade6
translate from en to ko
FKgk Oct 1, 2019
33dc8fb
텐서플로우 -> 텐서플로
FKgk Oct 1, 2019
527ee2f
노트 -> Note
FKgk Oct 1, 2019
5e365e3
파이썬에서 -> 파이썬
FKgk Oct 1, 2019
561903a
노트 -> Note
FKgk Oct 1, 2019
60ae220
내장객체 -> 내장 객체
FKgk Oct 1, 2019
a913e36
튜플의 열성 -> 튜플의 열성
FKgk Oct 1, 2019
be24958
방법 -> 메서드
FKgk Oct 1, 2019
8b0af42
Python -> 파이썬 & 진입합니다. -> 접근합니다.
FKgk Oct 1, 2019
4a33694
시도합니다. -> 사용합니다.
FKgk Oct 1, 2019
8873b44
세트 업. -> 준비.
FKgk Oct 1, 2019
1e33f91
일렬로 -> 결과창에
FKgk Oct 1, 2019
01503fc
remove English Document
FKgk Oct 1, 2019
d9bdb60
스위피트에서, -> 스위프트에서
FKgk Oct 1, 2019
1179962
투플 -> 튜플
FKgk Oct 1, 2019
4c359a2
결과창에 -> 결과 창에
FKgk Oct 1, 2019
4f44aaa
노트: ~ 않습니다. -> ~ 않다는 점에 유의해야 합니다
FKgk Oct 1, 2019
9ea40b5
debug ... loading -> 파이썬 라이브러리 로딩을 위한 디버그 출력
FKgk Oct 1, 2019
aee2b72
modify metadata for swift
FKgk Oct 2, 2019
35a493b
Fix button links
lamberta Oct 3, 2019
4402409
Update as suggested
FKgk Oct 22, 2019
00d8e75
Revert "Update as suggested"
FKgk Oct 22, 2019
6b41054
Revert "Fix button links"
FKgk Oct 22, 2019
3175a99
Revert "Revert "Fix button links""
FKgk Oct 22, 2019
323dfcf
Update as suggested
FKgk Oct 22, 2019
3af777d
remove 예시 원본에 존재X
FKgk Oct 22, 2019
9093099
add 예를 들어 for origin 'For example:'
FKgk Oct 22, 2019
d8bb21a
change 로 to 에
FKgk Oct 23, 2019
2378372
revert proper noun
FKgk Oct 23, 2019
e9f2d66
translate url title
FKgk Oct 27, 2019
535019d
add community Note
FKgk Oct 27, 2019
bb71ff6
re translte PYTHON_LIBRARY~~~
FKgk Oct 27, 2019
0ccf422
modify sentence swift for python version~
FKgk Oct 27, 2019
0a2d3f1
correction of misspelled
FKgk Oct 27, 2019
b1bdc2e
correction of misspelled
FKgk Oct 27, 2019
6dd1bc6
add 를
FKgk Oct 27, 2019
06c2eea
'유형' -> '자료형
FKgk Oct 27, 2019
7f7c4d1
Literal 모든 -> 모든 Literal
FKgk Oct 27, 2019
df44872
modify tanslation
FKgk Oct 27, 2019
77e7f4b
modify tanslation adding type-safe
FKgk Oct 27, 2019
0b3a34e
Retranslation
FKgk Oct 27, 2019
f6f7366
Retranslate basic
FKgk Oct 27, 2019
7191bb0
modify double quote
FKgk Oct 27, 2019
f7b3c58
move traslation to en docs
FKgk Oct 28, 2019
5ffd04c
Update en docs url
FKgk Oct 28, 2019
5c582a9
modify translation to read easily
FKgk Oct 28, 2019
e5c25cc
modify translation to read easily
FKgk Oct 28, 2019
24b9a38
modify translation to read easily
FKgk Oct 28, 2019
012aa5d
update url in github and colab
FKgk Oct 29, 2019
03dba97
add space
FKgk Oct 29, 2019
01ba431
add space
FKgk Oct 29, 2019
f78414c
change Python qoute
FKgk Oct 29, 2019
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
translate from en to ko
  • Loading branch information
FKgk committed Oct 1, 2019
commit 39fade694f1d8406d25e130bfb23d199441e8819
128 changes: 69 additions & 59 deletions site/ko/swift/python_interoperability.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@
"id": "8sa42_NblqRE"
},
"source": [
"# Python interoperability\n",
"# 파이썬 상호 호환성\n",
"\n",
"Swift For TensorFlow supports Python interoperability.\n",
"\n",
"You can import Python modules from Swift, call Python functions, and convert values between Swift and Python."
"텐서플로우를 위한 스위프트는 파이썬 상호 호환성을 지원합니다.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'tensorflow' is translated as '텐서플로' in TF docs.
Please replace '텐서플로우' with '텐서플로'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review

I changed it from '텐서플로우' to '텐서플로'.

"스위프트에서 파이썬 모듈을 임포트해서, 스위프트와 파이썬 사이의 값을 바꾸거나 파이썬 함수를 호출할 수 있습니다."
]
},
{
Expand Down Expand Up @@ -99,29 +98,29 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setting the Python version"
"## 파이썬 버전 설정"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By default, when you `import Python`, Swift searches system library paths for the newest version of Python installed. \n",
"To use a specific Python installation, set the `PYTHON_LIBRARY` environment variable to the `libpython` shared library provided by the installation. For example: \n",
"기본적으로 파이썬을 임포트 하면, 스위프트는 시스템 라이브러리 경로를 검색하여 설치된 최신 버전의 파이썬을 검색합니다.\n",
"특정한 파이썬을 설치하고자 할 때, 설치에서 제공하는 `libpython` 공유 라이브러리로 `PYTHON_LIBRARY` 환경변수를 설정해야 합니다.\n",
"\n",
"`export PYTHON_LIBRARY=\"~/anaconda3/lib/libpython3.7m.so\"`\n",
"예시: `\"export PYTHON_LIBRARY=\"~/anaconda3/\n",
"lib/libpython3.7m.so\"`\n",
"\n",
"The exact filename will differ across Python environments and platforms."
"정확한 파일명은 파이썬 환경과 플랫폼마다 다를 수 있습니다."
]
},

{
"cell_type": "markdown",
"metadata": {},
"source": [
"Alternatively, you can set the `PYTHON_VERSION` environment variable, which instructs Swift to search system library paths for a matching Python version. Note that `PYTHON_LIBRARY` takes precedence over `PYTHON_VERSION`.\n",
"또는 스위프트에 일치하는 파이썬 버전에 대한 시스템 라이브러리 경로를 검색하도록 알려주는 `PYTHON_VERSION` 환경변수를 설정할 수 있습니다. `PYTHON_LIBRARY``PYTHON_VERSION`보다 우선한다는 점을 유의해야 합니다.\n",
"\n",
"In code, you can also call the `PythonLibrary.useVersion` function, which is equivalent to setting `PYTHON_VERSION`."
"또한 코드에서 `PYTHON_VERSION` 설정과 동일한 `PythonLibrary.useVersion`함수를 호출할 수 있습니다."
]
},
{
Expand All @@ -138,14 +137,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"__Note: you should run `PythonLibrary.useVersion` right after `import Python`, before calling any Python code. It cannot be used to dynamically switch Python versions.__"
"_노트: \n",
"파이썬을 임포트한 직후, 파이썬 코드를 호출하기 전에`PythonLibrary.useVersion`을 실행해야 합니다._\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Note' is a style element used on tensorflow.org for callout boxes. So, don't need to translate the word.
I suggest to replace '_노트' with 'Note'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it from '노트' to 'Note'
Also 267th line was changed same.

]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Set `PYTHON_LOADER_LOGGING=1` to see [debug output for Python library loading](https://github.com/apple/swift/pull/20674#discussion_r235207008). "
"`PYTHON_LOADER_LOGGING=1` 설정은 [debug output for Python library loading](https://github.com/apple/swift/pull/20674#discussion_r235207008)을 참고하세요."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The words for site link, 'debug... loading', seems to be translated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I translate it from 'debug output for Python library loading' to '파이썬 라이브러리 로딩을 위한 디버그 출력'
Or should I not translate?

]
},
{
Expand All @@ -155,14 +155,13 @@
"id": "rU0WY_sJodio"
},
"source": [
"## Basics\n",
"\n",
"In Swift, `PythonObject` represents an object from Python.\n",
"All Python APIs use and return `PythonObject` instances.\n",
"## 기본\n",
"스위프트에서, `PythonObject`는 파이썬에서 객체를 나타냅니다.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'~에서' ... '~에서' doesn't looks natural.
I suggest to replace '파이썬에서' with '파이썬'

Copy link
Contributor Author

@FKgk FKgk Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it from '파이썬에서' to '파이썬
And I suggest to replace '스위프트에서,' with '스위프트에서'
(But the en doc says 'in swift,' )

"모든 파이썬 API는 `PythonObject` 인스턴스를 사용하거나 반환합니다.\n",
"\n",
"Basic types in Swift (like numbers and arrays) are convertible to `PythonObject`. In some cases (for literals and functions taking `PythonConvertible` arguments), conversion happens implicitly. To explicitly cast a Swift value to `PythonObject`, use the `PythonObject` initializer.\n",
"스위프트(숫자 및 배열처럼)에서 기본형은 `PythonObject`로 전환할 수 있습니다. 몇몇 경우에 (\"PythonConvertible\" 인수를 받는 리터럴과 함수의 경우), 변환이 암묵적으로 일어납니다. 스위프트 값을 `PythonObject`에 명시적으로 지정하려면 `PythonObject` 이니셜라이저를 사용합니다.\n",
"\n",
"`PythonObject` defines many standard operations, including numeric operations, indexing, and iteration."
"`PythonObject`는 숫자 연산, 인덱싱, 반복을 포함한 많은 표준 연산을 정의합니다."
]
},
{
Expand Down Expand Up @@ -191,15 +190,15 @@
}
],
"source": [
"// Convert standard Swift types to Python.\n",
"// 표준 스위프트 유형을 Python으로 변환합니다.\n",
"let pythonInt: PythonObject = 1\n",
"let pythonFloat: PythonObject = 3.0\n",
"let pythonString: PythonObject = \"Hello Python!\"\n",
"let pythonRange: PythonObject = PythonObject(5..<10)\n",
"let pythonArray: PythonObject = [1, 2, 3, 4]\n",
"let pythonDict: PythonObject = [\"foo\": [0], \"bar\": [1, 2, 3]]\n",
"\n",
"// Perform standard operations on Python objects.\n",
"// 파이썬 객체에 표준 연산을 수행합니다.\n",
"print(pythonInt + pythonFloat)\n",
"print(pythonString[0..<6])\n",
"print(pythonRange)\n",
Expand Down Expand Up @@ -233,16 +232,16 @@
}
],
"source": [
"// Convert Python objects back to Swift.\n",
"// 파이썬 객체를 다시 스위프트로 변환합니다.\n",
"let int = Int(pythonInt)!\n",
"let float = Float(pythonFloat)!\n",
"let string = String(pythonString)!\n",
"let range = Range<Int>(pythonRange)!\n",
"let array: [Int] = Array(pythonArray)!\n",
"let dict: [String: [Int]] = Dictionary(pythonDict)!\n",
"\n",
"// Perform standard operations.\n",
"// Outputs are the same as Python!\n",
"// 표준 연산을 수행합니다.\n",
"// 출력은 파이썬과 동일합니다!\n",
"print(Float(int) + float)\n",
"print(string.prefix(6))\n",
"print(range)\n",
Expand All @@ -257,16 +256,16 @@
"id": "1pMewsl0VgnJ"
},
"source": [
"`PythonObject` defines conformances to many standard Swift protocols:\n",
"* `Equatable`\n",
"* `Comparable`\n",
"* `Hashable`\n",
"* `SignedNumeric`\n",
"* `Strideable`\n",
"* `MutableCollection`\n",
"* All of the `ExpressibleBy_Literal` protocols\n",
"`PythonObject`는 많은 표준 스위프트 프로토콜에 대한 적합성을 정의합니다.\n",
"* `동시성`\n",
"* `비교성`\n",
"* `해쉬적`\n",
"* `정수`\n",
"* `변할 수 있는 수집`\n",
"* `리터럴에 의해 표현가능한` 모든 프로토콜\n",
"\n",
"Note that these conformances are not type-safe: crashes will occur if you attempt to use protocol functionality from an incompatible `PythonObject` instance."
"노트: 이러한 형식은 안전하지 않습니다.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original English document, the word, 'Note', is not used but 'Note that'.
'Note' is a style element but not 'Note that'.
I suggest to rewrite this sentence.

Copy link
Contributor Author

@FKgk FKgk Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to rewrite '노트: 이러한 형식은 안전하지 않습니다.' with '이러한 형식은 안전하지 않다는 점에 유의해야 합니다.'

"충돌은 호환되지 않는 `PythonObject` 인스턴스에서 프로토콜 기능을 사용하려고 할 때 발생합니다."
]
},
{
Expand Down Expand Up @@ -314,9 +313,9 @@
"id": "w3lmTRCWT5sS"
},
"source": [
"To convert tuples from Python to Swift, you must statically know the arity of the tuple.\n",
"튜플을 파이썬에서 스위프트로 변환하려면, 정적으로 투플의 열성을 알아야 합니다.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In logic, mathematics, and computer science, the meaning of 'arity' is 'fixed number of argument'.
I suggest to replace '투플의 열성' with '튜플의 길이'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for information

I changed it '투플의 열성' to '튜플의 길이'

"\n",
"Call one of the following instance methods:\n",
"다음 인스턴스 방법 중 하나를 호출합니다:\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'method' is translated as '메서드' in TF docs.
I suggest to replace '방법' with '메서드'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry I couldn't refer to the TF docs well.

I changed it from '방법' to '메서드'

"- `PythonObject.tuple2`\n",
"- `PythonObject.tuple3`\n",
"- `PythonObject.tuple4`"
Expand Down Expand Up @@ -360,9 +359,9 @@
"id": "Te7sNNx9c_am"
},
"source": [
"## Python builtins\n",
"## 파이썬 내장객체\n",
"\n",
"Access Python builtins via the global `Python` interface."
"Python의 전역 인터페이스를 활용해 Python 내장 객체에 진입합니다."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Python' should be translated into Korean.
And I suggest to replace '진입합니다' with '접근합니다' carefully.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I translated from 'Python' to '파이썬'

I changed it from '진입합니다' to '접근합니다'
I also think that's a more correct expression.

Thank you

]
},
{
Expand All @@ -389,10 +388,10 @@
}
],
"source": [
"// `Python.builtins` is a dictionary of all Python builtins.\n",
"// `Python.builtins`은 모든 파이썬 내장객체의 딕셔너리입니다.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just typo '내장객체' -> '내장 객체'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I Correctly fixed. ('내장객체' -> '내장 객체')

"_ = Python.builtins\n",
"\n",
"// Try some Python builtins.\n",
"// 파이썬 내장 객체를 시도합니다.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The literal translation of 'Try' seems to be not good.
I suggest to replace '시도합니다' with '사용합니다.'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced it from '시도합니다.' to '사용합니다.'

"print(Python.type(1))\n",
"print(Python.len([1, 2, 3]))\n",
"print(Python.sum([1, 2, 3]))"
Expand All @@ -405,9 +404,9 @@
"id": "H2wwUL1tY3JX"
},
"source": [
"## Importing Python modules\n",
"## 파이썬 모듈 임포트\n",
"\n",
"Use `Python.import` to import a Python module. It works like the `import` keyword in `Python`."
"`Python.import`를 사용하여 `Python` 모듈을 임포트합니다. 이것은 파이썬의 `import` 키워드처럼 동작합니다."
]
},
{
Expand Down Expand Up @@ -447,7 +446,7 @@
"id": "hQvza3dUXlr0"
},
"source": [
"Use the throwing function `Python.attemptImport` to perform safe importing."
"안전하게 패키지를 가져오기 위해 예외처리 함수 `Python.attemptImport`를 사용합니다."
]
},
{
Expand Down Expand Up @@ -483,16 +482,21 @@
"id": "Qej_Z6V3mZnG"
},
"source": [
"## Conversion with `numpy.ndarray`\n",
"## `numpy.ndarray`로 변환\n",
"\n",
"The following Swift types can be converted to and from `numpy.ndarray`:\n",
"- `Array<Element>`\n",
"- `ShapedArray<Scalar>`\n",
"- `Tensor<Scalar>`\n",
"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 487-491 is the English document and should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove them

"Conversion succeeds only if the `dtype` of the `numpy.ndarray` is compatible with the `Element` or `Scalar` generic parameter type.\n",
"다음 스위프트 유형은 `numpy.ndarray`로 변환할 수 있습니다.\n",
"- `Array<Element>`\n",
"- `ShapedArray<Scalar>`\n",
"- `Tensor<Scalar>`\n",
"\n",
"`Numpy.ndarray`의 `dtype`이 `Element` 또는 `Scalar`의 일반 파라미터 타입과 호환되어야만 변환이 성공합니다.\n",
"\n",
"For `Array`, conversion from `numpy` succeeds only if the `numpy.ndarray` is 1-D."
"`Array`의 경우 `numpy.ndarray`가 1-D일 경우에만 `numpy`에서 변환이 성공합니다."
]
},
{
Expand Down Expand Up @@ -551,17 +555,17 @@
}
],
"source": [
"// Examples of converting `numpy.ndarray` to Swift types.\n",
"// `numpy.ndarray`에서 스위프트 타입으로 변환하는 예제.\n",
"let array: [Float] = Array(numpy: numpyArray)!\n",
"let shapedArray = ShapedArray<Float>(numpy: numpyArray)!\n",
"let tensor = Tensor<Float>(numpy: numpyArray)!\n",
"\n",
"// Examples of converting Swift types to `numpy.ndarray`.\n",
"// 스위프트 타입에서 `numpy.ndarray`으로 변환하는 예제.\n",
"print(array.makeNumpyArray())\n",
"print(shapedArray.makeNumpyArray())\n",
"print(tensor.makeNumpyArray())\n",
"\n",
"// Examples with different dtypes.\n",
"// dtype이 다른 예제.\n",
"let doubleArray: [Double] = Array(numpy: np.ones([3], dtype: np.float))!\n",
"let intTensor = Tensor<Int32>(numpy: np.ones([2, 3], dtype: np.int32))!"
]
Expand All @@ -573,9 +577,9 @@
"id": "8EQFZZ5iafwh"
},
"source": [
"## Displaying images\n",
"## 이미지 표시\n",
"\n",
"You can display images in-line using `matplotlib`, just like in Python notebooks."
"파이썬 노트북에서처럼 `matplotlib`를 이용해 이미지를 일렬로 표시할 수 있습니다."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the meaning of 'in-line' might be 'same-line', 'same-page' or 'output line'
I suggest to replace '일렬로' with '같은 화면에' or '결과창에'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it '일렬로' to '결과 창에'

Thank you for information

]
},
{
Expand Down Expand Up @@ -617,7 +621,7 @@
}
],
"source": [
"// Setup.\n",
"// 세트 업.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to replace '세트 업' with '준비'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it from '세트 업' to '준비'

Thank you for letting me know about many changes.
After this translation, I will try to be better next time I participate.

"%include \"EnableIPythonDisplay.swift\"\n",
"IPythonDisplay.shell.enable_matplotlib(\"inline\")\n",
"\n",
Expand Down Expand Up @@ -651,15 +655,21 @@
"version": "0.3.2"
},
"kernelspec": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swift notebooks are a bit different than Python notebooks. You need to manually set the kernel to use Swift in Colab (there's not a UI option, yet).

See the original notebook (at the bottom): https://raw.githubusercontent.com/tensorflow/swift/master/docs/site/tutorials/python_interoperability.ipynb

I would recommend starting a translation by copying that notebook instead of starting a new one. These should execute in Colab.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta data has been modified for Swift.

Perhaps the kernel changed while checking on local notebook after work in colab

Thank you

"display_name": "Swift",
"language": "swift",
"name": "swift"
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"file_extension": ".swift",
"mimetype": "text/x-swift",
"name": "swift",
"version": ""
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down