@@ -39,12 +39,13 @@ public static void main(String[] args) throws Exception {
39
39
// The Google Cloud project id to use as a parent resource.
40
40
String projectId = "your-project-id" ;
41
41
// The string to de-identify.
42
- String textToInspect = "patient: quasimodo" ;
43
- inspectStringAugmentInfoType (projectId , textToInspect );
42
+ String textToInspect = "The patient's name is quasimodo" ;
43
+ String textToAugment = "quasimodo" ;
44
+ inspectStringAugmentInfoType (projectId , textToInspect , textToAugment );
44
45
}
45
46
46
47
// Inspects the provided text.
47
- public static void inspectStringAugmentInfoType (String projectId , String textToInspect )
48
+ public static void inspectStringAugmentInfoType (String projectId , String textToInspect , String textToAugment )
48
49
throws IOException {
49
50
// Initialize client that will be used to send requests. This client only needs to be created
50
51
// once, and can be reused for multiple requests. After completing all of your requests, call
@@ -62,11 +63,11 @@ public static void inspectStringAugmentInfoType(String projectId, String textToI
62
63
CustomInfoType .Dictionary wordList =
63
64
CustomInfoType .Dictionary .newBuilder ()
64
65
.setWordList (
65
- CustomInfoType .Dictionary .WordList .newBuilder ().addWords ("quasimodo" ).build ())
66
+ CustomInfoType .Dictionary .WordList .newBuilder ().addWords (textToAugment ).build ())
66
67
.build ();
67
68
68
69
InfoType infoType = InfoType .newBuilder ().setName ("PERSON_NAME" ).build ();
69
- // Construct the custom infotype detector associated with the word list.
70
+ // Construct a custom infotype detector by augmenting the PERSON_NAME detector with a word list
70
71
CustomInfoType customInfoType =
71
72
CustomInfoType .newBuilder ().setInfoType (infoType ).setDictionary (wordList ).build ();
72
73
0 commit comments