"Se você não está usando a aprendizagem profunda, deveria estar." - Jeff Dean, bolsista do Google.
O Google começou com a missão de capacitar tudo e todos com Inteligência Artificial (I.A.). Ele abriu o Tensorflow e as bibliotecas de suporte para permitir que os desenvolvedores e as empresas criem e treinem modelos e façam inferências (previsões) usando esses modelos. A criação de serviços empresariais úteis com isso pode levar tempo.
O Google também expôs muitos dos serviços de IA (por meio das APIs de aprendizado de máquina na nuvem) que podem ser bastante úteis em seus aplicativos. A extração de recursos e textos de imagens, a tradução de textos de um idioma para outro e a análise de sentimentos em textos podem ajudá-lo a melhorar drasticamente a experiência do usuário. Há novos negócios e modelos de negócios possibilitados apenas por esses serviços. O Google fez o trabalho árduo de criar e treinar o modelo. Você simplesmente chama uma API REST para explorar suas APIs de aprendizado de máquina. Essas APIs funcionam simplesmente como um método de invocação de serviço declarativo, sem a necessidade de entender ou manter a infraestrutura profunda subjacente.
Suas APIs de aprendizado de máquina incluem:
- E provavelmente muitos outros serviços até o momento em que este artigo for publicado.
Todos eles são fornecidos como APIs REST. Consulte o site do Google abaixo para obter a documentação e os detalhes do serviço.
No Couchbase 5.0, a engenheira de P&D da N1QL, Isha Kandaswamy, desenvolveu e escrito sobre a funcionalidade CURL(). Usando CURL(), você pode usar qualquer serviço REST com ponto de extremidade JSON. Um exemplo de uso de A API do mapa do Google é mostrada aqui. O resultado JSON dos serviços pode ser processado naturalmente no N1QL porque o N1QL foi projetado para ser SQL para JSON.
Observação: Você pode usar CURL(), usar A.I. ou outros serviços de qualquer serviço disponível publicamente.
Este blog mostra a maneira de usar a API de IA do Google Cloud diretamente nos dados que você tem no Couchbase, diretamente com uma simples instrução N1QL. Todas as APIs de aprendizado de máquina do Google Cloud retornam JSON. Portanto, CURL() pode ser usado para chamar qualquer um dos serviços. Mostrarei exemplos de uso da API do Google Vision, da API de tradução do Google e da API de linguagem natural do Google.
Observação: você precisa configurar seu projeto, ativar cada um dos serviços e obter a API-KEY que precisa passar. Nos exemplos abaixo, Retirei minha chave. Você deve substituir PUT YOUR KEY HERE por sua chave.

Vamos explorar o uso de algumas das APIs.
1. Usando API do Google Vision:
Você pode ser uma empresa de seguros em que os clientes fazem upload de fotos de seus carros e identificações. Você pode ser uma faculdade que recebe imagens de históricos escolares. Deseja extrair o texto da imagem para garantir a veracidade, melhorar a experiência do usuário e facilitar a pesquisa quando necessário.
O Google deixou de organizar o texto do mundo para organizar o conteúdo multimídia do mundo. A API Vision oferece recursos avançados para extrair muitos metadados de uma imagem e correlacionar essas informações com informações e outras imagens disponíveis na Web.

