Skip to content

Commit 461f3fd

Browse files
authored
Merge pull request #53952 from ashmaka/patch-14
[Cog Svcs] NER to Java quickstart
2 parents 0d6ea55 + cf1bf5f commit 461f3fd

File tree

1 file changed

+138
-43
lines changed
  • articles/cognitive-services/text-analytics/quickstarts

1 file changed

+138
-43
lines changed

articles/cognitive-services/text-analytics/quickstarts/java.md

Lines changed: 138 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ title: 'Quickstart: Using Java to call the Text Analytics API'
33
titleSuffix: Azure Cognitive Services
44
description: Get information and code samples to help you quickly get started using the Text Analytics API in Microsoft Cognitive Services on Azure.
55
services: cognitive-services
6-
author: ashmaka
6+
author: noellelacharite
77
manager: cgronlun
88

99
ms.service: cognitive-services
1010
ms.component: text-analytics
1111
ms.topic: quickstart
12-
ms.date: 09/12/2018
13-
ms.author: ashmaka
12+
ms.date: 10/01/2018
13+
ms.author: nolachar
1414
---
15-
1615
# Quickstart: Using Java to call the Text Analytics Cognitive Service
1716
<a name="HOLTop"></a>
1817

@@ -519,9 +518,9 @@ A successful response is returned in JSON, as shown in the following example:
519518
```
520519
<a name="Entities"></a>
521520

522-
## Identify linked entities
521+
## Identify entities
523522

524-
The Entity Linking API identifies well-known entities in a text document, using the [Entity Linking method](https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics.V2.0/operations/5ac4251d5b4ccd1554da7634). The following example identifies entities for English documents.
523+
The Entities API identifies well-known entities in a text document, using the [Entities method](https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-V2-1-Preview/operations/5ac4251d5b4ccd1554da7634). The following example identifies entities for English documents.
525524

526525
1. Create a new Java project in your favorite IDE.
527526
2. Add the code provided below.
@@ -594,7 +593,7 @@ public class GetEntities {
594593
// a free trial access key, you should not need to change this region.
595594
static String host = "https://westus.api.cognitive.microsoft.com";
596595

597-
static String path = "/text/analytics/v2.0/entities";
596+
static String path = "/text/analytics/v2.1-preview/entities";
598597

599598
public static String GetEntities (Documents documents) throws Exception {
600599
String text = new Gson().toJson(documents);
@@ -634,8 +633,8 @@ public class GetEntities {
634633
public static void main (String[] args) {
635634
try {
636635
Documents documents = new Documents ();
637-
documents.add ("1", "en", "I really enjoy the new XBox One S. It has a clean look, it has 4K/HDR resolution and it is affordable.");
638-
documents.add ("2", "en", "The Seattle Seahawks won the Super Bowl in 2014.");
636+
documents.add ("1", "en", "Jeff bought three dozen eggs because there was a 50% discount.");
637+
documents.add ("2", "en", "The Great Depression began in 1929. By 1933, the GDP in America fell by 25%.");
639638

640639
String response = GetEntities (documents);
641640
System.out.println (prettify (response));
@@ -646,67 +645,163 @@ public class GetEntities {
646645
}
647646
}
648647
```
649-
**Entity linking response**
648+
**Entity extraction response**
650649

651650
A successful response is returned in JSON, as shown in the following example:
652651

