Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-107279

Unable to generate tags with the Google Natural Language service: too few tokens

    Details

      Description

      The minimum number of tokens Google's API method classifyText, which Liferay uses to classify content in a document*,* defines for a text to be auto-tagged is 20: https://cloud.google.com/natural-language/docs/basics#content-classification

      Then if we try to auto-tag shorter content, an exception occurs.

      Steps to reproduce:

      1. Enable auto-tagging for Web Contents. (https://portal.liferay.dev/docs/7-2/user/-/knowledge_base/u/auto-tagging-text)
      2. Create a structure "test" adding an html field.
      3. Create a "test" Web Content, setting "hello" in the html field. Publish it.

      Expected result: The Web Content is created without any errors.

      Current result: the following error is thrown in the console:

      2020-01-17 12:31:54.868 ERROR [liferay/asset_auto_tagger-4][GCloudNaturalLanguageDocumentAssetAutoTagProvider:69] com.liferay.portal.kernel.exception.PortalException: Unable to generate tags with the Google Natural Language service. Response code 400: Invalid text content: too few tokens (words) to process.
      com.liferay.portal.kernel.exception.PortalException: Unable to generate tags with the Google Natural Language service. Response code 400: Invalid text content: too few tokens (words) to process.
       at com.liferay.asset.auto.tagger.google.cloud.natural.language.internal.GCloudNaturalLanguageDocumentAssetAutoTaggerImpl._post(GCloudNaturalLanguageDocumentAssetAutoTaggerImpl.java:240)
       at com.liferay.asset.auto.tagger.google.cloud.natural.language.internal.GCloudNaturalLanguageDocumentAssetAutoTaggerImpl._getClassificationTagNames(GCloudNaturalLanguageDocumentAssetAutoTaggerImpl.java:146)
       at com.liferay.asset.auto.tagger.google.cloud.natural.language.internal.GCloudNaturalLanguageDocumentAssetAutoTaggerImpl.getTagNames(GCloudNaturalLanguageDocumentAssetAutoTaggerImpl.java:108)
       at com.liferay.asset.auto.tagger.google.cloud.natural.language.internal.GCloudNaturalLanguageDocumentAssetAutoTagProvider.getTagNames(GCloudNaturalLanguageDocumentAssetAutoTagProvider.java:60)
       at com.liferay.asset.auto.tagger.google.cloud.natural.language.internal.GCloudNaturalLanguageDocumentAssetAutoTagProvider.getTagNames(GCloudNaturalLanguageDocumentAssetAutoTagProvider.java:40)
       at com.liferay.asset.auto.tagger.internal.AssetAutoTaggerImpl._getAutoAssetTagNames(AssetAutoTaggerImpl.java:162)
       at com.liferay.asset.auto.tagger.internal.AssetAutoTaggerImpl.tag(AssetAutoTaggerImpl.java:67)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
       at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
       at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
       at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
       at com.sun.proxy.$Proxy694.tag(Unknown Source)
       at com.liferay.asset.auto.tagger.internal.messaging.AssetAutoTaggerMessageListener.doReceive(AssetAutoTaggerMessageListener.java:41)
       at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:26)
       at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:74)
       at com.liferay.portal.messaging.internal.ParallelDestination$1.run(ParallelDestination.java:56)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       at java.lang.Thread.run(Thread.java:748)

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                16 weeks, 1 day ago

                Packages

                Version Package
                7.2.10 DXP FP5
                7.2.10.2 DXP SP2
                7.2.X
                7.3.1 CE GA2
                7.3.2 CE GA3
                Master