Vamos obter a análise completa da imagem usando a API do Google Vision.
|
1 2 3 4 5 6 7 |
select imagetext from curl("https://vision.googleapis.com/v1/images:annotate?key=PUT YOUR KEY HERE", {"request": "POST", "header":"Content-Type: application/json", "data": '{ "requests": [ { "image": { "source": { "imageUri": "https://www.couchbase.com/blog/wp-content/uploads/2018/01/Screen-Shot-2018-01-21-at-6.50.38-PM.png" } }, "features": [ { "type": "TEXT_DETECTION" } ] } ] }'}) AS imagetext |
Essa consulta retorna uma enorme resposta de 120K descrevendo todos os polígonos e textos associados. Aqui está a resposta. Vamos emitir a consulta novamente e projetar o que precisamos. A API Vision retorna a lista concatenada de cadeias de caracteres. Você pode usar a função SPLIT() ou TOKENS() do N1QL para obter cada string separadamente.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
select r.fullTextAnnotation.text from curl("https://vision.googleapis.com/v1/images:annotate?key=PUT YOUR KEY HERE", {"request": "POST", "header":"Content-Type: application/json", "data": '{ "requests": [ { "image": { "source": { "imageUri": "https://www.couchbase.com/blog/wp-content/uploads/2018/01/Screen-Shot-2018-01-21-at-6.50.38-PM.png" } }, "features": [ { "type": "TEXT_DETECTION" } ] } ] }'}) AS imagetext UNNEST imagetext.responses r ; { "requestID": "c1e41d74-2522-4de9-84ef-2730cae1aebc", "signature": { "text": "json" }, "results": [ { "text": "APPLICATION SERVER\nAPPLICATION SERVER\nCLIENT LIBRARY\nCLIENT LIBRARY\nSDK\nSDK\nCluster\nManager\nCluster\nManager\nCluster\nManager\nCluster\nManager\nCluster\nManager\nData\nService\nQuery\nService\nIndex\nService\nSearch\nService\nAnalytics\nService*\nManaged Cache\nStorage\nCouchbase Server 1\nManaged Cache\nStorage\nCouchbase Server 3\nManaged Cache\nStorage\nCouchbase Server 4\nManaged Cache\nStorage\nCouchbase Server\nCouchbase Server\nServer Cluster\n" } ], "status": "success", "metrics": { "elapsedTime": "1.906194164s", "executionTime": "1.906166141s", "resultCount": 1, "resultSize": 499 } } |
2. API de tradução do Google
Essa API faz o que diz: Traduzir de um idioma para outro. Ela pode detectar automaticamente o idioma de origem. Os argumentos para essa API são simplesmente o conteúdo de origem e o idioma de destino. Neste exemplo, vamos traduzir as avaliações de clientes de um hotel do inglês para o francês.
|
1 2 3 4 5 6 7 8 9 |
SELECT ginfo FROM ( SELECT r.content as english, curl("https://translation.googleapis.com/language/translate/v2?key=PUT YOUR KEYS HERE", {"request": "POST", "header":"Content-Type: application/json", "data": mydata }) AS french FROM `travel-sample` h USE KEYS "hotel_10142" UNNEST h.reviews r LET mydata = '{ "q":"' || r.content || '", "target": "fr"}') AS ginfo; |
O resultado da consulta, que inclui a tradução para o francês, é:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
{ "requestID": "a388a2a4-da40-42df-9af6-93a83f8f3cf1", "signature": { "ginfo": "json" }, "results": [ { "ginfo": { "english": "This has got to be the worse experience I have ever had at a hotel. Our reservation was placed two months in advance for a non-smoking room with two beds from July 2-7, 2010. We are staying five nights at $190 a night and this is what we got, a smoking room with one bed, and was only told at the front desk that it was going to be a smoking room, nothing about the one bed, when she asked us how many beds we needed, oh they provided a roll-a-way, only thing is I had to move the chair into the hallway to fit the bed. The t.v. was older than me and the speaker was shot. the bathroom was so small you have to step into the tub to close the door, no fridge in the room, doors are cheap and horrible. only sheets on the bed no blankets/quilts, plus on top of that, i had to pay $14.95 a night for internet. I will never recommend this hotel! how can you take a reservation and state that it will be held till 10am the following morning, yet not provide what was requested in the reservation? What if someone in my party was allergic to smoke, asthmatic, or worse... we wouldn't have gotten a room? completely unacceptable no wonder I will continue to stay at the comfort suites... free internet, modern amenities(flat screens) oh and $85 a night. unsatisfied doesn't even come close to how I feel. the only good thing out of this whole stay was the hot cookie when I got here and mine wasn't even hot. You can take that cookie and... well i'm sure you can figure out the rest. Thanx for nothing!", "french": { "data": { "translations": [ { "detectedSourceLanguage": "en", "translatedText": "Cela doit être la pire expérience que j'ai jamais eu dans un hôtel. Notre réservation a été placée deux mois à l'avance pour une chambre non-fumeurs avec deux lits du 2 au 7 juillet 2010. Nous restons cinq nuits à 190 $ la nuit et c'est ce que nous avons eu, une chambre fumeurs avec un lit, et On m'a seulement dit à la réception que ça allait être une chambre fumeur, rien à propos du lit, quand elle nous a demandé combien de lits nous avions besoin, oh ils ont fourni un roll-a-way, seule chose que je devais déplacer le Chaise dans le couloir pour s'adapter au lit. La télé était plus vieille que moi et l'orateur a été abattu. La salle de bain était si petite que vous devez marcher dans la baignoire pour fermer la porte, pas de frigo dans la chambre, les portes sont bon marché et horrible. seulement des draps sur le lit pas de couvertures / couettes, en plus de cela, j'ai dû payer 14,95 $ la nuit pour internet. Je ne recommanderai jamais cet hôtel! Comment pouvez-vous prendre une réservation et indiquer qu'il se tiendra jusqu'à 10 heures du matin le lendemain, mais ne pas fournir ce qui était demandé dans la réservation? Et si quelqu'un de mon groupe était allergique à la fumée, asthmatique ou pire ... nous n'aurions pas eu de chambre? complètement inacceptable pas étonnant je vais continuer à rester dans les suites de confort ... Internet gratuit, des équipements modernes (écrans plats) oh et 85 $ la nuit. insatisfait ne se rapproche même pas de ce que je ressens. La seule bonne chose de tout ce séjour était le cookie chaud quand je suis arrivé et le mien n'était même pas chaud. Vous pouvez prendre ce cookie et ... eh bien, je suis sûr que vous pouvez comprendre le reste. Merci pour rien!" } ] } } } }, { "ginfo": { "english": "OK - I booked this place about 8 weeks prior to travel, when the rooms were still $116 for a Saturday night on Doubletree/Hilton site. As the travel date drew close, I would reprice and the rate climbed to over $200. $116 was a bargain, but the place isn't worth $200. I had room 1022 - very small, some mildew on in the closet in the corner, and right down the hall from the housekeeping closets (they banged their doors day and night). The bed was comfortable and the staff was very courteous. I didn't know this when I booked the hotel, but I was thrilled to see it was at the same intersection as Harrah's Casino so I lost $50. The hotel is also right at a trolley car stop on Canal Street. $116 - yep, I'ld stay there again in a heartbeat. $200 - no can do. Book early and tolerate the inconveniences in exchange for a bargain price.", "french": { "data": { "translations": [ { "detectedSourceLanguage": "en", "translatedText": "D'accord, j'ai réservé cet hôtel environ 8 semaines avant de partir, quand les chambres étaient toujours 116 pour un samedi soir sur Doubletree / Hilton. Comme la date du voyage se rapprochait, je voudrais réévaluer et le taux a grimpé à plus de 200 $. 116 $ était une bonne affaire, mais l'endroit ne vaut pas 200 $. J'avais la chambre 1022 - très petite, un peu de moisissure dans le placard dans le coin, et juste dans le couloir des placards de ménage (ils ont frappé leurs portes jour et nuit). Le lit était confortable et le personnel était très courtois. Je ne savais pas cela quand j'ai réservé cet hôtel, mais j'ai été ravi de voir que c'était au même carrefour que Harrah's Casino, j'ai perdu 50 $. L'hôtel est également juste à côté d'un arrêt de tramway sur Canal Street. 116 $ - oui, j'y retournerais sans hésiter. 200 $ - ne peut pas faire. Réservez tôt et tolérer les inconvénients en échange d'un prix d'aubaine." } ] } } } }, { "ginfo": { "english": "I was impressed with my room and the great service I received at the front desk. I found the staff helpful and very pleasant. The location was great with easy walking distances to the French Quarter, other points of interest and great restaurants in the immediate area. Room service was on time and my breakfast arrived hot and ready to enjoy. I would recommend this hotel for the start of a great stay in Big Easy.", "french": { "data": { "translations": [ { "detectedSourceLanguage": "en", "translatedText": "J'ai été impressionné par ma chambre et le super service que j'ai reçu à la réception. J'ai trouvé le personnel serviable et très agréable. L'emplacement était génial, à quelques minutes de marche du quartier français, d'autres points d'intérêt et d'excellents restaurants dans les environs immédiats. Le service de chambre était à l'heure et mon petit déjeuner est arrivé chaud et prêt à profiter. Je recommande cet hôtel pour le début d'un excellent séjour à Big Easy." } ] } } } }, { "ginfo": { "english": "The hotel is located conveniently on Canal Street at the edge of the French Quarter near the river. When we arrived, the rooms were ready to go and checking was painless, the cookies were awesome! The louge downstairs was a good place to catch a drink before heading out each night. We were within walking distance to everything in the French Quarter and catching a cab in front of the hotel was easy. The trolley has a stop in front of the hotel, Harrah's is next door, the aquarium , the mall and a move theater are all across the street. The hotel restaurant was good, not the best considering it's New Orleans, but good for hotel food. I didn't have a car this trip, but you have to pay for parking in most places in the quarter. The pool is small, but nice to hang out at mid afternoon and there is a small gym for a quick work out. I've staryed in many places in the French Quarter over the years and this is one of the better experiences I have had. I was pleasantly suprizes at how much I liked the location.", "french": { "data": { "translations": [ { "detectedSourceLanguage": "en", "translatedText": "L'hôtel est idéalement situé sur Canal Street, au bord du quartier français près de la rivière. Quand nous sommes arrivés, les chambres étaient prêtes à partir et les formalités de départ étaient indolores, les cookies étaient géniaux! Le rez-de-chaussée était un bon endroit pour prendre un verre avant de partir chaque nuit. Nous étions à distance de marche de tout dans le quartier français et prendre un taxi en face de l'hôtel était facile. Le tramway s'arrête devant l'hôtel, Harrah est à côté, l'aquarium, le centre commercial et un théâtre de déménagement sont tous de l'autre côté de la rue. Le restaurant de l'hôtel était bien, pas le meilleur étant donné que c'est la Nouvelle-Orléans, mais bon pour la nourriture de l'hôtel. Je n'avais pas de voiture ce voyage, mais vous devez payer pour le stationnement dans la plupart des endroits dans le quartier. La piscine est petite, mais agréable de sortir en milieu d'après-midi et il y a une petite salle de gym pour faire du sport. Je me suis entretenu dans de nombreux endroits dans le quartier français au cours des années et c'est l'une des meilleures expériences que j'ai eu. J'ai été agréablement suprizes à quel point j'ai aimé l'emplacement." } ] } } } }, { "ginfo": { "english": "The Doubltree is located near so many attractions, we hardly ever needed a cab the whole time we were there. Clean rooms that were well maintained were a treat to come home to after a long day. I never experienced one issue or problem the entire time I was there, from a warm a welcoming check-in (with a great cookie!) to an efficent check-out. I would certainly reccomend the hotel to anyone I knew that was traveling to the Big Easy.", "french": { "data": { "translations": [ { "detectedSourceLanguage": "en", "translatedText": "Le Doubltree est situé près de tant d'attractions, nous n'avons presque jamais eu besoin d'un taxi pendant tout notre séjour. Les chambres propres qui étaient bien entretenues étaient un régal pour rentrer à la maison après une longue journée. Je n'ai jamais connu un problème ou problème tout le temps où j'étais là-bas, d'un accueil chaleureux (avec un bon cookie!) À un départ efficace. Je recommanderais cet hôtel à tous ceux que je connaissais qui voyageaient au Big Easy." } ] } } } }, { "ginfo": { "english": "We stayed at the Doubletree Hotel New Orleans for the first time on February 14, 2009. The good: check in was quick, the rooms were comfortable and very clean. I forgot some amenities and staff were very quick to respond with bringing up what I needed. All staff were very polite. One bad: the walls are paper thin, you can literally hear every word in the rooms next to you and in the hallway. I would stay here again for the ideal location, but if you need a good nights rest, reconsider due to noise.", "french": { "data": { "translations": [ { "detectedSourceLanguage": "en", "translatedText": "Nous avons séjourné au Doubletree Hotel New Orleans pour la première fois le 14 février 2009. Le bon: l'enregistrement a été rapide, les chambres étaient confortables et très propres. J'ai oublié quelques équipements et le personnel était très rapide pour répondre à ce que j'ai besoin de ce dont j'avais besoin. Tout le personnel était très poli. Un mauvais: les murs sont très fins, vous pouvez littéralement entendre chaque mot dans les chambres à côté de vous et dans le couloir. Je reviendrais ici pour l'emplacement idéal, mais si vous avez besoin de bonnes nuits de repos, reconsidérer à cause du bruit." } ] } } } } ], "status": "success", "metrics": { "elapsedTime": "3.604491133s", "executionTime": "3.604475374s", "resultCount": 6, "resultSize": 13090 } } |
Como não entendo bem francês, pedi que traduzissem a avaliação para Kannada, minha língua materna. Devo dizer que a tradução foi decente para uma máquina. Algumas frases eram complicadas (quase pareciam Kannada antigo), mas no geral eram compreensíveis. Aqui está a tradução.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
> SELECT ginfo FROM ( select r.content, curl("https://translation.googleapis.com/language/translate/v2?key=PUT YOUR KEY HERE", {"request": "POST", "header":"Content-Type: application/json", "data": mydata }) as kannada from `travel-sample` h use keys "hotel_10142" unnest h.reviews r LET mydata = '{ "q":"' || r.content || '", "source": "en", "target": "kn"}') ginfo; { "requestID": "079f9dba-2da2-4941-b1be-70865997ec51", "signature": { "ginfo": "json" }, "results": [ { "ginfo": { "content": "This has got to be the worse experience I have ever had at a hotel. Our reservation was placed two months in advance for a non-smoking room with two beds from July 2-7, 2010. We are staying five nights at $190 a night and this is what we got, a smoking room with one bed, and was only told at the front desk that it was going to be a smoking room, nothing about the one bed, when she asked us how many beds we needed, oh they provided a roll-a-way, only thing is I had to move the chair into the hallway to fit the bed. The t.v. was older than me and the speaker was shot. the bathroom was so small you have to step into the tub to close the door, no fridge in the room, doors are cheap and horrible. only sheets on the bed no blankets/quilts, plus on top of that, i had to pay $14.95 a night for internet. I will never recommend this hotel! how can you take a reservation and state that it will be held till 10am the following morning, yet not provide what was requested in the reservation? What if someone in my party was allergic to smoke, asthmatic, or worse... we wouldn't have gotten a room? completely unacceptable no wonder I will continue to stay at the comfort suites... free internet, modern amenities(flat screens) oh and $85 a night. unsatisfied doesn't even come close to how I feel. the only good thing out of this whole stay was the hot cookie when I got here and mine wasn't even hot. You can take that cookie and... well i'm sure you can figure out the rest. Thanx for nothing!", "kannada": { "data": { "translations": [ { "translatedText": "ಹೋಟೆಲ್ನಲ್ಲಿ ನಾನು ಹೊಂದಿದ್ದ ಕೆಟ್ಟ ಅನುಭವ ಎಂದು ಇದು ತಿಳಿದು ಬಂದಿದೆ. ನಮ್ಮ ಕಾಯ್ದಿರಿಸುವಿಕೆ ಎರಡು ತಿಂಗಳ ಮುಂಚಿತವಾಗಿ ಜುಲೈ 2, 7 ರಿಂದ 2010 ರವರೆಗೆ ಎರಡು ಹಾಸಿಗೆಯೊಂದಿಗೆ ಧೂಮಪಾನ ಕೊಠಡಿಯನ್ನು ಇರಿಸಿದೆ. ನಾವು ರಾತ್ರಿಗೆ $ 190 ಗೆ ಐದು ರಾತ್ರಿಗಳು ಇರುತ್ತಿದ್ದೇವೆ ಮತ್ತು ಇದು ನಮಗೆ ಸಿಕ್ಕಿತು, ಒಂದು ಹಾಸಿಗೆಯೊಂದಿಗೆ ಧೂಮಪಾನ ಕೊಠಡಿ, ಕೇವಲ ಮುಂಭಾಗದ ಮೇಜಿನ ಬಳಿ ಅದು ಧೂಮಪಾನ ಕೊಠಡಿ ಎಂದು ಹೇಳುತ್ತಿದ್ದೆವು, ಒಂದು ಹಾಸಿಗೆಯ ಬಗ್ಗೆ ಏನೂ ಇಲ್ಲ, ನಮಗೆ ಎಷ್ಟು ಹಾಸಿಗೆಗಳು ಬೇಕಾಗಿವೆ ಎಂದು ಕೇಳಿದಾಗ, ಅವರು ರೋಲ್-ಎ-ವೇವನ್ನು ಒದಗಿಸಿದರು, ಕೇವಲ ವಿಷಯ ನಾನು ಹಾಸಿಗೆಯನ್ನು ಹೊಂದಲು ಹಜಾರದ ಒಳಗೆ ಕುರ್ಚಿ. ಟಿವಿ ನನ್ನಂತೆಯೇ ಹಳೆಯದು ಮತ್ತು ಸ್ಪೀಕರ್ ಚಿತ್ರೀಕರಿಸಲಾಯಿತು. ಬಾತ್ರೂಮ್ ಚಿಕ್ಕದಾಗಿದೆ, ಬಾಗಿಲನ್ನು ಮುಚ್ಚಲು ನೀವು ಟಬ್ಬಿನೊಳಗೆ ಹೆಜ್ಜೆ ಹಾಕಬೇಕು, ಕೋಣೆಯಲ್ಲಿ ಯಾವುದೇ ಫ್ರಿಜ್ ಇಲ್ಲ, ಬಾಗಿಲು ಅಗ್ಗವಾಗಿದ್ದು ಭಯಾನಕವಾಗಿದೆ. ಹಾಸಿಗೆಯ ಮೇಲೆ ಮಾತ್ರ ಹಾಳೆಗಳು ಕಂಬಳಿಗಳು / ಕ್ವಿಲ್ಟ್ಸ್ ಮಾತ್ರವಲ್ಲ, ಅದರ ಮೇಲೆ, ನಾನು ಅಂತರ್ಜಾಲಕ್ಕಾಗಿ $ 14.95 ರಷ್ಟು ಹಣವನ್ನು ಪಾವತಿಸಬೇಕಾಯಿತು. ನಾನು ಈ ಹೋಟೆಲ್ಗೆ ಎಂದಿಗೂ ಶಿಫಾರಸು ಮಾಡುವುದಿಲ್ಲ! ಮುಂದಿನ ದಿನ ಬೆಳಿಗ್ಗೆ 10 ಗಂಟೆಗೆ ನಡೆಯಲಿದೆ ಎಂದು ಮೀಸಲಾತಿ ಮತ್ತು ರಾಜ್ಯವನ್ನು ನೀವು ಹೇಗೆ ತೆಗೆದುಕೊಳ್ಳಬಹುದು, ಆದರೆ ಮೀಸಲಾತಿಯಲ್ಲಿ ಏನು ವಿನಂತಿಸಲಾಗಿದೆ? ನನ್ನ ಪಾರ್ಟಿಯಲ್ಲಿ ಯಾರೋ ಹೊಗೆ, ಅಸ್ತಮ, ಅಥವಾ ಕೆಟ್ಟದ್ದಕ್ಕೆ ಅಲರ್ಜಿಯಾಗಿದ್ದರೆ ... ನಾವು ಒಂದು ಕೊಠಡಿಯನ್ನು ಪಡೆದಿರಲಿಲ್ಲವೆ? ಸಂಪೂರ್ಣವಾಗಿ ಸ್ವೀಕಾರಾರ್ಹವಲ್ಲ ಯಾವುದೇ ಆಶ್ಚರ್ಯ ನಾನು ಸೌಕರ್ಯಗಳಿಗೆ ಕೋಣೆಗಳು ನಲ್ಲಿ ಉಳಿಯಲು ಮುಂದುವರಿಯುತ್ತದೆ ... ಉಚಿತ ಇಂಟರ್ನೆಟ್, ಆಧುನಿಕ ಸೌಕರ್ಯಗಳು (ಫ್ಲಾಟ್ ಪರದೆಗಳು) ಓಹ್ ಮತ್ತು $ 85 ಒಂದು ರಾತ್ರಿ. ಅತೃಪ್ತರಾಗಿದ್ದರೂ ನಾನು ಹೇಗೆ ಭಾವಿಸುತ್ತೇನೆ ಎಂಬುದರ ಹತ್ತಿರ ಬರುವುದಿಲ್ಲ. ನಾನು ಇಲ್ಲಿಗೆ ಬಂದಾಗ ಮತ್ತು ಗಣಿ ಕೂಡ ಬಿಸಿಯಾಗಿರಲಿಲ್ಲವಾದ್ದರಿಂದ ಈ ಸಂಪೂರ್ಣ ವಾಸ್ತವ್ಯದಲ್ಲೇ ಇರುವ ಏಕೈಕ ಒಳ್ಳೆಯದು ಬಿಸಿ ಕುಕೀ. ನೀವು ಆ ಕುಕೀ ತೆಗೆದುಕೊಳ್ಳಬಹುದು ಮತ್ತು ... ಚೆನ್ನಾಗಿ ಉಳಿದಿರುವುದನ್ನು ನೀವು ಲೆಕ್ಕಾಚಾರ ಮಾಡಬಹುದು ಎಂದು ನನಗೆ ಖಾತ್ರಿಯಿದೆ. ಥಾಂಕ್ಸ್ ಏನೂ ಇಲ್ಲ!" } ] } } } }, { "ginfo": { "content": "OK - I booked this place about 8 weeks prior to travel, when the rooms were still $116 for a Saturday night on Doubletree/Hilton site. As the travel date drew close, I would reprice and the rate climbed to over $200. $116 was a bargain, but the place isn't worth $200. I had room 1022 - very small, some mildew on in the closet in the corner, and right down the hall from the housekeeping closets (they banged their doors day and night). The bed was comfortable and the staff was very courteous. I didn't know this when I booked the hotel, but I was thrilled to see it was at the same intersection as Harrah's Casino so I lost $50. The hotel is also right at a trolley car stop on Canal Street. $116 - yep, I'ld stay there again in a heartbeat. $200 - no can do. Book early and tolerate the inconveniences in exchange for a bargain price.", "kannada": { "data": { "translations": [ { "translatedText": "ಸರಿ - ಈ ಸ್ಥಳವು ಪ್ರಯಾಣಕ್ಕೆ 8 ವಾರಗಳ ಮುಂಚಿತವಾಗಿ, ಶನಿವಾರ ರಾತ್ರಿ ಡಬಲ್ಟ್ರೀ / ಹಿಲ್ಟನ್ ಸೈಟ್ನಲ್ಲಿ ಕೊಠಡಿಗಳು ಇನ್ನೂ $ 116 ಆಗಿದ್ದಾಗ ನಾನು ಈ ಸ್ಥಳವನ್ನು ಗೊತ್ತು ಮಾಡಿದೆ. ಪ್ರಯಾಣದ ದಿನಾಂಕ ಹತ್ತಿರ ಬಂದಾಗ, ನಾನು ಮರುಪಾವತಿ ಮಾಡುತ್ತೇನೆ ಮತ್ತು ದರವು $ 200 ಕ್ಕಿಂತ ಹೆಚ್ಚಿದೆ. $ 116 ಒಂದು ಚೌಕಾಶಿಯಾಗಿತ್ತು, ಆದರೆ ಸ್ಥಳವು $ 200 ಮೌಲ್ಯದ್ದಾಗಿಲ್ಲ. ನಾನು ಕೋಣೆ 1022 ಅನ್ನು ಹೊಂದಿದ್ದೆ - ಬಹಳ ಚಿಕ್ಕದಾದ, ಕೆಲವು ಮೂಲೆಯಲ್ಲಿರುವ ಶಿಲೀಂಧ್ರ, ಮನೆಮನೆಯ ಮುಚ್ಚುಮರೆಯಿಂದ ಹಾಲ್ ಕೆಳಗೆ ಬಿದ್ದ (ಅವರು ದಿನ ಮತ್ತು ರಾತ್ರಿ ತಮ್ಮ ಬಾಗಿಲುಗಳನ್ನು ಹೊಡೆಯುತ್ತಿದ್ದರು). ಹಾಸಿಗೆ ಆರಾಮದಾಯಕ ಮತ್ತು ಸಿಬ್ಬಂದಿ ಬಹಳ ವಿನಯಶೀಲರಾಗಿದ್ದರು. ನಾನು ಹೋಟೆಲ್ ಅನ್ನು ಬುಕ್ ಮಾಡುತ್ತಿರುವಾಗ ನಾನು ಇದನ್ನು ತಿಳಿದಿರಲಿಲ್ಲ, ಆದರೆ ಇದು ಹಾರ್ರಾಹ್ ಕ್ಯಾಸಿನೊದಲ್ಲಿ ಅದೇ ಛೇದಕದಲ್ಲಿದೆ ಎಂದು ನನಗೆ ಥ್ರಿಲ್ಡ್ ಮಾಡಲಾಯಿತು, ಹಾಗಾಗಿ ನಾನು $ 50 ಕಳೆದುಕೊಂಡೆ. ಕಾನಾಲ್ ಸ್ಟ್ರೀಟ್ನಲ್ಲಿರುವ ಟ್ರಾಲಿ ಕಾರ್ ಸ್ಟಾಪ್ನಲ್ಲಿ ಹೋಟೆಲ್ ಸಹ ಸರಿಯಾಗಿದೆ. $ 116 - ಹೌದು, ನಾನು ಮತ್ತೆ ಹೃದಯ ಬಡಿತದಲ್ಲಿ ಇರುತ್ತೇನೆ. $ 200 - ಇಲ್ಲ. ಚೌಕಾಶಿ ಬೆಲೆಗೆ ವಿನಿಮಯವಾಗಿ ಅನನುಕೂಲತೆಗಳನ್ನು ಪ್ರಾರಂಭಿಸಿ ಮತ್ತು ಸಹಿಸಿಕೊಳ್ಳಿ." } ] } } } }, { "ginfo": { "content": "I was impressed with my room and the great service I received at the front desk. I found the staff helpful and very pleasant. The location was great with easy walking distances to the French Quarter, other points of interest and great restaurants in the immediate area. Room service was on time and my breakfast arrived hot and ready to enjoy. I would recommend this hotel for the start of a great stay in Big Easy.", "kannada": { "data": { "translations": [ { "translatedText": "ನನ್ನ ಕೊಠಡಿ ಮತ್ತು ನಾನು ಮುಂಭಾಗದ ಮೇಜಿನ ಬಳಿ ಪಡೆದ ಅತ್ಯುತ್ತಮ ಸೇವೆಯಿಂದ ಪ್ರಭಾವಿತನಾಗಿದ್ದೆ. ನಾನು ಸಿಬ್ಬಂದಿ ಸಹಾಯಕವಾಗಿದೆಯೆ ಮತ್ತು ಅತ್ಯಂತ ಆಹ್ಲಾದಕರ ಎಂದು ಕಂಡುಬಂದಿಲ್ಲ. ಈ ಸ್ಥಳವು ಫ್ರೆಂಚ್ ಕ್ವಾರ್ಟರ್ಗೆ ಸುಲಭ ವಾಕಿಂಗ್ ದೂರದೊಂದಿಗೆ, ಇತರ ಪ್ರದೇಶದ ಆಸಕ್ತಿಗಳು ಮತ್ತು ತಕ್ಷಣದ ಪ್ರದೇಶದ ದೊಡ್ಡ ರೆಸ್ಟೊರೆಂಟ್ಗಳೊಂದಿಗೆ ಉತ್ತಮವಾಗಿತ್ತು. ರೂಮ್ ಸೇವೆಯು ಸಮಯಕ್ಕೆ ಇತ್ತು ಮತ್ತು ನನ್ನ ಉಪಹಾರವು ಬಿಸಿಯಾಗಿ ಬಂದು ಆನಂದಿಸಲು ಸಿದ್ಧವಾಗಿದೆ. ಬಿಗ್ ಈಸಿನಲ್ಲಿ ಉತ್ತಮ ವಾಸ್ತವ್ಯದ ಪ್ರಾರಂಭಕ್ಕಾಗಿ ನಾನು ಈ ಹೋಟೆಲ್ ಅನ್ನು ಶಿಫಾರಸು ಮಾಡಿದ್ದೇನೆ." } ] } } } }, { "ginfo": { "content": "The hotel is located conveniently on Canal Street at the edge of the French Quarter near the river. When we arrived, the rooms were ready to go and checking was painless, the cookies were awesome! The louge downstairs was a good place to catch a drink before heading out each night. We were within walking distance to everything in the French Quarter and catching a cab in front of the hotel was easy. The trolley has a stop in front of the hotel, Harrah's is next door, the aquarium , the mall and a move theater are all across the street. The hotel restaurant was good, not the best considering it's New Orleans, but good for hotel food. I didn't have a car this trip, but you have to pay for parking in most places in the quarter. The pool is small, but nice to hang out at mid afternoon and there is a small gym for a quick work out. I've staryed in many places in the French Quarter over the years and this is one of the better experiences I have had. I was pleasantly suprizes at how much I liked the location.", "kannada": { "data": { "translations": [ { "translatedText": "ನದಿಯ ಬಳಿ ಫ್ರೆಂಚ್ ಕ್ವಾರ್ಟರ್ನ ಅಂಚಿನಲ್ಲಿರುವ ಕಾನಾಲ್ ಸ್ಟ್ರೀಟ್ನಲ್ಲಿ ಈ ಹೋಟೆಲ್ ಅನುಕೂಲಕರವಾಗಿ ಇದೆ. ನಾವು ಬಂದಾಗ ಕೊಠಡಿಗಳು ಹೋಗಲು ಸಿದ್ಧವಾಗಿದ್ದವು ಮತ್ತು ನೋವುರಹಿತವಾಗಿದ್ದವು, ಕುಕೀಗಳು ಮನಮೋಹಕವಾಗಿತ್ತು! ಪ್ರತಿ ರಾತ್ರಿ ಶಿರೋನಾಮೆ ಮಾಡುವ ಮೊದಲು ಪಾನೀಯವನ್ನು ಹಿಡಿಯಲು ಉತ್ತಮ ಸ್ಥಳವಾಗಿದೆ. ನಾವು ಫ್ರೆಂಚ್ ಕ್ವಾರ್ಟರ್ನಲ್ಲಿ ಎಲ್ಲದರ ಕಡೆಗೆ ನಡೆಯುತ್ತಿದ್ದೆವು ಮತ್ತು ಹೋಟೆಲ್ ಮುಂದೆ ಕ್ಯಾಬ್ ಅನ್ನು ಹಿಡಿಯುವುದು ಸುಲಭವಾಗಿದೆ. ಹೋಟೆಲ್ ಮುಂದೆ ಮುಂಭಾಗದಲ್ಲಿ ಟ್ರಾಲಿಯು ನಿಲ್ಲುತ್ತದೆ, ಹರ್ರಾಹ್ಸ್ ಮುಂದಿನ ಬಾಗಿಲು, ಅಕ್ವೇರಿಯಂ, ಮಾಲ್ ಮತ್ತು ಚಲಿಸುವ ಥಿಯೇಟರ್ ಎಲ್ಲಾ ಬೀದಿಗಳಲ್ಲಿದೆ. ಹೊಟೇಲ್ ರೆಸ್ಟೊರೆಂಟ್ ಒಳ್ಳೆಯದು, ಅದು ನ್ಯೂ ಒರ್ಲಿಯನ್ಸ್ ಅನ್ನು ಪರಿಗಣಿಸಿಲ್ಲ, ಆದರೆ ಹೋಟೆಲ್ ಆಹಾರಕ್ಕೆ ಉತ್ತಮವಾಗಿದೆ. ನಾನು ಈ ಟ್ರಿಪ್ ಅನ್ನು ಹೊಂದಿಲ್ಲ, ಆದರೆ ಕಾಲುಭಾಗದಲ್ಲಿ ಹೆಚ್ಚಿನ ಸ್ಥಳಗಳಲ್ಲಿ ನೀವು ಪಾರ್ಕಿಂಗ್ಗೆ ಪಾವತಿಸಬೇಕಾಗುತ್ತದೆ. ಪೂಲ್ ಚಿಕ್ಕದಾಗಿದೆ, ಆದರೆ ಮಧ್ಯ ಮಧ್ಯಾಹ್ನ ಹ್ಯಾಂಗ್ ಔಟ್ ಮಾಡಲು ಉತ್ತಮವಾಗಿದೆ ಮತ್ತು ತ್ವರಿತ ಕೆಲಸಕ್ಕಾಗಿ ಸಣ್ಣ ಜಿಮ್ ಇರುತ್ತದೆ. ನಾನು ವರ್ಷಗಳಲ್ಲಿ ಫ್ರೆಂಚ್ ಕ್ವಾರ್ಟರ್ನಲ್ಲಿ ಅನೇಕ ಸ್ಥಳಗಳಲ್ಲಿ ನಿಂತಿರುತ್ತೇನೆ ಮತ್ತು ನಾನು ಹೊಂದಿದ್ದ ಉತ್ತಮ ಅನುಭವಗಳಲ್ಲಿ ಒಂದಾಗಿದೆ. ನಾನು ಸ್ಥಳವನ್ನು ಎಷ್ಟು ಇಷ್ಟಪಟ್ಟಿದ್ದೇನೆಂದರೆ ನನಗೆ ಸಂತೋಷಕರವಾದ ಕೊಡುಗೆಯಾಗಿದೆ." } ] } } } }, { "ginfo": { "content": "The Doubltree is located near so many attractions, we hardly ever needed a cab the whole time we were there. Clean rooms that were well maintained were a treat to come home to after a long day. I never experienced one issue or problem the entire time I was there, from a warm a welcoming check-in (with a great cookie!) to an efficent check-out. I would certainly reccomend the hotel to anyone I knew that was traveling to the Big Easy.", "kannada": { "data": { "translations": [ { "translatedText": "ಡಬಲ್ಟ್ರೀ ಹಲವಾರು ಆಕರ್ಷಣೆಗಳ ಬಳಿ ಇದೆ, ನಾವು ಅಲ್ಲಿದ್ದ ಸಂಪೂರ್ಣ ಸಮಯಕ್ಕೆ ಕ್ಯಾಬ್ಗೆ ಬೇಕಾಗಲಿಲ್ಲ. ಸುದೀರ್ಘ ಕಾಲದ ನಂತರ ಮನೆಗೆ ಬರಲು ಒಂದು ಸತ್ಕಾರದ ವಿಧಾನವನ್ನು ಚೆನ್ನಾಗಿ ನಿರ್ವಹಿಸಲಾಗಿರುವ ಸ್ವಚ್ಛ ಕೊಠಡಿಗಳು. ನಾನು ಅಲ್ಲಿದ್ದ ಸಂಪೂರ್ಣ ಸಮಯದ ಒಂದು ಸಮಸ್ಯೆಯನ್ನು ಅಥವಾ ಸಮಸ್ಯೆಯನ್ನು ನಾನು ಅನುಭವಿಸಲಿಲ್ಲ, ಬೆಚ್ಚಗಿನ ಸ್ವಾಗತ ಪರಿಶೀಲನೆಯಿಂದ (ಉತ್ತಮ ಕುಕಿ ಯೊಂದಿಗೆ) ಪರಿಣಾಮಕಾರಿ ಚೆಕ್-ಔಟ್ಗೆ. ನಾನು ಬಿಗ್ ಈಸಿಗೆ ಹೋಗುತ್ತಿದ್ದೇನೆ ಎಂದು ನಾನು ತಿಳಿದಿರುವ ಎಲ್ಲರಿಗೂ ಹೋಟೆಲ್ ಅನ್ನು ಖಂಡಿತವಾಗಿಯೂ ಮರುಸಂಗ್ರಹಿಸುತ್ತೇನೆ." } ] } } } }, { "ginfo": { "content": "We stayed at the Doubletree Hotel New Orleans for the first time on February 14, 2009. The good: check in was quick, the rooms were comfortable and very clean. I forgot some amenities and staff were very quick to respond with bringing up what I needed. All staff were very polite. One bad: the walls are paper thin, you can literally hear every word in the rooms next to you and in the hallway. I would stay here again for the ideal location, but if you need a good nights rest, reconsider due to noise.", "kannada": { "data": { "translations": [ { "translatedText": "ಫೆಬ್ರುವರಿ 14, 2009 ರಂದು ನಾವು ಮೊದಲ ಬಾರಿಗೆ ಡಬ್ಟ್ರೀ ಹೋಟೆಲ್ ನ್ಯೂ ಓರ್ಲಿಯನ್ಸ್ನಲ್ಲಿ ನೆಲೆಸಿದ್ದೇವೆ. ಒಳ್ಳೆಯದು: ಚೆಕ್ ಇನ್ ತ್ವರಿತವಾಗಿದ್ದು, ಕೊಠಡಿಗಳು ಆರಾಮದಾಯಕ ಮತ್ತು ಸ್ವಚ್ಛವಾಗಿರುತ್ತವೆ. ನಾನು ಅಗತ್ಯವಿರುವದನ್ನು ತರುವುದರೊಂದಿಗೆ ಪ್ರತಿಕ್ರಿಯಿಸಲು ನಾನು ಕೆಲವು ಸೌಲಭ್ಯಗಳನ್ನು ಮತ್ತು ಸಿಬ್ಬಂದಿಗಳನ್ನು ಶೀಘ್ರವಾಗಿ ಮರೆತಿದ್ದೇನೆ. ಎಲ್ಲಾ ಸಿಬ್ಬಂದಿಗಳು ತುಂಬಾ ಮನೋಭಾವ ಹೊಂದಿದ್ದರು. ಒಂದು ಕಳಪೆ: ಗೋಡೆಗಳು ಕಾಗದದ ತೆಳುವಾದವು, ನಿಮಗೆ ಮುಂದಿನ ಮತ್ತು ಹಜಾರದ ಕೋಣೆಗಳಲ್ಲಿ ಪ್ರತಿಯೊಂದು ಶಬ್ದವನ್ನೂ ನೀವು ಅಕ್ಷರಶಃ ಕೇಳಬಹುದು. ನಾನು ಸೂಕ್ತ ಸ್ಥಳಕ್ಕಾಗಿ ಮತ್ತೆ ಇಲ್ಲಿಯೇ ಇರುತ್ತೇನೆ, ಆದರೆ ನಿಮಗೆ ಒಳ್ಳೆಯ ರಾತ್ರಿಗಳು ಬೇಕಾಗಿದ್ದರೆ, ಶಬ್ದದ ಕಾರಣದಿಂದಾಗಿ ಮರುಪರಿಶೀಲಿಸಿ." } ] } } } } ], "status": "success", "metrics": { "elapsedTime": "3.604226917s", "executionTime": "3.604175923s", "resultCount": 6, "resultSize": 20088 } } |
3. API de linguagem natural do Google
A API de linguagem natural faz análise de sentimentos, análise de entidades, analisa a intenção e muito mais. Você pode invocar esses serviços apenas alterando os parâmetros do serviço.
Vamos usar os dados de avaliações de hotéis, que de fato têm algum conteúdo emocional!
|
1 2 3 4 5 6 7 8 9 10 |
SELECT ginfo.review, ginfo.sentscore.documentSentiment.magnitude, ginfo.sentscore.documentSentiment.score FROM ( SELECT r.content AS review, curl("https://language.googleapis.com/v1/documents:analyzeSentiment?key=PUT YOUR KEY HERE", {"request": "POST", "header":"Content-Type: application/json", "data": mydata }) AS sentscore FROM `travel-sample` h USE KEYS "hotel_10142" UNNEST h.reviews r LET mydata = '{ "encodingType": "UTF8", "document": { "type": "PLAIN_TEXT", "content":"' || r.content || '"} }' ) ginfo |
Projetamos apenas os campos que nos interessam aqui: avaliação, magnitude e pontuação de sentimento. Consulte os documentos do Google para obter uma descrição completa do significado desses campos e do restante dos dados gerados.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
{ "requestID": "c7b66165-3d18-4a61-8b24-732afdd4714a", "signature": { "magnitude": "json", "review": "json", "score": "json" }, "results": [ { "magnitude": 8.7, "review": "This has got to be the worse experience I have ever had at a hotel. Our reservation was placed two months in advance for a non-smoking room with two beds from July 2-7, 2010. We are staying five nights at $190 a night and this is what we got, a smoking room with one bed, and was only told at the front desk that it was going to be a smoking room, nothing about the one bed, when she asked us how many beds we needed, oh they provided a roll-a-way, only thing is I had to move the chair into the hallway to fit the bed. The t.v. was older than me and the speaker was shot. the bathroom was so small you have to step into the tub to close the door, no fridge in the room, doors are cheap and horrible. only sheets on the bed no blankets/quilts, plus on top of that, i had to pay $14.95 a night for internet. I will never recommend this hotel! how can you take a reservation and state that it will be held till 10am the following morning, yet not provide what was requested in the reservation? What if someone in my party was allergic to smoke, asthmatic, or worse... we wouldn't have gotten a room? completely unacceptable no wonder I will continue to stay at the comfort suites... free internet, modern amenities(flat screens) oh and $85 a night. unsatisfied doesn't even come close to how I feel. the only good thing out of this whole stay was the hot cookie when I got here and mine wasn't even hot. You can take that cookie and... well i'm sure you can figure out the rest. Thanx for nothing!", "score": -0.4 }, { "magnitude": 4.1, "review": "OK - I booked this place about 8 weeks prior to travel, when the rooms were still $116 for a Saturday night on Doubletree/Hilton site. As the travel date drew close, I would reprice and the rate climbed to over $200. $116 was a bargain, but the place isn't worth $200. I had room 1022 - very small, some mildew on in the closet in the corner, and right down the hall from the housekeeping closets (they banged their doors day and night). The bed was comfortable and the staff was very courteous. I didn't know this when I booked the hotel, but I was thrilled to see it was at the same intersection as Harrah's Casino so I lost $50. The hotel is also right at a trolley car stop on Canal Street. $116 - yep, I'ld stay there again in a heartbeat. $200 - no can do. Book early and tolerate the inconveniences in exchange for a bargain price.", "score": 0.1 }, { "magnitude": 4.5, "review": "I was impressed with my room and the great service I received at the front desk. I found the staff helpful and very pleasant. The location was great with easy walking distances to the French Quarter, other points of interest and great restaurants in the immediate area. Room service was on time and my breakfast arrived hot and ready to enjoy. I would recommend this hotel for the start of a great stay in Big Easy.", "score": 0.9 }, { "magnitude": 5.9, "review": "The hotel is located conveniently on Canal Street at the edge of the French Quarter near the river. When we arrived, the rooms were ready to go and checking was painless, the cookies were awesome! The louge downstairs was a good place to catch a drink before heading out each night. We were within walking distance to everything in the French Quarter and catching a cab in front of the hotel was easy. The trolley has a stop in front of the hotel, Harrah's is next door, the aquarium , the mall and a move theater are all across the street. The hotel restaurant was good, not the best considering it's New Orleans, but good for hotel food. I didn't have a car this trip, but you have to pay for parking in most places in the quarter. The pool is small, but nice to hang out at mid afternoon and there is a small gym for a quick work out. I've staryed in many places in the French Quarter over the years and this is one of the better experiences I have had. I was pleasantly suprizes at how much I liked the location.", "score": 0.5 }, { "magnitude": 3.3, "review": "The Doubltree is located near so many attractions, we hardly ever needed a cab the whole time we were there. Clean rooms that were well maintained were a treat to come home to after a long day. I never experienced one issue or problem the entire time I was there, from a warm a welcoming check-in (with a great cookie!) to an efficent check-out. I would certainly reccomend the hotel to anyone I knew that was traveling to the Big Easy.", "score": 0.8 }, { "magnitude": 3.8, "review": "We stayed at the Doubletree Hotel New Orleans for the first time on February 14, 2009. The good: check in was quick, the rooms were comfortable and very clean. I forgot some amenities and staff were very quick to respond with bringing up what I needed. All staff were very polite. One bad: the walls are paper thin, you can literally hear every word in the rooms next to you and in the hallway. I would stay here again for the ideal location, but if you need a good nights rest, reconsider due to noise.", "score": 0.5 } ], "status": "success", "metrics": { "elapsedTime": "3.905025161s", "executionTime": "3.893259752s", "resultCount": 6, "resultSize": 5256 } } |
A API de linguagem natural do Google também pode extrair entidades e suas referências na Web. Vamos dar uma olhada em um exemplo disso também.
|
1 2 3 4 5 6 7 8 9 10 |
SELECT ginfo FROM ( SELECT name, content, curl("https://language.googleapis.com/v1/documents:analyzeEntities?key=PUT YOUR KEY HERE", {"request": "POST", "header":"Content-Type: application/json", "data": mydata }) AS sentscore FROM `travel-sample` l USE KEYS "landmark_10087" LET mydata = '{ "encodingType": "UTF8", "document": { "type": "PLAIN_TEXT", "content":"' || l.name || " " || l.content || '"} }' ) ginfo |
A API de análise de entidades identifica corretamente o local e nos fornece as referências da Web (URLs) para o ponto de referência. Quando as referências não são muito específicas, como as William Team Rooms aqui, a API pode fornecer referências genéricas de alto nível.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
{ "requestID": "4e104224-fe2d-43a8-b86f-aca371987d75", "signature": { "ginfo": "json" }, "results": [ { "ginfo": { "content": "During the temperance movement, the idea of "tearooms", places where you could relax and enjoy non-alcoholic refreshments in differently themed rooms, became popular in Glasgow. This one, designed by Charles Rennie Mackintosh in 1904, was the most popular of its time and has been lovingly restored.", "name": "Willow Tea Rooms", "sentscore": { "entities": [ { "mentions": [ { "text": { "beginOffset": 0, "content": "Willow Tea Rooms" }, "type": "PROPER" }, { "text": { "beginOffset": 83, "content": "places" }, "type": "COMMON" } ], "metadata": { "mid": "/m/0cpvtc", "wikipedia_url": "https://en.wikipedia.org/wiki/Willow_Tearooms" }, "name": "Willow Tea Rooms", "salience": 0.45414653, "type": "LOCATION" }, { "mentions": [ { "text": { "beginOffset": 28, "content": "temperance movement" }, "type": "COMMON" } ], "metadata": {}, "name": "temperance movement", "salience": 0.18415423, "type": "EVENT" }, { "mentions": [ { "text": { "beginOffset": 53, "content": "idea" }, "type": "COMMON" } ], "metadata": {}, "name": "idea", "salience": 0.075759985, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 61, "content": """ }, "type": "COMMON" } ], "metadata": {}, "name": """, "salience": 0.075759985, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 171, "content": "rooms" }, "type": "COMMON" } ], "metadata": {}, "name": "rooms", "salience": 0.059097562, "type": "LOCATION" }, { "mentions": [ { "text": { "beginOffset": 136, "content": "refreshments" }, "type": "COMMON" } ], "metadata": {}, "name": "refreshments", "salience": 0.051312122, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 67, "content": "tearooms"" }, "type": "PROPER" } ], "metadata": { "mid": "/g/11b6hv7vlz", "wikipedia_url": "https://en.wikipedia.org/wiki/Tearoom_(UK_and_US)" }, "name": "tearooms"", "salience": 0.045740306, "type": "ORGANIZATION" }, { "mentions": [ { "text": { "beginOffset": 196, "content": "Glasgow" }, "type": "PROPER" } ], "metadata": { "mid": "/m/0hyxv", "wikipedia_url": "https://en.wikipedia.org/wiki/Glasgow" }, "name": "Glasgow", "salience": 0.028563324, "type": "LOCATION" }, { "mentions": [ { "text": { "beginOffset": 275, "content": "popular" }, "type": "COMMON" } ], "metadata": {}, "name": "popular", "salience": 0.02095558, "type": "OTHER" }, { "mentions": [ { "text": { "beginOffset": 227, "content": "Charles Rennie Mackintosh" }, "type": "PROPER" } ], "metadata": { "mid": "/m/0f7tt", "wikipedia_url": "https://en.wikipedia.org/wiki/Charles_Rennie_Mackintosh" }, "name": "Charles Rennie Mackintosh", "salience": 0.0045103845, "type": "PERSON" } ], "language": "en" } } } ], "status": "success", "metrics": { "elapsedTime": "158.149783ms", "executionTime": "158.101909ms", "resultCount": 1, "resultSize": 8125 } } |
Resumo:
Os aplicativos Couchbase N1QL podem usar facilmente as APIs de aprendizado de máquina do Google para melhorar a experiência do cliente. O CURL() oferece um método flexível para usar os serviços de IA não apenas do Google, mas também de outros fornecedores. Experimente.
Referências:
1. N1QL: https://docs.couchbase.com/server/5.5/n1ql/n1ql-language-reference/index.html
2. Documentação do CURL(): https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/curl.html
3. CURL chega ao N1QL: https://dzone.com/articles/curl-comes-to-n1ql-querying-external-json-data