653652
```json
654653
{
655-
"documents": [
654+
"Documents": [
656655
{
657-
"id": "1",
658-
"entities": [
656+
"Id": "1",
657+
"Entities": [
659658
{
660-
"name": "Xbox One",
661-
"matches": [
659+
"Name": "Jeff",
660+
"Matches": [
662661
{
663-
"text": "XBox One",
664-
"offset": 23,
665-
"length": 8
662+
"Text": "Jeff",
663+
"Offset": 0,
664+
"Length": 4
666665
}
667666
],
668-
"wikipediaLanguage": "en",
669-
"wikipediaId": "Xbox One",
670-
"wikipediaUrl": "https://en.wikipedia.org/wiki/Xbox_One",
671-
"bingId": "446bb4df-4999-4243-84c0-74e0f6c60e75"
667+
"Type": "Person"
672668
},
673669
{
674-
"name": "Ultra-high-definition television",
675-
"matches": [
670+
"Name": "three dozen",
671+
"Matches": [
676672
{
677-
"text": "4K",
678-
"offset": 63,
679-
"length": 2
673+
"Text": "three dozen",
674+
"Offset": 12,
675+
"Length": 11
680676
}
681677
],
682-
"wikipediaLanguage": "en",
683-
"wikipediaId": "Ultra-high-definition television",
684-
"wikipediaUrl": "https://en.wikipedia.org/wiki/Ultra-high-definition_television",
685-
"bingId": "7ee02026-b6ec-878b-f4de-f0bc7b0ab8c4"
678+
"Type": "Quantity",
679+
"SubType": "Number"
680+
},
681+
{
682+
"Name": "50",
683+
"Matches": [
684+
{
685+
"Text": "50",
686+
"Offset": 49,
687+
"Length": 2
688+
}
689+
],
690+
"Type": "Quantity",
691+
"SubType": "Number"
692+
},
693+
{
694+
"Name": "50%",
695+
"Matches": [
696+
{
697+
"Text": "50%",
698+
"Offset": 49,
699+
"Length": 3
700+
}
701+
],
702+
"Type": "Quantity",
703+
"SubType": "Percentage"
686704
}
687705
]
688706
},
689707
{
690-
"id": "2",
691-
"entities": [
708+
"Id": "2",
709+
"Entities": [
710+
{
711+
"Name": "Great Depression",
712+
"Matches": [
713+
{
714+
"Text": "The Great Depression",
715+
"Offset": 0,
716+
"Length": 20
717+
}
718+
],
719+
"WikipediaLanguage": "en",
720+
"WikipediaId": "Great Depression",
721+
"WikipediaUrl": "https://en.wikipedia.org/wiki/Great_Depression",
722+
"BingId": "d9364681-98ad-1a66-f869-a3f1c8ae8ef8"
723+
},
724+
{
725+
"Name": "1929",
726+
"Matches": [
727+
{
728+
"Text": "1929",
729+
"Offset": 30,
730+
"Length": 4
731+
}
732+
],
733+
"Type": "DateTime",
734+
"SubType": "DateRange"
735+
},
736+
{
737+
"Name": "By 1933",
738+
"Matches": [
739+
{
740+
"Text": "By 1933",
741+
"Offset": 36,
742+
"Length": 7
743+
}
744+
],
745+
"Type": "DateTime",
746+
"SubType": "DateRange"
747+
},
748+
{
749+
"Name": "Gross domestic product",
750+
"Matches": [
751+
{
752+
"Text": "GDP",
753+
"Offset": 49,
754+
"Length": 3
755+
}
756+
],
757+
"WikipediaLanguage": "en",
758+
"WikipediaId": "Gross domestic product",
759+
"WikipediaUrl": "https://en.wikipedia.org/wiki/Gross_domestic_product",
760+
"BingId": "c859ed84-c0dd-e18f-394a-530cae5468a2"
761+
},
762+
{
763+
"Name": "United States",
764+
"Matches": [
765+
{
766+
"Text": "America",
767+
"Offset": 56,
768+
"Length": 7
769+
}
770+
],
771+
"WikipediaLanguage": "en",
772+
"WikipediaId": "United States",
773+
"WikipediaUrl": "https://en.wikipedia.org/wiki/United_States",
774+
"BingId": "5232ed96-85b1-2edb-12c6-63e6c597a1de",
775+
"Type": "Location"
776+
},
777+
{
778+
"Name": "25",
779+
"Matches": [
780+
{
781+
"Text": "25",
782+
"Offset": 72,
783+
"Length": 2
784+
}
785+
],
786+
"Type": "Quantity",
787+
"SubType": "Number"
788+
},
692789
{
693-
"name": "2013 Seattle Seahawks season",
694-
"matches": [
790+
"Name": "25%",
791+
"Matches": [
695792
{
696-
"text": "Seattle Seahawks",
697-
"offset": 4,
698-
"length": 16
793+
"Text": "25%",
794+
"Offset": 72,
795+
"Length": 3
699796
}
700797
],
701-
"wikipediaLanguage": "en",
702-
"wikipediaId": "2013 Seattle Seahawks season",
703-
"wikipediaUrl": "https://en.wikipedia.org/wiki/2013_Seattle_Seahawks_season",
704-
"bingId": "eb637865-4722-4eca-be9e-0ac0c376d361"
798+
"Type": "Quantity",
799+
"SubType": "Percentage"
705800
}
706801
]
707802
}
708803
],
709-
"errors": []
804+
"Errors": []
710805
}
711806
```
712807

0 commit comments

Comments
 (0)