[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393625=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393625
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 17:17
Start Date: 26/Feb/20 17:17
Worklog Time Spent: 10m 
  Work Description: aaltay commented on pull request #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881
 
 
   
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393625)
Time Spent: 3h 20m  (was: 3h 10m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
> Fix For: 2.20.0
>
>  Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393542=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393542
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 15:06
Start Date: 26/Feb/20 15:06
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-591473122
 
 
   Retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393542)
Time Spent: 3h 10m  (was: 3h)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393540=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393540
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 15:02
Start Date: 26/Feb/20 15:02
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-591470896
 
 
   Retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393540)
Time Spent: 3h  (was: 2h 50m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 3h
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393538=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393538
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 15:01
Start Date: 26/Feb/20 15:01
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-591470319
 
 
   Retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393538)
Time Spent: 2h 50m  (was: 2h 40m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393396=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393396
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 12:12
Start Date: 26/Feb/20 12:12
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-591395081
 
 
   retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393396)
Time Spent: 2h 40m  (was: 2.5h)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393394=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393394
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 11:59
Start Date: 26/Feb/20 11:59
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-591390366
 
 
   retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393394)
Time Spent: 2.5h  (was: 2h 20m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393392=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393392
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 11:59
Start Date: 26/Feb/20 11:59
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-591390366
 
 
   retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393392)
Time Spent: 2h 10m  (was: 2h)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393393=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393393
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 11:59
Start Date: 26/Feb/20 11:59
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-591390429
 
 
   retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393393)
Time Spent: 2h 20m  (was: 2h 10m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393346=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393346
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 26/Feb/20 10:35
Start Date: 26/Feb/20 10:35
Worklog Time Spent: 10m 
  Work Description: kamilwu commented on pull request #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#discussion_r384407327
 
 

 ##
 File path: sdks/python/apache_beam/ml/gcp/naturallanguageml.py
 ##
 @@ -0,0 +1,156 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from __future__ import absolute_import
+
+from typing import Dict
+from typing import Mapping
+from typing import Optional
+from typing import Sequence
+from typing import Tuple
+from typing import Union
+
+import apache_beam as beam
+from apache_beam.metrics import Metrics
+
+try:
+  from google.cloud import language
+  from google.cloud.language import enums  # pylint: disable=unused-import
+  from google.cloud.language import types
+except ImportError:
+  raise ImportError(
+  'Google Cloud Natural Language API not supported for this execution '
+  'environment (could not import Natural Language API client).')
+
+__all__ = ['Document', 'Feature', 'AnnotateText']
+
+
+class Document(object):
+  """Represents the input to :class:`AnnotateText` transform.
+
+  Args:
+content (str): The content of the input or the Google Cloud Storage URI
+  where the file is stored.
+type (`Union[str, google.cloud.language.enums.Document.Type]`): Text type.
+  Possible values are `HTML`, `PLAIN_TEXT`. The default value is
+  `PLAIN_TEXT`.
+language_hint (`Optional[str]`): The language of the text. If not 
specified,
+  language will be automatically detected. Values should conform to
+  ISO-639-1 standard.
+encoding (`Optional[str]`): Text encoding. Possible values are: `NONE`,
+ `UTF8`, `UTF16`, `UTF32`. The default value is `UTF8`.
+from_gcs (bool): Whether the content should be interpret as a Google Cloud
+  Storage URI. The default value is :data:`False`.
+  """
+
+  def __init__(
+  self,
+  content,  # type: str
+  type='PLAIN_TEXT',  # type: Union[str, enums.Document.Type]
+  language_hint=None,  # type: Optional[str]
+  encoding='UTF8',  # type: Optional[str]
+  from_gcs=False  # type: bool
+  ):
+self.content = content
+self.type = type
+self.encoding = encoding
+self.language_hint = language_hint
+self.from_gcs = from_gcs
+
+  @staticmethod
+  def to_dict(document):
+# type: (Document) -> Mapping[str, Optional[str]]
+if document.from_gcs:
+  dict_repr = {'gcs_content_uri': document.content}
+else:
+  dict_repr = {'content': document.content}
+dict_repr.update({
+'type': document.type, 'language': document.language_hint
+})
+return dict_repr
+
+
+class Feature(object):
+  EXTRACT_SYNTAX = 'extract_syntax'
+  EXTRACT_ENTITIES = 'extract_entities'
+  EXTRACT_DOCUMENT_SENTIMENT = 'extract_document_sentiment'
+  EXTRACT_ENTITY_SENTIMENT = 'extract_entity_sentiment'
+  CLASSIFY_TEXT = 'classify_text'
+
+  @staticmethod
+  def to_dict(features):
 
 Review comment:
   Yes, the client library has `Features` protobuf message that can used. In 
that case, I'll just remove my `Feature` class and update type annotations. 
Thanks.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393346)
Time Spent: 2h  (was: 1h 50m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: 

[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-25 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=393003=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-393003
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 25/Feb/20 22:15
Start Date: 25/Feb/20 22:15
Worklog Time Spent: 10m 
  Work Description: udim commented on issue #10881: [BEAM-9248] Integrate 
Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-591098432
 
 
   Sorry I was too busy to respond
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 393003)
Time Spent: 1h 50m  (was: 1h 40m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-25 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=392824=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-392824
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 25/Feb/20 18:40
Start Date: 25/Feb/20 18:40
Worklog Time Spent: 10m 
  Work Description: aaltay commented on pull request #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#discussion_r384051123
 
 

 ##
 File path: sdks/python/apache_beam/ml/gcp/naturallanguageml.py
 ##
 @@ -0,0 +1,156 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from __future__ import absolute_import
+
+from typing import Dict
+from typing import Mapping
+from typing import Optional
+from typing import Sequence
+from typing import Tuple
+from typing import Union
+
+import apache_beam as beam
+from apache_beam.metrics import Metrics
+
+try:
+  from google.cloud import language
+  from google.cloud.language import enums  # pylint: disable=unused-import
+  from google.cloud.language import types
+except ImportError:
+  raise ImportError(
+  'Google Cloud Natural Language API not supported for this execution '
+  'environment (could not import Natural Language API client).')
+
+__all__ = ['Document', 'Feature', 'AnnotateText']
+
+
+class Document(object):
+  """Represents the input to :class:`AnnotateText` transform.
+
+  Args:
+content (str): The content of the input or the Google Cloud Storage URI
+  where the file is stored.
+type (`Union[str, google.cloud.language.enums.Document.Type]`): Text type.
+  Possible values are `HTML`, `PLAIN_TEXT`. The default value is
+  `PLAIN_TEXT`.
+language_hint (`Optional[str]`): The language of the text. If not 
specified,
+  language will be automatically detected. Values should conform to
+  ISO-639-1 standard.
+encoding (`Optional[str]`): Text encoding. Possible values are: `NONE`,
+ `UTF8`, `UTF16`, `UTF32`. The default value is `UTF8`.
+from_gcs (bool): Whether the content should be interpret as a Google Cloud
+  Storage URI. The default value is :data:`False`.
+  """
+
+  def __init__(
+  self,
+  content,  # type: str
+  type='PLAIN_TEXT',  # type: Union[str, enums.Document.Type]
+  language_hint=None,  # type: Optional[str]
+  encoding='UTF8',  # type: Optional[str]
+  from_gcs=False  # type: bool
+  ):
+self.content = content
+self.type = type
+self.encoding = encoding
+self.language_hint = language_hint
+self.from_gcs = from_gcs
+
+  @staticmethod
+  def to_dict(document):
+# type: (Document) -> Mapping[str, Optional[str]]
+if document.from_gcs:
+  dict_repr = {'gcs_content_uri': document.content}
+else:
+  dict_repr = {'content': document.content}
+dict_repr.update({
+'type': document.type, 'language': document.language_hint
+})
+return dict_repr
+
+
+class Feature(object):
+  EXTRACT_SYNTAX = 'extract_syntax'
+  EXTRACT_ENTITIES = 'extract_entities'
+  EXTRACT_DOCUMENT_SENTIMENT = 'extract_document_sentiment'
+  EXTRACT_ENTITY_SENTIMENT = 'extract_entity_sentiment'
+  CLASSIFY_TEXT = 'classify_text'
+
+  @staticmethod
+  def to_dict(features):
 
 Review comment:
   What happens if features are not on the above list? Do we need to keep and 
maintain an updated list?
   
   Does the client library has a list of these?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 392824)
Time Spent: 1h 40m  (was: 1.5h)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: 

[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-25 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=392822=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-392822
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 25/Feb/20 18:40
Start Date: 25/Feb/20 18:40
Worklog Time Spent: 10m 
  Work Description: aaltay commented on pull request #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#discussion_r384051123
 
 

 ##
 File path: sdks/python/apache_beam/ml/gcp/naturallanguageml.py
 ##
 @@ -0,0 +1,156 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from __future__ import absolute_import
+
+from typing import Dict
+from typing import Mapping
+from typing import Optional
+from typing import Sequence
+from typing import Tuple
+from typing import Union
+
+import apache_beam as beam
+from apache_beam.metrics import Metrics
+
+try:
+  from google.cloud import language
+  from google.cloud.language import enums  # pylint: disable=unused-import
+  from google.cloud.language import types
+except ImportError:
+  raise ImportError(
+  'Google Cloud Natural Language API not supported for this execution '
+  'environment (could not import Natural Language API client).')
+
+__all__ = ['Document', 'Feature', 'AnnotateText']
+
+
+class Document(object):
+  """Represents the input to :class:`AnnotateText` transform.
+
+  Args:
+content (str): The content of the input or the Google Cloud Storage URI
+  where the file is stored.
+type (`Union[str, google.cloud.language.enums.Document.Type]`): Text type.
+  Possible values are `HTML`, `PLAIN_TEXT`. The default value is
+  `PLAIN_TEXT`.
+language_hint (`Optional[str]`): The language of the text. If not 
specified,
+  language will be automatically detected. Values should conform to
+  ISO-639-1 standard.
+encoding (`Optional[str]`): Text encoding. Possible values are: `NONE`,
+ `UTF8`, `UTF16`, `UTF32`. The default value is `UTF8`.
+from_gcs (bool): Whether the content should be interpret as a Google Cloud
+  Storage URI. The default value is :data:`False`.
+  """
+
+  def __init__(
+  self,
+  content,  # type: str
+  type='PLAIN_TEXT',  # type: Union[str, enums.Document.Type]
+  language_hint=None,  # type: Optional[str]
+  encoding='UTF8',  # type: Optional[str]
+  from_gcs=False  # type: bool
+  ):
+self.content = content
+self.type = type
+self.encoding = encoding
+self.language_hint = language_hint
+self.from_gcs = from_gcs
+
+  @staticmethod
+  def to_dict(document):
+# type: (Document) -> Mapping[str, Optional[str]]
+if document.from_gcs:
+  dict_repr = {'gcs_content_uri': document.content}
+else:
+  dict_repr = {'content': document.content}
+dict_repr.update({
+'type': document.type, 'language': document.language_hint
+})
+return dict_repr
+
+
+class Feature(object):
+  EXTRACT_SYNTAX = 'extract_syntax'
+  EXTRACT_ENTITIES = 'extract_entities'
+  EXTRACT_DOCUMENT_SENTIMENT = 'extract_document_sentiment'
+  EXTRACT_ENTITY_SENTIMENT = 'extract_entity_sentiment'
+  CLASSIFY_TEXT = 'classify_text'
+
+  @staticmethod
+  def to_dict(features):
 
 Review comment:
   What happens if features are not on the above list? Do we need to keep and 
maintain an updated list?
   
   Does the client library has a list of thise?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 392822)
Time Spent: 1.5h  (was: 1h 20m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: 

[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-25 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=392479=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-392479
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 25/Feb/20 11:11
Start Date: 25/Feb/20 11:11
Worklog Time Spent: 10m 
  Work Description: kamilwu commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-590814622
 
 
   R: @aaltay 
   cc: @mwalenia 
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 392479)
Time Spent: 1h 20m  (was: 1h 10m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-25 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=392467=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-392467
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 25/Feb/20 10:39
Start Date: 25/Feb/20 10:39
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-590801457
 
 
   Run Python 2 PostCommit
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 392467)
Time Spent: 1h 10m  (was: 1h)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=390578=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-390578
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 21/Feb/20 11:11
Start Date: 21/Feb/20 11:11
Worklog Time Spent: 10m 
  Work Description: kamilwu commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-589609577
 
 
   @udim Pinging kindly. If you don't have time right now, just let me know and 
I'll assign somebody else. Thank you.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 390578)
Time Spent: 1h  (was: 50m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=390558=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-390558
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 21/Feb/20 10:34
Start Date: 21/Feb/20 10:34
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-589596797
 
 
   retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 390558)
Time Spent: 50m  (was: 40m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 50m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=390557=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-390557
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 21/Feb/20 10:33
Start Date: 21/Feb/20 10:33
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-589596433
 
 
   retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 390557)
Time Spent: 40m  (was: 0.5h)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-17 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=388360=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-388360
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 17/Feb/20 12:12
Start Date: 17/Feb/20 12:12
Worklog Time Spent: 10m 
  Work Description: kamilwu commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-586966167
 
 
   R: @udim Can I ask you for a review?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 388360)
Time Spent: 0.5h  (was: 20m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-17 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=388301=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-388301
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 17/Feb/20 10:08
Start Date: 17/Feb/20 10:08
Worklog Time Spent: 10m 
  Work Description: mwalenia commented on issue #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881#issuecomment-586914645
 
 
   retest this please
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 388301)
Time Spent: 20m  (was: 10m)

> [Python] PTransform that integrates Cloud Natural Language functionality
> 
>
> Key: BEAM-9248
> URL: https://issues.apache.org/jira/browse/BEAM-9248
> Project: Beam
>  Issue Type: Sub-task
>  Components: io-py-gcp
>Reporter: Kamil Wasilewski
>Assignee: Kamil Wasilewski
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> The goal is to create a PTransform that integrates Google Cloud Natural 
> Language API functionality [1].
> [1] https://cloud.google.com/natural-language/docs/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (BEAM-9248) [Python] PTransform that integrates Cloud Natural Language functionality

2020-02-17 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9248?focusedWorklogId=388265=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-388265
 ]

ASF GitHub Bot logged work on BEAM-9248:


Author: ASF GitHub Bot
Created on: 17/Feb/20 09:11
Start Date: 17/Feb/20 09:11
Worklog Time Spent: 10m 
  Work Description: kamilwu commented on pull request #10881: [BEAM-9248] 
Integrate Google Cloud Natural Language functionality for Python SDK
URL: https://github.com/apache/beam/pull/10881
 
 
   
   
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
- [ ] [**Choose 
reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and 
mention them in a comment (`R: @username`).
- [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA 
issue, if applicable. This will automatically link the pull request to the 
issue.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   Post-Commit Tests Status (on master branch)
   

   
   Lang | SDK | Apex | Dataflow | Flink | Gearpump | Samza | Spark
   --- | --- | --- | --- | --- | --- | --- | ---
   Go | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/)
 | --- | --- | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/)
 | --- | --- | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/)
   Java | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/)
   Python | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/)[![Build