diff --git a/Language/metadata/V1/LanguageService.php b/Language/metadata/V1/LanguageService.php new file mode 100644 index 000000000000..99ffa96e160e --- /dev/null +++ b/Language/metadata/V1/LanguageService.php @@ -0,0 +1,284 @@ +internalAddGeneratedFile(hex2bin( + "0af53c0a2f676f6f676c652f636c6f75642f6c616e67756167652f76312f" . + "6c616e67756167655f736572766963652e70726f746f1218676f6f676c65" . + "2e636c6f75642e6c616e67756167652e763122c3010a08446f63756d656e" . + "7412350a047479706518012001280e32272e676f6f676c652e636c6f7564" . + "2e6c616e67756167652e76312e446f63756d656e742e5479706512110a07" . + "636f6e74656e74180220012809480012190a0f6763735f636f6e74656e74" . + "5f757269180320012809480012100a086c616e6775616765180420012809" . + "22360a045479706512140a10545950455f554e5350454349464945441000" . + "120e0a0a504c41494e5f54455854100112080a0448544d4c100242080a06" . + "736f7572636522740a0853656e74656e636512300a047465787418012001" . + "280b32222e676f6f676c652e636c6f75642e6c616e67756167652e76312e" . + "546578745370616e12360a0973656e74696d656e7418022001280b32232e" . + "676f6f676c652e636c6f75642e6c616e67756167652e76312e53656e7469" . + "6d656e7422ff030a06456e74697479120c0a046e616d6518012001280912" . + "330a047479706518022001280e32252e676f6f676c652e636c6f75642e6c" . + "616e67756167652e76312e456e746974792e5479706512400a086d657461" . + "6461746118032003280b322e2e676f6f676c652e636c6f75642e6c616e67" . + "756167652e76312e456e746974792e4d65746164617461456e7472791210" . + "0a0873616c69656e636518042001280212390a086d656e74696f6e731805" . + "2003280b32272e676f6f676c652e636c6f75642e6c616e67756167652e76" . + "312e456e746974794d656e74696f6e12360a0973656e74696d656e741806" . + "2001280b32232e676f6f676c652e636c6f75642e6c616e67756167652e76" . + "312e53656e74696d656e741a2f0a0d4d65746164617461456e747279120b" . + "0a036b6579180120012809120d0a0576616c75651802200128093a023801" . + "22b9010a0454797065120b0a07554e4b4e4f574e1000120a0a0650455253" . + "4f4e1001120c0a084c4f434154494f4e100212100a0c4f5247414e495a41" . + "54494f4e100312090a054556454e541004120f0a0b574f524b5f4f465f41" . + "5254100512110a0d434f4e53554d45525f474f4f44100612090a054f5448" . + "4552100712100a0c50484f4e455f4e554d4245521009120b0a0741444452" . + "455353100a12080a0444415445100b120a0a064e554d424552100c12090a" . + "055052494345100d22cb010a05546f6b656e12300a047465787418012001" . + "280b32222e676f6f676c652e636c6f75642e6c616e67756167652e76312e" . + "546578745370616e123e0a0e706172745f6f665f73706565636818022001" . + "280b32262e676f6f676c652e636c6f75642e6c616e67756167652e76312e" . + "506172744f6653706565636812410a0f646570656e64656e63795f656467" . + "6518032001280b32282e676f6f676c652e636c6f75642e6c616e67756167" . + "652e76312e446570656e64656e637945646765120d0a056c656d6d611804" . + "20012809222d0a0953656e74696d656e7412110a096d61676e6974756465" . + "180220012802120d0a0573636f726518032001280222a3100a0c50617274" . + "4f6653706565636812370a0374616718012001280e322a2e676f6f676c65" . + "2e636c6f75642e6c616e67756167652e76312e506172744f665370656563" . + "682e546167123d0a0661737065637418022001280e322d2e676f6f676c65" . + "2e636c6f75642e6c616e67756167652e76312e506172744f665370656563" . + "682e41737065637412390a046361736518032001280e322b2e676f6f676c" . + "652e636c6f75642e6c616e67756167652e76312e506172744f6653706565" . + "63682e4361736512390a04666f726d18042001280e322b2e676f6f676c65" . + "2e636c6f75642e6c616e67756167652e76312e506172744f665370656563" . + "682e466f726d123d0a0667656e64657218052001280e322d2e676f6f676c" . + "652e636c6f75642e6c616e67756167652e76312e506172744f6653706565" . + "63682e47656e64657212390a046d6f6f6418062001280e322b2e676f6f67" . + "6c652e636c6f75642e6c616e67756167652e76312e506172744f66537065" . + "6563682e4d6f6f64123d0a066e756d62657218072001280e322d2e676f6f" . + "676c652e636c6f75642e6c616e67756167652e76312e506172744f665370" . + "656563682e4e756d626572123d0a06706572736f6e18082001280e322d2e" . + "676f6f676c652e636c6f75642e6c616e67756167652e76312e506172744f" . + "665370656563682e506572736f6e123d0a0670726f70657218092001280e" . + "322d2e676f6f676c652e636c6f75642e6c616e67756167652e76312e5061" . + "72744f665370656563682e50726f70657212470a0b7265636970726f6369" . + "7479180a2001280e32322e676f6f676c652e636c6f75642e6c616e677561" . + "67652e76312e506172744f665370656563682e5265636970726f63697479" . + "123b0a0574656e7365180b2001280e322c2e676f6f676c652e636c6f7564" . + "2e6c616e67756167652e76312e506172744f665370656563682e54656e73" . + "65123b0a05766f696365180c2001280e322c2e676f6f676c652e636c6f75" . + "642e6c616e67756167652e76312e506172744f665370656563682e566f69" . + "6365228d010a03546167120b0a07554e4b4e4f574e100012070a0341444a" . + "100112070a03414450100212070a03414456100312080a04434f4e4a1004" . + "12070a03444554100512080a044e4f554e100612070a034e554d10071208" . + "0a0450524f4e100812070a03505254100912090a0550554e4354100a1208" . + "0a0456455242100b12050a0158100c12090a054146464958100d224f0a06" . + "41737065637412120a0e4153504543545f554e4b4e4f574e1000120e0a0a" . + "50455246454354495645100112100a0c494d504552464543544956451002" . + "120f0a0b50524f4752455353495645100322f8010a044361736512100a0c" . + "434153455f554e4b4e4f574e1000120e0a0a414343555341544956451001" . + "120d0a0941445645524249414c100212110a0d434f4d504c454d454e5449" . + "56451003120a0a064441544956451004120c0a0847454e49544956451005" . + "12100a0c494e535452554d454e54414c1006120c0a084c4f434154495645" . + "1007120e0a0a4e4f4d494e41544956451008120b0a074f424c4951554510" . + "09120d0a09504152544954495645100a12110a0d505245504f534954494f" . + "4e414c100b12120a0e5245464c45584956455f43415345100c12110a0d52" . + "454c41544956455f43415345100d120c0a08564f434154495645100e22af" . + "010a04466f726d12100a0c464f524d5f554e4b4e4f574e1000120c0a0841" . + "444e4f4d49414c1001120d0a09415558494c49415259100212120a0e434f" . + "4d504c454d454e54495a4552100312100a0c46494e414c5f454e44494e47" . + "1004120a0a06474552554e441005120a0a065245414c49531006120c0a08" . + "49525245414c4953100712090a0553484f5254100812080a044c4f4e4710" . + "0912090a054f52444552100a120c0a085350454349464943100b22450a06" . + "47656e64657212120a0e47454e4445525f554e4b4e4f574e1000120c0a08" . + "46454d494e494e451001120d0a094d415343554c494e451002120a0a064e" . + "45555445521003227f0a044d6f6f6412100a0c4d4f4f445f554e4b4e4f57" . + "4e100012140a10434f4e444954494f4e414c5f4d4f4f441001120e0a0a49" . + "4d50455241544956451002120e0a0a494e4449434154495645100312110a" . + "0d494e544552524f4741544956451004120b0a074a555353495645100512" . + "0f0a0b5355424a554e4354495645100622400a064e756d62657212120a0e" . + "4e554d4245525f554e4b4e4f574e1000120c0a0853494e47554c41521001" . + "120a0a06504c5552414c100212080a044455414c100322540a0650657273" . + "6f6e12120a0e504552534f4e5f554e4b4e4f574e100012090a0546495253" . + "541001120a0a065345434f4e44100212090a055448495244100312140a10" . + "5245464c45584956455f504552534f4e100422380a0650726f7065721212" . + "0a0e50524f5045525f554e4b4e4f574e1000120a0a0650524f5045521001" . + "120e0a0a4e4f545f50524f5045521002224a0a0b5265636970726f636974" . + "7912170a135245434950524f434954595f554e4b4e4f574e1000120e0a0a" . + "5245434950524f43414c100112120a0e4e4f4e5f5245434950524f43414c" . + "100222730a0554656e736512110a0d54454e53455f554e4b4e4f574e1000" . + "12150a11434f4e444954494f4e414c5f54454e53451001120a0a06465554" . + "555245100212080a04504153541003120b0a0750524553454e541004120d" . + "0a09494d504552464543541005120e0a0a504c5550455246454354100622" . + "420a05566f69636512110a0d564f4943455f554e4b4e4f574e1000120a0a" . + "064143544956451001120d0a094341555341544956451002120b0a075041" . + "535349564510032295080a0e446570656e64656e63794564676512180a10" . + "686561645f746f6b656e5f696e646578180120012805123d0a056c616265" . + "6c18022001280e322e2e676f6f676c652e636c6f75642e6c616e67756167" . + "652e76312e446570656e64656e6379456467652e4c6162656c22a9070a05" . + "4c6162656c120b0a07554e4b4e4f574e1000120a0a064142425245561001" . + "12090a0541434f4d50100212090a05414456434c1003120a0a064144564d" . + "4f44100412080a04414d4f44100512090a054150504f53100612080a0441" . + "545452100712070a034155581008120b0a0741555850415353100912060a" . + "024343100a12090a0543434f4d50100b12080a04434f4e4a100c12090a05" . + "435355424a100d120d0a09435355424a50415353100e12070a0344455010" . + "0f12070a034445541010120d0a09444953434f55525345101112080a0444" . + "4f424a101212080a044558504c1013120c0a08474f455357495448101412" . + "080a04494f424a101512080a044d41524b101612070a034d574510171207" . + "0a034d5756101812070a034e4547101912060a024e4e101a120c0a084e50" . + "4144564d4f44101b12090a054e5355424a101c120d0a094e5355424a5041" . + "5353101d12070a034e554d101e120a0a064e554d424552101f12050a0150" . + "1020120d0a095041524154415849531021120b0a07504152544d4f441022" . + "12090a0550434f4d50102312080a04504f424a102412080a04504f535310" . + "25120b0a07504f53544e45471026120b0a07505245434f4d501027120b0a" . + "07505245434f4e4a1028120a0a06505245444554102912080a0450524546" . + "102a12080a0450524550102b12090a0550524f4e4c102c12070a03505254" . + "102d12060a025053102e120c0a085155414e544d4f44102f12090a055243" . + "4d4f441030120c0a0852434d4f4452454c103112090a055244524f501032" . + "12070a035245461033120b0a0752454d4e414e541034120e0a0a52455041" . + "52414e44554d103512080a04524f4f54103612080a04534e554d10371208" . + "0a0453554646103812080a04544d4f44103912090a05544f504943103a12" . + "080a04564d4f44103b120c0a08564f434154495645103c12090a0558434f" . + "4d50103d120a0a06535546464958103e12090a055449544c45103f120c0a" . + "0841445650484d4f441040120b0a0741555843415553104112090a054155" . + "585656104212090a0544544d4f441043120b0a07464f524549474e104412" . + "060a024b57104512080a044c495354104612080a044e4f4d431047120c0a" . + "084e4f4d435355424a104812100a0c4e4f4d435355424a50415353104912" . + "080a044e554d43104a12070a03434f50104b120e0a0a4449534c4f434154" . + "4544104c12070a03415350104d12080a04474d4f44104e12080a04474f42" . + "4a104f120a0a06494e464d4f44105012070a034d4553105112090a054e43" . + "4f4d50105222e7010a0d456e746974794d656e74696f6e12300a04746578" . + "7418012001280b32222e676f6f676c652e636c6f75642e6c616e67756167" . + "652e76312e546578745370616e123a0a047479706518022001280e322c2e" . + "676f6f676c652e636c6f75642e6c616e67756167652e76312e456e746974" . + "794d656e74696f6e2e5479706512360a0973656e74696d656e7418032001" . + "280b32232e676f6f676c652e636c6f75642e6c616e67756167652e76312e" . + "53656e74696d656e7422300a045479706512100a0c545950455f554e4b4e" . + "4f574e1000120a0a0650524f5045521001120a0a06434f4d4d4f4e100222" . + "310a08546578745370616e120f0a07636f6e74656e741801200128091214" . + "0a0c626567696e5f6f6666736574180220012805223a0a16436c61737369" . + "6669636174696f6e43617465676f7279120c0a046e616d65180120012809" . + "12120a0a636f6e666964656e6365180220012802228e010a17416e616c79" . + "7a6553656e74696d656e745265717565737412340a08646f63756d656e74" . + "18012001280b32222e676f6f676c652e636c6f75642e6c616e6775616765" . + "2e76312e446f63756d656e74123d0a0d656e636f64696e675f7479706518" . + "022001280e32262e676f6f676c652e636c6f75642e6c616e67756167652e" . + "76312e456e636f64696e675479706522a4010a18416e616c797a6553656e" . + "74696d656e74526573706f6e7365123f0a12646f63756d656e745f73656e" . + "74696d656e7418012001280b32232e676f6f676c652e636c6f75642e6c61" . + "6e67756167652e76312e53656e74696d656e7412100a086c616e67756167" . + "6518022001280912350a0973656e74656e63657318032003280b32222e67" . + "6f6f676c652e636c6f75642e6c616e67756167652e76312e53656e74656e" . + "63652294010a1d416e616c797a65456e7469747953656e74696d656e7452" . + "65717565737412340a08646f63756d656e7418012001280b32222e676f6f" . + "676c652e636c6f75642e6c616e67756167652e76312e446f63756d656e74" . + "123d0a0d656e636f64696e675f7479706518022001280e32262e676f6f67" . + "6c652e636c6f75642e6c616e67756167652e76312e456e636f64696e6754" . + "79706522660a1e416e616c797a65456e7469747953656e74696d656e7452" . + "6573706f6e736512320a08656e74697469657318012003280b32202e676f" . + "6f676c652e636c6f75642e6c616e67756167652e76312e456e7469747912" . + "100a086c616e6775616765180220012809228d010a16416e616c797a6545" . + "6e7469746965735265717565737412340a08646f63756d656e7418012001" . + "280b32222e676f6f676c652e636c6f75642e6c616e67756167652e76312e" . + "446f63756d656e74123d0a0d656e636f64696e675f747970651802200128" . + "0e32262e676f6f676c652e636c6f75642e6c616e67756167652e76312e45" . + "6e636f64696e6754797065225f0a17416e616c797a65456e746974696573" . + "526573706f6e736512320a08656e74697469657318012003280b32202e67" . + "6f6f676c652e636c6f75642e6c616e67756167652e76312e456e74697479" . + "12100a086c616e6775616765180220012809228b010a14416e616c797a65" . + "53796e7461785265717565737412340a08646f63756d656e741801200128" . + "0b32222e676f6f676c652e636c6f75642e6c616e67756167652e76312e44" . + "6f63756d656e74123d0a0d656e636f64696e675f7479706518022001280e" . + "32262e676f6f676c652e636c6f75642e6c616e67756167652e76312e456e" . + "636f64696e67547970652291010a15416e616c797a6553796e7461785265" . + "73706f6e736512350a0973656e74656e63657318012003280b32222e676f" . + "6f676c652e636c6f75642e6c616e67756167652e76312e53656e74656e63" . + "65122f0a06746f6b656e7318022003280b321f2e676f6f676c652e636c6f" . + "75642e6c616e67756167652e76312e546f6b656e12100a086c616e677561" . + "6765180320012809224b0a13436c61737369667954657874526571756573" . + "7412340a08646f63756d656e7418012001280b32222e676f6f676c652e63" . + "6c6f75642e6c616e67756167652e76312e446f63756d656e74225c0a1443" . + "6c61737369667954657874526573706f6e736512440a0a63617465676f72" . + "69657318012003280b32302e676f6f676c652e636c6f75642e6c616e6775" . + "6167652e76312e436c617373696669636174696f6e43617465676f727922" . + "f0020a13416e6e6f74617465546578745265717565737412340a08646f63" . + "756d656e7418012001280b32222e676f6f676c652e636c6f75642e6c616e" . + "67756167652e76312e446f63756d656e7412480a08666561747572657318" . + "022001280b32362e676f6f676c652e636c6f75642e6c616e67756167652e" . + "76312e416e6e6f7461746554657874526571756573742e46656174757265" . + "73123d0a0d656e636f64696e675f7479706518032001280e32262e676f6f" . + "676c652e636c6f75642e6c616e67756167652e76312e456e636f64696e67" . + "547970651a99010a08466561747572657312160a0e657874726163745f73" . + "796e74617818012001280812180a10657874726163745f656e7469746965" . + "7318022001280812220a1a657874726163745f646f63756d656e745f7365" . + "6e74696d656e7418032001280812200a18657874726163745f656e746974" . + "795f73656e74696d656e7418042001280812150a0d636c6173736966795f" . + "7465787418062001280822cb020a14416e6e6f7461746554657874526573" . + "706f6e736512350a0973656e74656e63657318012003280b32222e676f6f" . + "676c652e636c6f75642e6c616e67756167652e76312e53656e74656e6365" . + "122f0a06746f6b656e7318022003280b321f2e676f6f676c652e636c6f75" . + "642e6c616e67756167652e76312e546f6b656e12320a08656e7469746965" . + "7318032003280b32202e676f6f676c652e636c6f75642e6c616e67756167" . + "652e76312e456e74697479123f0a12646f63756d656e745f73656e74696d" . + "656e7418042001280b32232e676f6f676c652e636c6f75642e6c616e6775" . + "6167652e76312e53656e74696d656e7412100a086c616e67756167651805" . + "2001280912440a0a63617465676f7269657318062003280b32302e676f6f" . + "676c652e636c6f75642e6c616e67756167652e76312e436c617373696669" . + "636174696f6e43617465676f72792a380a0c456e636f64696e6754797065" . + "12080a044e4f4e45100012080a0455544638100112090a05555446313610" . + "0212090a055554463332100332e3070a0f4c616e67756167655365727669" . + "636512a4010a10416e616c797a6553656e74696d656e7412312e676f6f67" . + "6c652e636c6f75642e6c616e67756167652e76312e416e616c797a655365" . + "6e74696d656e74526571756573741a322e676f6f676c652e636c6f75642e" . + "6c616e67756167652e76312e416e616c797a6553656e74696d656e745265" . + "73706f6e7365222982d3e4930223221e2f76312f646f63756d656e74733a" . + "616e616c797a6553656e74696d656e743a012a12a0010a0f416e616c797a" . + "65456e74697469657312302e676f6f676c652e636c6f75642e6c616e6775" . + "6167652e76312e416e616c797a65456e746974696573526571756573741a" . + "312e676f6f676c652e636c6f75642e6c616e67756167652e76312e416e61" . + "6c797a65456e746974696573526573706f6e7365222882d3e4930222221d" . + "2f76312f646f63756d656e74733a616e616c797a65456e7469746965733a" . + "012a12bc010a16416e616c797a65456e7469747953656e74696d656e7412" . + "372e676f6f676c652e636c6f75642e6c616e67756167652e76312e416e61" . + "6c797a65456e7469747953656e74696d656e74526571756573741a382e67" . + "6f6f676c652e636c6f75642e6c616e67756167652e76312e416e616c797a" . + "65456e7469747953656e74696d656e74526573706f6e7365222f82d3e493" . + "022922242f76312f646f63756d656e74733a616e616c797a65456e746974" . + "7953656e74696d656e743a012a1298010a0d416e616c797a6553796e7461" . + "78122e2e676f6f676c652e636c6f75642e6c616e67756167652e76312e41" . + "6e616c797a6553796e746178526571756573741a2f2e676f6f676c652e63" . + "6c6f75642e6c616e67756167652e76312e416e616c797a6553796e746178" . + "526573706f6e7365222682d3e4930220221b2f76312f646f63756d656e74" . + "733a616e616c797a6553796e7461783a012a1294010a0c436c6173736966" . + "7954657874122d2e676f6f676c652e636c6f75642e6c616e67756167652e" . + "76312e436c61737369667954657874526571756573741a2e2e676f6f676c" . + "652e636c6f75642e6c616e67756167652e76312e436c6173736966795465" . + "7874526573706f6e7365222582d3e493021f221a2f76312f646f63756d65" . + "6e74733a636c617373696679546578743a012a1294010a0c416e6e6f7461" . + "746554657874122d2e676f6f676c652e636c6f75642e6c616e6775616765" . + "2e76312e416e6e6f7461746554657874526571756573741a2e2e676f6f67" . + "6c652e636c6f75642e6c616e67756167652e76312e416e6e6f7461746554" . + "657874526573706f6e7365222582d3e493021f221a2f76312f646f63756d" . + "656e74733a616e6e6f74617465546578743a012a42780a1c636f6d2e676f" . + "6f676c652e636c6f75642e6c616e67756167652e763142144c616e677561" . + "67655365727669636550726f746f50015a40676f6f676c652e676f6c616e" . + "672e6f72672f67656e70726f746f2f676f6f676c65617069732f636c6f75" . + "642f6c616e67756167652f76313b6c616e6775616765620670726f746f33" + ), true); + + static::$is_initialized = true; + } +} + diff --git a/Language/src/V1/AnalyzeEntitiesRequest.php b/Language/src/V1/AnalyzeEntitiesRequest.php new file mode 100644 index 000000000000..90ecf2f0b75f --- /dev/null +++ b/Language/src/V1/AnalyzeEntitiesRequest.php @@ -0,0 +1,101 @@ +google.cloud.language.v1.AnalyzeEntitiesRequest + */ +class AnalyzeEntitiesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + */ + private $document = null; + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + */ + private $encoding_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Document $document + * Input document. + * @type int $encoding_type + * The encoding type used by the API to calculate offsets. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @return \Google\Cloud\Language\V1\Document + */ + public function getDocument() + { + return $this->document; + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @param \Google\Cloud\Language\V1\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Document::class); + $this->document = $var; + + return $this; + } + + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + * @return int + */ + public function getEncodingType() + { + return $this->encoding_type; + } + + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + * @param int $var + * @return $this + */ + public function setEncodingType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\EncodingType::class); + $this->encoding_type = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/AnalyzeEntitiesResponse.php b/Language/src/V1/AnalyzeEntitiesResponse.php new file mode 100644 index 000000000000..9a50db50d5cb --- /dev/null +++ b/Language/src/V1/AnalyzeEntitiesResponse.php @@ -0,0 +1,113 @@ +google.cloud.language.v1.AnalyzeEntitiesResponse + */ +class AnalyzeEntitiesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The recognized entities in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 1; + */ + private $entities; + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + */ + private $language = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Entity[]|\Google\Protobuf\Internal\RepeatedField $entities + * The recognized entities in the input document. + * @type string $language + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The recognized entities in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEntities() + { + return $this->entities; + } + + /** + * The recognized entities in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 1; + * @param \Google\Cloud\Language\V1\Entity[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEntities($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\Entity::class); + $this->entities = $arr; + + return $this; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + * @param string $var + * @return $this + */ + public function setLanguage($var) + { + GPBUtil::checkString($var, True); + $this->language = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/AnalyzeEntitySentimentRequest.php b/Language/src/V1/AnalyzeEntitySentimentRequest.php new file mode 100644 index 000000000000..7f39bf456411 --- /dev/null +++ b/Language/src/V1/AnalyzeEntitySentimentRequest.php @@ -0,0 +1,101 @@ +google.cloud.language.v1.AnalyzeEntitySentimentRequest + */ +class AnalyzeEntitySentimentRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + */ + private $document = null; + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + */ + private $encoding_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Document $document + * Input document. + * @type int $encoding_type + * The encoding type used by the API to calculate offsets. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @return \Google\Cloud\Language\V1\Document + */ + public function getDocument() + { + return $this->document; + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @param \Google\Cloud\Language\V1\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Document::class); + $this->document = $var; + + return $this; + } + + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + * @return int + */ + public function getEncodingType() + { + return $this->encoding_type; + } + + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + * @param int $var + * @return $this + */ + public function setEncodingType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\EncodingType::class); + $this->encoding_type = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/AnalyzeEntitySentimentResponse.php b/Language/src/V1/AnalyzeEntitySentimentResponse.php new file mode 100644 index 000000000000..805246d43980 --- /dev/null +++ b/Language/src/V1/AnalyzeEntitySentimentResponse.php @@ -0,0 +1,113 @@ +google.cloud.language.v1.AnalyzeEntitySentimentResponse + */ +class AnalyzeEntitySentimentResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The recognized entities in the input document with associated sentiments. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 1; + */ + private $entities; + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + */ + private $language = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Entity[]|\Google\Protobuf\Internal\RepeatedField $entities + * The recognized entities in the input document with associated sentiments. + * @type string $language + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The recognized entities in the input document with associated sentiments. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEntities() + { + return $this->entities; + } + + /** + * The recognized entities in the input document with associated sentiments. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 1; + * @param \Google\Cloud\Language\V1\Entity[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEntities($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\Entity::class); + $this->entities = $arr; + + return $this; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + * @param string $var + * @return $this + */ + public function setLanguage($var) + { + GPBUtil::checkString($var, True); + $this->language = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/AnalyzeSentimentRequest.php b/Language/src/V1/AnalyzeSentimentRequest.php new file mode 100644 index 000000000000..219369f4af67 --- /dev/null +++ b/Language/src/V1/AnalyzeSentimentRequest.php @@ -0,0 +1,101 @@ +google.cloud.language.v1.AnalyzeSentimentRequest + */ +class AnalyzeSentimentRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + */ + private $document = null; + /** + * The encoding type used by the API to calculate sentence offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + */ + private $encoding_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Document $document + * Input document. + * @type int $encoding_type + * The encoding type used by the API to calculate sentence offsets. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @return \Google\Cloud\Language\V1\Document + */ + public function getDocument() + { + return $this->document; + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @param \Google\Cloud\Language\V1\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Document::class); + $this->document = $var; + + return $this; + } + + /** + * The encoding type used by the API to calculate sentence offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + * @return int + */ + public function getEncodingType() + { + return $this->encoding_type; + } + + /** + * The encoding type used by the API to calculate sentence offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + * @param int $var + * @return $this + */ + public function setEncodingType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\EncodingType::class); + $this->encoding_type = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/AnalyzeSentimentResponse.php b/Language/src/V1/AnalyzeSentimentResponse.php new file mode 100644 index 000000000000..89cc2fe7da5f --- /dev/null +++ b/Language/src/V1/AnalyzeSentimentResponse.php @@ -0,0 +1,147 @@ +google.cloud.language.v1.AnalyzeSentimentResponse + */ +class AnalyzeSentimentResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The overall sentiment of the input document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment document_sentiment = 1; + */ + private $document_sentiment = null; + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + */ + private $language = ''; + /** + * The sentiment for all the sentences in the document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 3; + */ + private $sentences; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Sentiment $document_sentiment + * The overall sentiment of the input document. + * @type string $language + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * @type \Google\Cloud\Language\V1\Sentence[]|\Google\Protobuf\Internal\RepeatedField $sentences + * The sentiment for all the sentences in the document. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The overall sentiment of the input document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment document_sentiment = 1; + * @return \Google\Cloud\Language\V1\Sentiment + */ + public function getDocumentSentiment() + { + return $this->document_sentiment; + } + + /** + * The overall sentiment of the input document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment document_sentiment = 1; + * @param \Google\Cloud\Language\V1\Sentiment $var + * @return $this + */ + public function setDocumentSentiment($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Sentiment::class); + $this->document_sentiment = $var; + + return $this; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 2; + * @param string $var + * @return $this + */ + public function setLanguage($var) + { + GPBUtil::checkString($var, True); + $this->language = $var; + + return $this; + } + + /** + * The sentiment for all the sentences in the document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSentences() + { + return $this->sentences; + } + + /** + * The sentiment for all the sentences in the document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 3; + * @param \Google\Cloud\Language\V1\Sentence[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSentences($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\Sentence::class); + $this->sentences = $arr; + + return $this; + } + +} + diff --git a/Language/src/V1/AnalyzeSyntaxRequest.php b/Language/src/V1/AnalyzeSyntaxRequest.php new file mode 100644 index 000000000000..634cd9d3bef2 --- /dev/null +++ b/Language/src/V1/AnalyzeSyntaxRequest.php @@ -0,0 +1,101 @@ +google.cloud.language.v1.AnalyzeSyntaxRequest + */ +class AnalyzeSyntaxRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + */ + private $document = null; + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + */ + private $encoding_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Document $document + * Input document. + * @type int $encoding_type + * The encoding type used by the API to calculate offsets. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @return \Google\Cloud\Language\V1\Document + */ + public function getDocument() + { + return $this->document; + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @param \Google\Cloud\Language\V1\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Document::class); + $this->document = $var; + + return $this; + } + + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + * @return int + */ + public function getEncodingType() + { + return $this->encoding_type; + } + + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 2; + * @param int $var + * @return $this + */ + public function setEncodingType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\EncodingType::class); + $this->encoding_type = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/AnalyzeSyntaxResponse.php b/Language/src/V1/AnalyzeSyntaxResponse.php new file mode 100644 index 000000000000..c073fd5a4408 --- /dev/null +++ b/Language/src/V1/AnalyzeSyntaxResponse.php @@ -0,0 +1,147 @@ +google.cloud.language.v1.AnalyzeSyntaxResponse + */ +class AnalyzeSyntaxResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Sentences in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 1; + */ + private $sentences; + /** + * Tokens, along with their syntactic information, in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Token tokens = 2; + */ + private $tokens; + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 3; + */ + private $language = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Sentence[]|\Google\Protobuf\Internal\RepeatedField $sentences + * Sentences in the input document. + * @type \Google\Cloud\Language\V1\Token[]|\Google\Protobuf\Internal\RepeatedField $tokens + * Tokens, along with their syntactic information, in the input document. + * @type string $language + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Sentences in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSentences() + { + return $this->sentences; + } + + /** + * Sentences in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 1; + * @param \Google\Cloud\Language\V1\Sentence[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSentences($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\Sentence::class); + $this->sentences = $arr; + + return $this; + } + + /** + * Tokens, along with their syntactic information, in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Token tokens = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getTokens() + { + return $this->tokens; + } + + /** + * Tokens, along with their syntactic information, in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Token tokens = 2; + * @param \Google\Cloud\Language\V1\Token[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setTokens($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\Token::class); + $this->tokens = $arr; + + return $this; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 3; + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 3; + * @param string $var + * @return $this + */ + public function setLanguage($var) + { + GPBUtil::checkString($var, True); + $this->language = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/AnnotateTextRequest.php b/Language/src/V1/AnnotateTextRequest.php new file mode 100644 index 000000000000..1a0ee70e7892 --- /dev/null +++ b/Language/src/V1/AnnotateTextRequest.php @@ -0,0 +1,136 @@ +google.cloud.language.v1.AnnotateTextRequest + */ +class AnnotateTextRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + */ + private $document = null; + /** + * The enabled features. + * + * Generated from protobuf field .google.cloud.language.v1.AnnotateTextRequest.Features features = 2; + */ + private $features = null; + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 3; + */ + private $encoding_type = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Document $document + * Input document. + * @type \Google\Cloud\Language\V1\AnnotateTextRequest\Features $features + * The enabled features. + * @type int $encoding_type + * The encoding type used by the API to calculate offsets. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @return \Google\Cloud\Language\V1\Document + */ + public function getDocument() + { + return $this->document; + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @param \Google\Cloud\Language\V1\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Document::class); + $this->document = $var; + + return $this; + } + + /** + * The enabled features. + * + * Generated from protobuf field .google.cloud.language.v1.AnnotateTextRequest.Features features = 2; + * @return \Google\Cloud\Language\V1\AnnotateTextRequest\Features + */ + public function getFeatures() + { + return $this->features; + } + + /** + * The enabled features. + * + * Generated from protobuf field .google.cloud.language.v1.AnnotateTextRequest.Features features = 2; + * @param \Google\Cloud\Language\V1\AnnotateTextRequest\Features $var + * @return $this + */ + public function setFeatures($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\AnnotateTextRequest_Features::class); + $this->features = $var; + + return $this; + } + + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 3; + * @return int + */ + public function getEncodingType() + { + return $this->encoding_type; + } + + /** + * The encoding type used by the API to calculate offsets. + * + * Generated from protobuf field .google.cloud.language.v1.EncodingType encoding_type = 3; + * @param int $var + * @return $this + */ + public function setEncodingType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\EncodingType::class); + $this->encoding_type = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/AnnotateTextRequest/Features.php b/Language/src/V1/AnnotateTextRequest/Features.php new file mode 100644 index 000000000000..7aa1c02c0f5b --- /dev/null +++ b/Language/src/V1/AnnotateTextRequest/Features.php @@ -0,0 +1,207 @@ +google.cloud.language.v1.AnnotateTextRequest.Features + */ +class Features extends \Google\Protobuf\Internal\Message +{ + /** + * Extract syntax information. + * + * Generated from protobuf field bool extract_syntax = 1; + */ + private $extract_syntax = false; + /** + * Extract entities. + * + * Generated from protobuf field bool extract_entities = 2; + */ + private $extract_entities = false; + /** + * Extract document-level sentiment. + * + * Generated from protobuf field bool extract_document_sentiment = 3; + */ + private $extract_document_sentiment = false; + /** + * Extract entities and their associated sentiment. + * + * Generated from protobuf field bool extract_entity_sentiment = 4; + */ + private $extract_entity_sentiment = false; + /** + * Classify the full document into categories. + * + * Generated from protobuf field bool classify_text = 6; + */ + private $classify_text = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $extract_syntax + * Extract syntax information. + * @type bool $extract_entities + * Extract entities. + * @type bool $extract_document_sentiment + * Extract document-level sentiment. + * @type bool $extract_entity_sentiment + * Extract entities and their associated sentiment. + * @type bool $classify_text + * Classify the full document into categories. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Extract syntax information. + * + * Generated from protobuf field bool extract_syntax = 1; + * @return bool + */ + public function getExtractSyntax() + { + return $this->extract_syntax; + } + + /** + * Extract syntax information. + * + * Generated from protobuf field bool extract_syntax = 1; + * @param bool $var + * @return $this + */ + public function setExtractSyntax($var) + { + GPBUtil::checkBool($var); + $this->extract_syntax = $var; + + return $this; + } + + /** + * Extract entities. + * + * Generated from protobuf field bool extract_entities = 2; + * @return bool + */ + public function getExtractEntities() + { + return $this->extract_entities; + } + + /** + * Extract entities. + * + * Generated from protobuf field bool extract_entities = 2; + * @param bool $var + * @return $this + */ + public function setExtractEntities($var) + { + GPBUtil::checkBool($var); + $this->extract_entities = $var; + + return $this; + } + + /** + * Extract document-level sentiment. + * + * Generated from protobuf field bool extract_document_sentiment = 3; + * @return bool + */ + public function getExtractDocumentSentiment() + { + return $this->extract_document_sentiment; + } + + /** + * Extract document-level sentiment. + * + * Generated from protobuf field bool extract_document_sentiment = 3; + * @param bool $var + * @return $this + */ + public function setExtractDocumentSentiment($var) + { + GPBUtil::checkBool($var); + $this->extract_document_sentiment = $var; + + return $this; + } + + /** + * Extract entities and their associated sentiment. + * + * Generated from protobuf field bool extract_entity_sentiment = 4; + * @return bool + */ + public function getExtractEntitySentiment() + { + return $this->extract_entity_sentiment; + } + + /** + * Extract entities and their associated sentiment. + * + * Generated from protobuf field bool extract_entity_sentiment = 4; + * @param bool $var + * @return $this + */ + public function setExtractEntitySentiment($var) + { + GPBUtil::checkBool($var); + $this->extract_entity_sentiment = $var; + + return $this; + } + + /** + * Classify the full document into categories. + * + * Generated from protobuf field bool classify_text = 6; + * @return bool + */ + public function getClassifyText() + { + return $this->classify_text; + } + + /** + * Classify the full document into categories. + * + * Generated from protobuf field bool classify_text = 6; + * @param bool $var + * @return $this + */ + public function setClassifyText($var) + { + GPBUtil::checkBool($var); + $this->classify_text = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Features::class, \Google\Cloud\Language\V1\AnnotateTextRequest_Features::class); + diff --git a/Language/src/V1/AnnotateTextRequest_Features.php b/Language/src/V1/AnnotateTextRequest_Features.php new file mode 100644 index 000000000000..e02aca7493ec --- /dev/null +++ b/Language/src/V1/AnnotateTextRequest_Features.php @@ -0,0 +1,16 @@ +google.cloud.language.v1.AnnotateTextResponse + */ +class AnnotateTextResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Sentences in the input document. Populated if the user enables + * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 1; + */ + private $sentences; + /** + * Tokens, along with their syntactic information, in the input document. + * Populated if the user enables + * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Token tokens = 2; + */ + private $tokens; + /** + * Entities, along with their semantic information, in the input document. + * Populated if the user enables + * [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entities]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 3; + */ + private $entities; + /** + * The overall sentiment for the document. Populated if the user enables + * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment]. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment document_sentiment = 4; + */ + private $document_sentiment = null; + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 5; + */ + private $language = ''; + /** + * Categories identified in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.ClassificationCategory categories = 6; + */ + private $categories; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Sentence[]|\Google\Protobuf\Internal\RepeatedField $sentences + * Sentences in the input document. Populated if the user enables + * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + * @type \Google\Cloud\Language\V1\Token[]|\Google\Protobuf\Internal\RepeatedField $tokens + * Tokens, along with their syntactic information, in the input document. + * Populated if the user enables + * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + * @type \Google\Cloud\Language\V1\Entity[]|\Google\Protobuf\Internal\RepeatedField $entities + * Entities, along with their semantic information, in the input document. + * Populated if the user enables + * [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entities]. + * @type \Google\Cloud\Language\V1\Sentiment $document_sentiment + * The overall sentiment for the document. Populated if the user enables + * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment]. + * @type string $language + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * @type \Google\Cloud\Language\V1\ClassificationCategory[]|\Google\Protobuf\Internal\RepeatedField $categories + * Categories identified in the input document. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Sentences in the input document. Populated if the user enables + * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSentences() + { + return $this->sentences; + } + + /** + * Sentences in the input document. Populated if the user enables + * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Sentence sentences = 1; + * @param \Google\Cloud\Language\V1\Sentence[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSentences($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\Sentence::class); + $this->sentences = $arr; + + return $this; + } + + /** + * Tokens, along with their syntactic information, in the input document. + * Populated if the user enables + * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Token tokens = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getTokens() + { + return $this->tokens; + } + + /** + * Tokens, along with their syntactic information, in the input document. + * Populated if the user enables + * [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1.AnnotateTextRequest.Features.extract_syntax]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Token tokens = 2; + * @param \Google\Cloud\Language\V1\Token[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setTokens($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\Token::class); + $this->tokens = $arr; + + return $this; + } + + /** + * Entities, along with their semantic information, in the input document. + * Populated if the user enables + * [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entities]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getEntities() + { + return $this->entities; + } + + /** + * Entities, along with their semantic information, in the input document. + * Populated if the user enables + * [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entities]. + * + * Generated from protobuf field repeated .google.cloud.language.v1.Entity entities = 3; + * @param \Google\Cloud\Language\V1\Entity[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setEntities($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\Entity::class); + $this->entities = $arr; + + return $this; + } + + /** + * The overall sentiment for the document. Populated if the user enables + * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment]. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment document_sentiment = 4; + * @return \Google\Cloud\Language\V1\Sentiment + */ + public function getDocumentSentiment() + { + return $this->document_sentiment; + } + + /** + * The overall sentiment for the document. Populated if the user enables + * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment]. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment document_sentiment = 4; + * @param \Google\Cloud\Language\V1\Sentiment $var + * @return $this + */ + public function setDocumentSentiment($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Sentiment::class); + $this->document_sentiment = $var; + + return $this; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 5; + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * The language of the text, which will be the same as the language specified + * in the request or, if not specified, the automatically-detected language. + * See [Document.language][google.cloud.language.v1.Document.language] field + * for more details. + * + * Generated from protobuf field string language = 5; + * @param string $var + * @return $this + */ + public function setLanguage($var) + { + GPBUtil::checkString($var, True); + $this->language = $var; + + return $this; + } + + /** + * Categories identified in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.ClassificationCategory categories = 6; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getCategories() + { + return $this->categories; + } + + /** + * Categories identified in the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.ClassificationCategory categories = 6; + * @param \Google\Cloud\Language\V1\ClassificationCategory[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setCategories($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\ClassificationCategory::class); + $this->categories = $arr; + + return $this; + } + +} + diff --git a/Language/src/V1/ClassificationCategory.php b/Language/src/V1/ClassificationCategory.php new file mode 100644 index 000000000000..a1b8dfd7564f --- /dev/null +++ b/Language/src/V1/ClassificationCategory.php @@ -0,0 +1,109 @@ +google.cloud.language.v1.ClassificationCategory + */ +class ClassificationCategory extends \Google\Protobuf\Internal\Message +{ + /** + * The name of the category representing the document, from the [predefined + * taxonomy](/natural-language/docs/categories). + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * The classifier's confidence of the category. Number represents how certain + * the classifier is that this category represents the given text. + * + * Generated from protobuf field float confidence = 2; + */ + private $confidence = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The name of the category representing the document, from the [predefined + * taxonomy](/natural-language/docs/categories). + * @type float $confidence + * The classifier's confidence of the category. Number represents how certain + * the classifier is that this category represents the given text. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The name of the category representing the document, from the [predefined + * taxonomy](/natural-language/docs/categories). + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The name of the category representing the document, from the [predefined + * taxonomy](/natural-language/docs/categories). + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The classifier's confidence of the category. Number represents how certain + * the classifier is that this category represents the given text. + * + * Generated from protobuf field float confidence = 2; + * @return float + */ + public function getConfidence() + { + return $this->confidence; + } + + /** + * The classifier's confidence of the category. Number represents how certain + * the classifier is that this category represents the given text. + * + * Generated from protobuf field float confidence = 2; + * @param float $var + * @return $this + */ + public function setConfidence($var) + { + GPBUtil::checkFloat($var); + $this->confidence = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/ClassifyTextRequest.php b/Language/src/V1/ClassifyTextRequest.php new file mode 100644 index 000000000000..3f96e705b994 --- /dev/null +++ b/Language/src/V1/ClassifyTextRequest.php @@ -0,0 +1,67 @@ +google.cloud.language.v1.ClassifyTextRequest + */ +class ClassifyTextRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + */ + private $document = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\Document $document + * Input document. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @return \Google\Cloud\Language\V1\Document + */ + public function getDocument() + { + return $this->document; + } + + /** + * Input document. + * + * Generated from protobuf field .google.cloud.language.v1.Document document = 1; + * @param \Google\Cloud\Language\V1\Document $var + * @return $this + */ + public function setDocument($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Document::class); + $this->document = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/ClassifyTextResponse.php b/Language/src/V1/ClassifyTextResponse.php new file mode 100644 index 000000000000..1ba1e29a598b --- /dev/null +++ b/Language/src/V1/ClassifyTextResponse.php @@ -0,0 +1,67 @@ +google.cloud.language.v1.ClassifyTextResponse + */ +class ClassifyTextResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Categories representing the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.ClassificationCategory categories = 1; + */ + private $categories; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\ClassificationCategory[]|\Google\Protobuf\Internal\RepeatedField $categories + * Categories representing the input document. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Categories representing the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.ClassificationCategory categories = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getCategories() + { + return $this->categories; + } + + /** + * Categories representing the input document. + * + * Generated from protobuf field repeated .google.cloud.language.v1.ClassificationCategory categories = 1; + * @param \Google\Cloud\Language\V1\ClassificationCategory[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setCategories($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\ClassificationCategory::class); + $this->categories = $arr; + + return $this; + } + +} + diff --git a/Language/src/V1/DependencyEdge.php b/Language/src/V1/DependencyEdge.php new file mode 100644 index 000000000000..eefcb6bc9ffe --- /dev/null +++ b/Language/src/V1/DependencyEdge.php @@ -0,0 +1,119 @@ +google.cloud.language.v1.DependencyEdge + */ +class DependencyEdge extends \Google\Protobuf\Internal\Message +{ + /** + * Represents the head of this token in the dependency tree. + * This is the index of the token which has an arc going to this token. + * The index is the position of the token in the array of tokens returned + * by the API method. If this token is a root token, then the + * `head_token_index` is its own index. + * + * Generated from protobuf field int32 head_token_index = 1; + */ + private $head_token_index = 0; + /** + * The parse label for the token. + * + * Generated from protobuf field .google.cloud.language.v1.DependencyEdge.Label label = 2; + */ + private $label = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $head_token_index + * Represents the head of this token in the dependency tree. + * This is the index of the token which has an arc going to this token. + * The index is the position of the token in the array of tokens returned + * by the API method. If this token is a root token, then the + * `head_token_index` is its own index. + * @type int $label + * The parse label for the token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Represents the head of this token in the dependency tree. + * This is the index of the token which has an arc going to this token. + * The index is the position of the token in the array of tokens returned + * by the API method. If this token is a root token, then the + * `head_token_index` is its own index. + * + * Generated from protobuf field int32 head_token_index = 1; + * @return int + */ + public function getHeadTokenIndex() + { + return $this->head_token_index; + } + + /** + * Represents the head of this token in the dependency tree. + * This is the index of the token which has an arc going to this token. + * The index is the position of the token in the array of tokens returned + * by the API method. If this token is a root token, then the + * `head_token_index` is its own index. + * + * Generated from protobuf field int32 head_token_index = 1; + * @param int $var + * @return $this + */ + public function setHeadTokenIndex($var) + { + GPBUtil::checkInt32($var); + $this->head_token_index = $var; + + return $this; + } + + /** + * The parse label for the token. + * + * Generated from protobuf field .google.cloud.language.v1.DependencyEdge.Label label = 2; + * @return int + */ + public function getLabel() + { + return $this->label; + } + + /** + * The parse label for the token. + * + * Generated from protobuf field .google.cloud.language.v1.DependencyEdge.Label label = 2; + * @param int $var + * @return $this + */ + public function setLabel($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\DependencyEdge_Label::class); + $this->label = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/DependencyEdge/Label.php b/Language/src/V1/DependencyEdge/Label.php new file mode 100644 index 000000000000..ed787ccf8fd0 --- /dev/null +++ b/Language/src/V1/DependencyEdge/Label.php @@ -0,0 +1,624 @@ +google.cloud.language.v1.DependencyEdge.Label + */ +class Label +{ + /** + * Unknown + * + * Generated from protobuf enum UNKNOWN = 0; + */ + const UNKNOWN = 0; + /** + * Abbreviation modifier + * + * Generated from protobuf enum ABBREV = 1; + */ + const ABBREV = 1; + /** + * Adjectival complement + * + * Generated from protobuf enum ACOMP = 2; + */ + const ACOMP = 2; + /** + * Adverbial clause modifier + * + * Generated from protobuf enum ADVCL = 3; + */ + const ADVCL = 3; + /** + * Adverbial modifier + * + * Generated from protobuf enum ADVMOD = 4; + */ + const ADVMOD = 4; + /** + * Adjectival modifier of an NP + * + * Generated from protobuf enum AMOD = 5; + */ + const AMOD = 5; + /** + * Appositional modifier of an NP + * + * Generated from protobuf enum APPOS = 6; + */ + const APPOS = 6; + /** + * Attribute dependent of a copular verb + * + * Generated from protobuf enum ATTR = 7; + */ + const ATTR = 7; + /** + * Auxiliary (non-main) verb + * + * Generated from protobuf enum AUX = 8; + */ + const AUX = 8; + /** + * Passive auxiliary + * + * Generated from protobuf enum AUXPASS = 9; + */ + const AUXPASS = 9; + /** + * Coordinating conjunction + * + * Generated from protobuf enum CC = 10; + */ + const CC = 10; + /** + * Clausal complement of a verb or adjective + * + * Generated from protobuf enum CCOMP = 11; + */ + const CCOMP = 11; + /** + * Conjunct + * + * Generated from protobuf enum CONJ = 12; + */ + const CONJ = 12; + /** + * Clausal subject + * + * Generated from protobuf enum CSUBJ = 13; + */ + const CSUBJ = 13; + /** + * Clausal passive subject + * + * Generated from protobuf enum CSUBJPASS = 14; + */ + const CSUBJPASS = 14; + /** + * Dependency (unable to determine) + * + * Generated from protobuf enum DEP = 15; + */ + const DEP = 15; + /** + * Determiner + * + * Generated from protobuf enum DET = 16; + */ + const DET = 16; + /** + * Discourse + * + * Generated from protobuf enum DISCOURSE = 17; + */ + const DISCOURSE = 17; + /** + * Direct object + * + * Generated from protobuf enum DOBJ = 18; + */ + const DOBJ = 18; + /** + * Expletive + * + * Generated from protobuf enum EXPL = 19; + */ + const EXPL = 19; + /** + * Goes with (part of a word in a text not well edited) + * + * Generated from protobuf enum GOESWITH = 20; + */ + const GOESWITH = 20; + /** + * Indirect object + * + * Generated from protobuf enum IOBJ = 21; + */ + const IOBJ = 21; + /** + * Marker (word introducing a subordinate clause) + * + * Generated from protobuf enum MARK = 22; + */ + const MARK = 22; + /** + * Multi-word expression + * + * Generated from protobuf enum MWE = 23; + */ + const MWE = 23; + /** + * Multi-word verbal expression + * + * Generated from protobuf enum MWV = 24; + */ + const MWV = 24; + /** + * Negation modifier + * + * Generated from protobuf enum NEG = 25; + */ + const NEG = 25; + /** + * Noun compound modifier + * + * Generated from protobuf enum NN = 26; + */ + const NN = 26; + /** + * Noun phrase used as an adverbial modifier + * + * Generated from protobuf enum NPADVMOD = 27; + */ + const NPADVMOD = 27; + /** + * Nominal subject + * + * Generated from protobuf enum NSUBJ = 28; + */ + const NSUBJ = 28; + /** + * Passive nominal subject + * + * Generated from protobuf enum NSUBJPASS = 29; + */ + const NSUBJPASS = 29; + /** + * Numeric modifier of a noun + * + * Generated from protobuf enum NUM = 30; + */ + const NUM = 30; + /** + * Element of compound number + * + * Generated from protobuf enum NUMBER = 31; + */ + const NUMBER = 31; + /** + * Punctuation mark + * + * Generated from protobuf enum P = 32; + */ + const P = 32; + /** + * Parataxis relation + * + * Generated from protobuf enum PARATAXIS = 33; + */ + const PARATAXIS = 33; + /** + * Participial modifier + * + * Generated from protobuf enum PARTMOD = 34; + */ + const PARTMOD = 34; + /** + * The complement of a preposition is a clause + * + * Generated from protobuf enum PCOMP = 35; + */ + const PCOMP = 35; + /** + * Object of a preposition + * + * Generated from protobuf enum POBJ = 36; + */ + const POBJ = 36; + /** + * Possession modifier + * + * Generated from protobuf enum POSS = 37; + */ + const POSS = 37; + /** + * Postverbal negative particle + * + * Generated from protobuf enum POSTNEG = 38; + */ + const POSTNEG = 38; + /** + * Predicate complement + * + * Generated from protobuf enum PRECOMP = 39; + */ + const PRECOMP = 39; + /** + * Preconjunt + * + * Generated from protobuf enum PRECONJ = 40; + */ + const PRECONJ = 40; + /** + * Predeterminer + * + * Generated from protobuf enum PREDET = 41; + */ + const PREDET = 41; + /** + * Prefix + * + * Generated from protobuf enum PREF = 42; + */ + const PREF = 42; + /** + * Prepositional modifier + * + * Generated from protobuf enum PREP = 43; + */ + const PREP = 43; + /** + * The relationship between a verb and verbal morpheme + * + * Generated from protobuf enum PRONL = 44; + */ + const PRONL = 44; + /** + * Particle + * + * Generated from protobuf enum PRT = 45; + */ + const PRT = 45; + /** + * Associative or possessive marker + * + * Generated from protobuf enum PS = 46; + */ + const PS = 46; + /** + * Quantifier phrase modifier + * + * Generated from protobuf enum QUANTMOD = 47; + */ + const QUANTMOD = 47; + /** + * Relative clause modifier + * + * Generated from protobuf enum RCMOD = 48; + */ + const RCMOD = 48; + /** + * Complementizer in relative clause + * + * Generated from protobuf enum RCMODREL = 49; + */ + const RCMODREL = 49; + /** + * Ellipsis without a preceding predicate + * + * Generated from protobuf enum RDROP = 50; + */ + const RDROP = 50; + /** + * Referent + * + * Generated from protobuf enum REF = 51; + */ + const REF = 51; + /** + * Remnant + * + * Generated from protobuf enum REMNANT = 52; + */ + const REMNANT = 52; + /** + * Reparandum + * + * Generated from protobuf enum REPARANDUM = 53; + */ + const REPARANDUM = 53; + /** + * Root + * + * Generated from protobuf enum ROOT = 54; + */ + const ROOT = 54; + /** + * Suffix specifying a unit of number + * + * Generated from protobuf enum SNUM = 55; + */ + const SNUM = 55; + /** + * Suffix + * + * Generated from protobuf enum SUFF = 56; + */ + const SUFF = 56; + /** + * Temporal modifier + * + * Generated from protobuf enum TMOD = 57; + */ + const TMOD = 57; + /** + * Topic marker + * + * Generated from protobuf enum TOPIC = 58; + */ + const TOPIC = 58; + /** + * Clause headed by an infinite form of the verb that modifies a noun + * + * Generated from protobuf enum VMOD = 59; + */ + const VMOD = 59; + /** + * Vocative + * + * Generated from protobuf enum VOCATIVE = 60; + */ + const VOCATIVE = 60; + /** + * Open clausal complement + * + * Generated from protobuf enum XCOMP = 61; + */ + const XCOMP = 61; + /** + * Name suffix + * + * Generated from protobuf enum SUFFIX = 62; + */ + const SUFFIX = 62; + /** + * Name title + * + * Generated from protobuf enum TITLE = 63; + */ + const TITLE = 63; + /** + * Adverbial phrase modifier + * + * Generated from protobuf enum ADVPHMOD = 64; + */ + const ADVPHMOD = 64; + /** + * Causative auxiliary + * + * Generated from protobuf enum AUXCAUS = 65; + */ + const AUXCAUS = 65; + /** + * Helper auxiliary + * + * Generated from protobuf enum AUXVV = 66; + */ + const AUXVV = 66; + /** + * Rentaishi (Prenominal modifier) + * + * Generated from protobuf enum DTMOD = 67; + */ + const DTMOD = 67; + /** + * Foreign words + * + * Generated from protobuf enum FOREIGN = 68; + */ + const FOREIGN = 68; + /** + * Keyword + * + * Generated from protobuf enum KW = 69; + */ + const KW = 69; + /** + * List for chains of comparable items + * + * Generated from protobuf enum LIST = 70; + */ + const PBLIST = 70; + /** + * Nominalized clause + * + * Generated from protobuf enum NOMC = 71; + */ + const NOMC = 71; + /** + * Nominalized clausal subject + * + * Generated from protobuf enum NOMCSUBJ = 72; + */ + const NOMCSUBJ = 72; + /** + * Nominalized clausal passive + * + * Generated from protobuf enum NOMCSUBJPASS = 73; + */ + const NOMCSUBJPASS = 73; + /** + * Compound of numeric modifier + * + * Generated from protobuf enum NUMC = 74; + */ + const NUMC = 74; + /** + * Copula + * + * Generated from protobuf enum COP = 75; + */ + const COP = 75; + /** + * Dislocated relation (for fronted/topicalized elements) + * + * Generated from protobuf enum DISLOCATED = 76; + */ + const DISLOCATED = 76; + /** + * Aspect marker + * + * Generated from protobuf enum ASP = 77; + */ + const ASP = 77; + /** + * Genitive modifier + * + * Generated from protobuf enum GMOD = 78; + */ + const GMOD = 78; + /** + * Genitive object + * + * Generated from protobuf enum GOBJ = 79; + */ + const GOBJ = 79; + /** + * Infinitival modifier + * + * Generated from protobuf enum INFMOD = 80; + */ + const INFMOD = 80; + /** + * Measure + * + * Generated from protobuf enum MES = 81; + */ + const MES = 81; + /** + * Nominal complement of a noun + * + * Generated from protobuf enum NCOMP = 82; + */ + const NCOMP = 82; + + private static $valueToName = [ + self::UNKNOWN => 'UNKNOWN', + self::ABBREV => 'ABBREV', + self::ACOMP => 'ACOMP', + self::ADVCL => 'ADVCL', + self::ADVMOD => 'ADVMOD', + self::AMOD => 'AMOD', + self::APPOS => 'APPOS', + self::ATTR => 'ATTR', + self::AUX => 'AUX', + self::AUXPASS => 'AUXPASS', + self::CC => 'CC', + self::CCOMP => 'CCOMP', + self::CONJ => 'CONJ', + self::CSUBJ => 'CSUBJ', + self::CSUBJPASS => 'CSUBJPASS', + self::DEP => 'DEP', + self::DET => 'DET', + self::DISCOURSE => 'DISCOURSE', + self::DOBJ => 'DOBJ', + self::EXPL => 'EXPL', + self::GOESWITH => 'GOESWITH', + self::IOBJ => 'IOBJ', + self::MARK => 'MARK', + self::MWE => 'MWE', + self::MWV => 'MWV', + self::NEG => 'NEG', + self::NN => 'NN', + self::NPADVMOD => 'NPADVMOD', + self::NSUBJ => 'NSUBJ', + self::NSUBJPASS => 'NSUBJPASS', + self::NUM => 'NUM', + self::NUMBER => 'NUMBER', + self::P => 'P', + self::PARATAXIS => 'PARATAXIS', + self::PARTMOD => 'PARTMOD', + self::PCOMP => 'PCOMP', + self::POBJ => 'POBJ', + self::POSS => 'POSS', + self::POSTNEG => 'POSTNEG', + self::PRECOMP => 'PRECOMP', + self::PRECONJ => 'PRECONJ', + self::PREDET => 'PREDET', + self::PREF => 'PREF', + self::PREP => 'PREP', + self::PRONL => 'PRONL', + self::PRT => 'PRT', + self::PS => 'PS', + self::QUANTMOD => 'QUANTMOD', + self::RCMOD => 'RCMOD', + self::RCMODREL => 'RCMODREL', + self::RDROP => 'RDROP', + self::REF => 'REF', + self::REMNANT => 'REMNANT', + self::REPARANDUM => 'REPARANDUM', + self::ROOT => 'ROOT', + self::SNUM => 'SNUM', + self::SUFF => 'SUFF', + self::TMOD => 'TMOD', + self::TOPIC => 'TOPIC', + self::VMOD => 'VMOD', + self::VOCATIVE => 'VOCATIVE', + self::XCOMP => 'XCOMP', + self::SUFFIX => 'SUFFIX', + self::TITLE => 'TITLE', + self::ADVPHMOD => 'ADVPHMOD', + self::AUXCAUS => 'AUXCAUS', + self::AUXVV => 'AUXVV', + self::DTMOD => 'DTMOD', + self::FOREIGN => 'FOREIGN', + self::KW => 'KW', + self::PBLIST => 'PBLIST', + self::NOMC => 'NOMC', + self::NOMCSUBJ => 'NOMCSUBJ', + self::NOMCSUBJPASS => 'NOMCSUBJPASS', + self::NUMC => 'NUMC', + self::COP => 'COP', + self::DISLOCATED => 'DISLOCATED', + self::ASP => 'ASP', + self::GMOD => 'GMOD', + self::GOBJ => 'GOBJ', + self::INFMOD => 'INFMOD', + self::MES => 'MES', + self::NCOMP => 'NCOMP', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Label::class, \Google\Cloud\Language\V1\DependencyEdge_Label::class); + diff --git a/Language/src/V1/DependencyEdge_Label.php b/Language/src/V1/DependencyEdge_Label.php new file mode 100644 index 000000000000..4d8f234314ba --- /dev/null +++ b/Language/src/V1/DependencyEdge_Label.php @@ -0,0 +1,16 @@ +google.cloud.language.v1.Document + */ +class Document extends \Google\Protobuf\Internal\Message +{ + /** + * Required. If the type is not set or is `TYPE_UNSPECIFIED`, + * returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field .google.cloud.language.v1.Document.Type type = 1; + */ + private $type = 0; + /** + * The language of the document (if not specified, the language is + * automatically detected). Both ISO and BCP-47 language codes are + * accepted.
+ * [Language Support](/natural-language/docs/languages) + * lists currently supported languages for each API method. + * If the language (either specified by the caller or automatically detected) + * is not supported by the called API method, an `INVALID_ARGUMENT` error + * is returned. + * + * Generated from protobuf field string language = 4; + */ + private $language = ''; + protected $source; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $type + * Required. If the type is not set or is `TYPE_UNSPECIFIED`, + * returns an `INVALID_ARGUMENT` error. + * @type string $content + * The content of the input in string format. + * @type string $gcs_content_uri + * The Google Cloud Storage URI where the file content is located. + * This URI must be of the form: gs://bucket_name/object_name. For more + * details, see https://cloud.google.com/storage/docs/reference-uris. + * NOTE: Cloud Storage object versioning is not supported. + * @type string $language + * The language of the document (if not specified, the language is + * automatically detected). Both ISO and BCP-47 language codes are + * accepted.
+ * [Language Support](/natural-language/docs/languages) + * lists currently supported languages for each API method. + * If the language (either specified by the caller or automatically detected) + * is not supported by the called API method, an `INVALID_ARGUMENT` error + * is returned. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * Required. If the type is not set or is `TYPE_UNSPECIFIED`, + * returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field .google.cloud.language.v1.Document.Type type = 1; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * Required. If the type is not set or is `TYPE_UNSPECIFIED`, + * returns an `INVALID_ARGUMENT` error. + * + * Generated from protobuf field .google.cloud.language.v1.Document.Type type = 1; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\Document_Type::class); + $this->type = $var; + + return $this; + } + + /** + * The content of the input in string format. + * + * Generated from protobuf field string content = 2; + * @return string + */ + public function getContent() + { + return $this->readOneof(2); + } + + /** + * The content of the input in string format. + * + * Generated from protobuf field string content = 2; + * @param string $var + * @return $this + */ + public function setContent($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * The Google Cloud Storage URI where the file content is located. + * This URI must be of the form: gs://bucket_name/object_name. For more + * details, see https://cloud.google.com/storage/docs/reference-uris. + * NOTE: Cloud Storage object versioning is not supported. + * + * Generated from protobuf field string gcs_content_uri = 3; + * @return string + */ + public function getGcsContentUri() + { + return $this->readOneof(3); + } + + /** + * The Google Cloud Storage URI where the file content is located. + * This URI must be of the form: gs://bucket_name/object_name. For more + * details, see https://cloud.google.com/storage/docs/reference-uris. + * NOTE: Cloud Storage object versioning is not supported. + * + * Generated from protobuf field string gcs_content_uri = 3; + * @param string $var + * @return $this + */ + public function setGcsContentUri($var) + { + GPBUtil::checkString($var, True); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * The language of the document (if not specified, the language is + * automatically detected). Both ISO and BCP-47 language codes are + * accepted.
+ * [Language Support](/natural-language/docs/languages) + * lists currently supported languages for each API method. + * If the language (either specified by the caller or automatically detected) + * is not supported by the called API method, an `INVALID_ARGUMENT` error + * is returned. + * + * Generated from protobuf field string language = 4; + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * The language of the document (if not specified, the language is + * automatically detected). Both ISO and BCP-47 language codes are + * accepted.
+ * [Language Support](/natural-language/docs/languages) + * lists currently supported languages for each API method. + * If the language (either specified by the caller or automatically detected) + * is not supported by the called API method, an `INVALID_ARGUMENT` error + * is returned. + * + * Generated from protobuf field string language = 4; + * @param string $var + * @return $this + */ + public function setLanguage($var) + { + GPBUtil::checkString($var, True); + $this->language = $var; + + return $this; + } + + /** + * @return string + */ + public function getSource() + { + return $this->whichOneof("source"); + } + +} + diff --git a/Language/src/V1/Document/Type.php b/Language/src/V1/Document/Type.php new file mode 100644 index 000000000000..00069f59a85c --- /dev/null +++ b/Language/src/V1/Document/Type.php @@ -0,0 +1,64 @@ +google.cloud.language.v1.Document.Type + */ +class Type +{ + /** + * The content type is not specified. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * Plain text + * + * Generated from protobuf enum PLAIN_TEXT = 1; + */ + const PLAIN_TEXT = 1; + /** + * HTML + * + * Generated from protobuf enum HTML = 2; + */ + const HTML = 2; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::PLAIN_TEXT => 'PLAIN_TEXT', + self::HTML => 'HTML', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Type::class, \Google\Cloud\Language\V1\Document_Type::class); + diff --git a/Language/src/V1/Document_Type.php b/Language/src/V1/Document_Type.php new file mode 100644 index 000000000000..a28599b289b6 --- /dev/null +++ b/Language/src/V1/Document_Type.php @@ -0,0 +1,16 @@ +google.cloud.language.v1.EncodingType + */ +class EncodingType +{ + /** + * If `EncodingType` is not specified, encoding-dependent information (such as + * `begin_offset`) will be set at `-1`. + * + * Generated from protobuf enum NONE = 0; + */ + const NONE = 0; + /** + * Encoding-dependent information (such as `begin_offset`) is calculated based + * on the UTF-8 encoding of the input. C++ and Go are examples of languages + * that use this encoding natively. + * + * Generated from protobuf enum UTF8 = 1; + */ + const UTF8 = 1; + /** + * Encoding-dependent information (such as `begin_offset`) is calculated based + * on the UTF-16 encoding of the input. Java and JavaScript are examples of + * languages that use this encoding natively. + * + * Generated from protobuf enum UTF16 = 2; + */ + const UTF16 = 2; + /** + * Encoding-dependent information (such as `begin_offset`) is calculated based + * on the UTF-32 encoding of the input. Python is an example of a language + * that uses this encoding natively. + * + * Generated from protobuf enum UTF32 = 3; + */ + const UTF32 = 3; + + private static $valueToName = [ + self::NONE => 'NONE', + self::UTF8 => 'UTF8', + self::UTF16 => 'UTF16', + self::UTF32 => 'UTF32', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + diff --git a/Language/src/V1/Entity.php b/Language/src/V1/Entity.php new file mode 100644 index 000000000000..280d97205cbc --- /dev/null +++ b/Language/src/V1/Entity.php @@ -0,0 +1,279 @@ +google.cloud.language.v1.Entity + */ +class Entity extends \Google\Protobuf\Internal\Message +{ + /** + * The representative name for the entity. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * The entity type. + * + * Generated from protobuf field .google.cloud.language.v1.Entity.Type type = 2; + */ + private $type = 0; + /** + * Metadata associated with the entity. + * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if + * available. The associated keys are "wikipedia_url" and "mid", respectively. + * + * Generated from protobuf field map metadata = 3; + */ + private $metadata; + /** + * The salience score associated with the entity in the [0, 1.0] range. + * The salience score for an entity provides information about the + * importance or centrality of that entity to the entire document text. + * Scores closer to 0 are less salient, while scores closer to 1.0 are highly + * salient. + * + * Generated from protobuf field float salience = 4; + */ + private $salience = 0.0; + /** + * The mentions of this entity in the input document. The API currently + * supports proper noun mentions. + * + * Generated from protobuf field repeated .google.cloud.language.v1.EntityMention mentions = 5; + */ + private $mentions; + /** + * For calls to [AnalyzeEntitySentiment][] or if + * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] + * is set to true, this field will contain the aggregate sentiment expressed + * for this entity in the provided document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 6; + */ + private $sentiment = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The representative name for the entity. + * @type int $type + * The entity type. + * @type array|\Google\Protobuf\Internal\MapField $metadata + * Metadata associated with the entity. + * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if + * available. The associated keys are "wikipedia_url" and "mid", respectively. + * @type float $salience + * The salience score associated with the entity in the [0, 1.0] range. + * The salience score for an entity provides information about the + * importance or centrality of that entity to the entire document text. + * Scores closer to 0 are less salient, while scores closer to 1.0 are highly + * salient. + * @type \Google\Cloud\Language\V1\EntityMention[]|\Google\Protobuf\Internal\RepeatedField $mentions + * The mentions of this entity in the input document. The API currently + * supports proper noun mentions. + * @type \Google\Cloud\Language\V1\Sentiment $sentiment + * For calls to [AnalyzeEntitySentiment][] or if + * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] + * is set to true, this field will contain the aggregate sentiment expressed + * for this entity in the provided document. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The representative name for the entity. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The representative name for the entity. + * + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * The entity type. + * + * Generated from protobuf field .google.cloud.language.v1.Entity.Type type = 2; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * The entity type. + * + * Generated from protobuf field .google.cloud.language.v1.Entity.Type type = 2; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\Entity_Type::class); + $this->type = $var; + + return $this; + } + + /** + * Metadata associated with the entity. + * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if + * available. The associated keys are "wikipedia_url" and "mid", respectively. + * + * Generated from protobuf field map metadata = 3; + * @return \Google\Protobuf\Internal\MapField + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * Metadata associated with the entity. + * Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if + * available. The associated keys are "wikipedia_url" and "mid", respectively. + * + * Generated from protobuf field map metadata = 3; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setMetadata($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->metadata = $arr; + + return $this; + } + + /** + * The salience score associated with the entity in the [0, 1.0] range. + * The salience score for an entity provides information about the + * importance or centrality of that entity to the entire document text. + * Scores closer to 0 are less salient, while scores closer to 1.0 are highly + * salient. + * + * Generated from protobuf field float salience = 4; + * @return float + */ + public function getSalience() + { + return $this->salience; + } + + /** + * The salience score associated with the entity in the [0, 1.0] range. + * The salience score for an entity provides information about the + * importance or centrality of that entity to the entire document text. + * Scores closer to 0 are less salient, while scores closer to 1.0 are highly + * salient. + * + * Generated from protobuf field float salience = 4; + * @param float $var + * @return $this + */ + public function setSalience($var) + { + GPBUtil::checkFloat($var); + $this->salience = $var; + + return $this; + } + + /** + * The mentions of this entity in the input document. The API currently + * supports proper noun mentions. + * + * Generated from protobuf field repeated .google.cloud.language.v1.EntityMention mentions = 5; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMentions() + { + return $this->mentions; + } + + /** + * The mentions of this entity in the input document. The API currently + * supports proper noun mentions. + * + * Generated from protobuf field repeated .google.cloud.language.v1.EntityMention mentions = 5; + * @param \Google\Cloud\Language\V1\EntityMention[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMentions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Language\V1\EntityMention::class); + $this->mentions = $arr; + + return $this; + } + + /** + * For calls to [AnalyzeEntitySentiment][] or if + * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] + * is set to true, this field will contain the aggregate sentiment expressed + * for this entity in the provided document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 6; + * @return \Google\Cloud\Language\V1\Sentiment + */ + public function getSentiment() + { + return $this->sentiment; + } + + /** + * For calls to [AnalyzeEntitySentiment][] or if + * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] + * is set to true, this field will contain the aggregate sentiment expressed + * for this entity in the provided document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 6; + * @param \Google\Cloud\Language\V1\Sentiment $var + * @return $this + */ + public function setSentiment($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Sentiment::class); + $this->sentiment = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/Entity/Type.php b/Language/src/V1/Entity/Type.php new file mode 100644 index 000000000000..3d72f1094919 --- /dev/null +++ b/Language/src/V1/Entity/Type.php @@ -0,0 +1,134 @@ +google.cloud.language.v1.Entity.Type + */ +class Type +{ + /** + * Unknown + * + * Generated from protobuf enum UNKNOWN = 0; + */ + const UNKNOWN = 0; + /** + * Person + * + * Generated from protobuf enum PERSON = 1; + */ + const PERSON = 1; + /** + * Location + * + * Generated from protobuf enum LOCATION = 2; + */ + const LOCATION = 2; + /** + * Organization + * + * Generated from protobuf enum ORGANIZATION = 3; + */ + const ORGANIZATION = 3; + /** + * Event + * + * Generated from protobuf enum EVENT = 4; + */ + const EVENT = 4; + /** + * Work of art + * + * Generated from protobuf enum WORK_OF_ART = 5; + */ + const WORK_OF_ART = 5; + /** + * Consumer goods + * + * Generated from protobuf enum CONSUMER_GOOD = 6; + */ + const CONSUMER_GOOD = 6; + /** + * Other types + * + * Generated from protobuf enum OTHER = 7; + */ + const OTHER = 7; + /** + * Phone number + * + * Generated from protobuf enum PHONE_NUMBER = 9; + */ + const PHONE_NUMBER = 9; + /** + * Address + * + * Generated from protobuf enum ADDRESS = 10; + */ + const ADDRESS = 10; + /** + * Date + * + * Generated from protobuf enum DATE = 11; + */ + const DATE = 11; + /** + * Number + * + * Generated from protobuf enum NUMBER = 12; + */ + const NUMBER = 12; + /** + * Price + * + * Generated from protobuf enum PRICE = 13; + */ + const PRICE = 13; + + private static $valueToName = [ + self::UNKNOWN => 'UNKNOWN', + self::PERSON => 'PERSON', + self::LOCATION => 'LOCATION', + self::ORGANIZATION => 'ORGANIZATION', + self::EVENT => 'EVENT', + self::WORK_OF_ART => 'WORK_OF_ART', + self::CONSUMER_GOOD => 'CONSUMER_GOOD', + self::OTHER => 'OTHER', + self::PHONE_NUMBER => 'PHONE_NUMBER', + self::ADDRESS => 'ADDRESS', + self::DATE => 'DATE', + self::NUMBER => 'NUMBER', + self::PRICE => 'PRICE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Type::class, \Google\Cloud\Language\V1\Entity_Type::class); + diff --git a/Language/src/V1/EntityMention.php b/Language/src/V1/EntityMention.php new file mode 100644 index 000000000000..251371b1d80c --- /dev/null +++ b/Language/src/V1/EntityMention.php @@ -0,0 +1,148 @@ +google.cloud.language.v1.EntityMention + */ +class EntityMention extends \Google\Protobuf\Internal\Message +{ + /** + * The mention text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + */ + private $text = null; + /** + * The type of the entity mention. + * + * Generated from protobuf field .google.cloud.language.v1.EntityMention.Type type = 2; + */ + private $type = 0; + /** + * For calls to [AnalyzeEntitySentiment][] or if + * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] + * is set to true, this field will contain the sentiment expressed for this + * mention of the entity in the provided document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 3; + */ + private $sentiment = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\TextSpan $text + * The mention text. + * @type int $type + * The type of the entity mention. + * @type \Google\Cloud\Language\V1\Sentiment $sentiment + * For calls to [AnalyzeEntitySentiment][] or if + * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] + * is set to true, this field will contain the sentiment expressed for this + * mention of the entity in the provided document. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The mention text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + * @return \Google\Cloud\Language\V1\TextSpan + */ + public function getText() + { + return $this->text; + } + + /** + * The mention text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + * @param \Google\Cloud\Language\V1\TextSpan $var + * @return $this + */ + public function setText($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\TextSpan::class); + $this->text = $var; + + return $this; + } + + /** + * The type of the entity mention. + * + * Generated from protobuf field .google.cloud.language.v1.EntityMention.Type type = 2; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * The type of the entity mention. + * + * Generated from protobuf field .google.cloud.language.v1.EntityMention.Type type = 2; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\EntityMention_Type::class); + $this->type = $var; + + return $this; + } + + /** + * For calls to [AnalyzeEntitySentiment][] or if + * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] + * is set to true, this field will contain the sentiment expressed for this + * mention of the entity in the provided document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 3; + * @return \Google\Cloud\Language\V1\Sentiment + */ + public function getSentiment() + { + return $this->sentiment; + } + + /** + * For calls to [AnalyzeEntitySentiment][] or if + * [AnnotateTextRequest.Features.extract_entity_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_entity_sentiment] + * is set to true, this field will contain the sentiment expressed for this + * mention of the entity in the provided document. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 3; + * @param \Google\Cloud\Language\V1\Sentiment $var + * @return $this + */ + public function setSentiment($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Sentiment::class); + $this->sentiment = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/EntityMention/Type.php b/Language/src/V1/EntityMention/Type.php new file mode 100644 index 000000000000..2fd75a738dfd --- /dev/null +++ b/Language/src/V1/EntityMention/Type.php @@ -0,0 +1,64 @@ +google.cloud.language.v1.EntityMention.Type + */ +class Type +{ + /** + * Unknown + * + * Generated from protobuf enum TYPE_UNKNOWN = 0; + */ + const TYPE_UNKNOWN = 0; + /** + * Proper name + * + * Generated from protobuf enum PROPER = 1; + */ + const PROPER = 1; + /** + * Common noun (or noun compound) + * + * Generated from protobuf enum COMMON = 2; + */ + const COMMON = 2; + + private static $valueToName = [ + self::TYPE_UNKNOWN => 'TYPE_UNKNOWN', + self::PROPER => 'PROPER', + self::COMMON => 'COMMON', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Type::class, \Google\Cloud\Language\V1\EntityMention_Type::class); + diff --git a/Language/src/V1/EntityMention_Type.php b/Language/src/V1/EntityMention_Type.php new file mode 100644 index 000000000000..187da39bbc0a --- /dev/null +++ b/Language/src/V1/EntityMention_Type.php @@ -0,0 +1,16 @@ +analyzeSentiment($document); + * } finally { + * $languageServiceClient->close(); + * } + * ``` + * + * @experimental + */ +class LanguageServiceGapicClient +{ + use GapicClientTrait; + + /** + * The name of the service. + */ + const SERVICE_NAME = 'google.cloud.language.v1.LanguageService'; + + /** + * The default address of the service. + */ + const SERVICE_ADDRESS = 'language.googleapis.com'; + + /** + * The default port of the service. + */ + const DEFAULT_SERVICE_PORT = 443; + + /** + * The name of the code generator, to be included in the agent header. + */ + const CODEGEN_NAME = 'gapic'; + + /** + * The default scopes required by the service. + */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-language', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'serviceAddress' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__.'/../resources/language_service_client_config.json', + 'descriptorsConfigPath' => __DIR__.'/../resources/language_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__.'/../resources/language_service_grpc_config.json', + 'credentialsConfig' => [ + 'scopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__.'/../resources/language_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Constructor. + * + * @param array $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $serviceAddress + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'language.googleapis.com:443'. + * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials + * The credentials to be used by the client to authorize API calls. This option + * accepts either a path to a credentials file, or a decoded credentials file as a + * PHP array. + * *Advanced usage*: In addition, this option can also accept a pre-constructed + * {@see \Google\Auth\FetchAuthTokenInterface} object or + * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these + * objects are provided, any settings in $credentialsConfig will be ignored. + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the client. + * For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()}. + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either a + * path to a JSON file, or a PHP array containing the decoded JSON data. + * By default this settings points to the default client config file, which is provided + * in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string `rest` + * or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already instantiated + * {@see \Google\ApiCore\Transport\TransportInterface} object. Note that when this + * object is provided, any settings in $transportConfig, and any $serviceAddress + * setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...] + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * } + * + * @throws ValidationException + * @experimental + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * Analyzes the sentiment of the provided text. + * + * Sample code: + * ``` + * $languageServiceClient = new LanguageServiceClient(); + * try { + * $document = new Document(); + * $response = $languageServiceClient->analyzeSentiment($document); + * } finally { + * $languageServiceClient->close(); + * } + * ``` + * + * @param Document $document Input document. + * @param array $optionalArgs { + * Optional. + * + * @type int $encodingType + * The encoding type used by the API to calculate sentence offsets. + * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Language\V1\AnalyzeSentimentResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function analyzeSentiment($document, array $optionalArgs = []) + { + $request = new AnalyzeSentimentRequest(); + $request->setDocument($document); + if (isset($optionalArgs['encodingType'])) { + $request->setEncodingType($optionalArgs['encodingType']); + } + + return $this->startCall( + 'AnalyzeSentiment', + AnalyzeSentimentResponse::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * + * Sample code: + * ``` + * $languageServiceClient = new LanguageServiceClient(); + * try { + * $document = new Document(); + * $response = $languageServiceClient->analyzeEntities($document); + * } finally { + * $languageServiceClient->close(); + * } + * ``` + * + * @param Document $document Input document. + * @param array $optionalArgs { + * Optional. + * + * @type int $encodingType + * The encoding type used by the API to calculate offsets. + * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Language\V1\AnalyzeEntitiesResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function analyzeEntities($document, array $optionalArgs = []) + { + $request = new AnalyzeEntitiesRequest(); + $request->setDocument($document); + if (isset($optionalArgs['encodingType'])) { + $request->setEncodingType($optionalArgs['encodingType']); + } + + return $this->startCall( + 'AnalyzeEntities', + AnalyzeEntitiesResponse::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Finds entities, similar to + * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] + * in the text and analyzes sentiment associated with each entity and its + * mentions. + * + * Sample code: + * ``` + * $languageServiceClient = new LanguageServiceClient(); + * try { + * $document = new Document(); + * $response = $languageServiceClient->analyzeEntitySentiment($document); + * } finally { + * $languageServiceClient->close(); + * } + * ``` + * + * @param Document $document Input document. + * @param array $optionalArgs { + * Optional. + * + * @type int $encodingType + * The encoding type used by the API to calculate offsets. + * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Language\V1\AnalyzeEntitySentimentResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function analyzeEntitySentiment($document, array $optionalArgs = []) + { + $request = new AnalyzeEntitySentimentRequest(); + $request->setDocument($document); + if (isset($optionalArgs['encodingType'])) { + $request->setEncodingType($optionalArgs['encodingType']); + } + + return $this->startCall( + 'AnalyzeEntitySentiment', + AnalyzeEntitySentimentResponse::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part of speech tags, dependency trees, and other + * properties. + * + * Sample code: + * ``` + * $languageServiceClient = new LanguageServiceClient(); + * try { + * $document = new Document(); + * $response = $languageServiceClient->analyzeSyntax($document); + * } finally { + * $languageServiceClient->close(); + * } + * ``` + * + * @param Document $document Input document. + * @param array $optionalArgs { + * Optional. + * + * @type int $encodingType + * The encoding type used by the API to calculate offsets. + * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Language\V1\AnalyzeSyntaxResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function analyzeSyntax($document, array $optionalArgs = []) + { + $request = new AnalyzeSyntaxRequest(); + $request->setDocument($document); + if (isset($optionalArgs['encodingType'])) { + $request->setEncodingType($optionalArgs['encodingType']); + } + + return $this->startCall( + 'AnalyzeSyntax', + AnalyzeSyntaxResponse::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * Classifies a document into categories. + * + * Sample code: + * ``` + * $languageServiceClient = new LanguageServiceClient(); + * try { + * $document = new Document(); + * $response = $languageServiceClient->classifyText($document); + * } finally { + * $languageServiceClient->close(); + * } + * ``` + * + * @param Document $document Input document. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Language\V1\ClassifyTextResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function classifyText($document, array $optionalArgs = []) + { + $request = new ClassifyTextRequest(); + $request->setDocument($document); + + return $this->startCall( + 'ClassifyText', + ClassifyTextResponse::class, + $optionalArgs, + $request + )->wait(); + } + + /** + * A convenience method that provides all the features that analyzeSentiment, + * analyzeEntities, and analyzeSyntax provide in one call. + * + * Sample code: + * ``` + * $languageServiceClient = new LanguageServiceClient(); + * try { + * $document = new Document(); + * $features = new AnnotateTextRequest\Features(); + * $response = $languageServiceClient->annotateText($document, $features); + * } finally { + * $languageServiceClient->close(); + * } + * ``` + * + * @param Document $document Input document. + * @param AnnotateTextRequest\Features $features The enabled features. + * @param array $optionalArgs { + * Optional. + * + * @type int $encodingType + * The encoding type used by the API to calculate offsets. + * For allowed values, use constants defined on {@see \Google\Cloud\Language\V1\EncodingType} + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a + * {@see Google\ApiCore\RetrySettings} object, or an associative array + * of retry settings parameters. See the documentation on + * {@see Google\ApiCore\RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Language\V1\AnnotateTextResponse + * + * @throws ApiException if the remote call fails + * @experimental + */ + public function annotateText($document, $features, array $optionalArgs = []) + { + $request = new AnnotateTextRequest(); + $request->setDocument($document); + $request->setFeatures($features); + if (isset($optionalArgs['encodingType'])) { + $request->setEncodingType($optionalArgs['encodingType']); + } + + return $this->startCall( + 'AnnotateText', + AnnotateTextResponse::class, + $optionalArgs, + $request + )->wait(); + } +} diff --git a/Language/src/V1/LanguageServiceClient.php b/Language/src/V1/LanguageServiceClient.php new file mode 100644 index 000000000000..39e546331cd9 --- /dev/null +++ b/Language/src/V1/LanguageServiceClient.php @@ -0,0 +1,38 @@ +_simpleRequest('/google.cloud.language.v1.LanguageService/AnalyzeSentiment', + $argument, + ['\Google\Cloud\Language\V1\AnalyzeSentimentResponse', 'decode'], + $metadata, $options); + } + + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * @param \Google\Cloud\Language\V1\AnalyzeEntitiesRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function AnalyzeEntities(\Google\Cloud\Language\V1\AnalyzeEntitiesRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnalyzeEntities', + $argument, + ['\Google\Cloud\Language\V1\AnalyzeEntitiesResponse', 'decode'], + $metadata, $options); + } + + /** + * Finds entities, similar to + * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] + * in the text and analyzes sentiment associated with each entity and its + * mentions. + * @param \Google\Cloud\Language\V1\AnalyzeEntitySentimentRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function AnalyzeEntitySentiment(\Google\Cloud\Language\V1\AnalyzeEntitySentimentRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnalyzeEntitySentiment', + $argument, + ['\Google\Cloud\Language\V1\AnalyzeEntitySentimentResponse', 'decode'], + $metadata, $options); + } + + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part of speech tags, dependency trees, and other + * properties. + * @param \Google\Cloud\Language\V1\AnalyzeSyntaxRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function AnalyzeSyntax(\Google\Cloud\Language\V1\AnalyzeSyntaxRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnalyzeSyntax', + $argument, + ['\Google\Cloud\Language\V1\AnalyzeSyntaxResponse', 'decode'], + $metadata, $options); + } + + /** + * Classifies a document into categories. + * @param \Google\Cloud\Language\V1\ClassifyTextRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function ClassifyText(\Google\Cloud\Language\V1\ClassifyTextRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/ClassifyText', + $argument, + ['\Google\Cloud\Language\V1\ClassifyTextResponse', 'decode'], + $metadata, $options); + } + + /** + * A convenience method that provides all the features that analyzeSentiment, + * analyzeEntities, and analyzeSyntax provide in one call. + * @param \Google\Cloud\Language\V1\AnnotateTextRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function AnnotateText(\Google\Cloud\Language\V1\AnnotateTextRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/AnnotateText', + $argument, + ['\Google\Cloud\Language\V1\AnnotateTextResponse', 'decode'], + $metadata, $options); + } + +} diff --git a/Language/src/V1/PartOfSpeech.php b/Language/src/V1/PartOfSpeech.php new file mode 100644 index 000000000000..97c84c7900e5 --- /dev/null +++ b/Language/src/V1/PartOfSpeech.php @@ -0,0 +1,443 @@ +google.cloud.language.v1.PartOfSpeech + */ +class PartOfSpeech extends \Google\Protobuf\Internal\Message +{ + /** + * The part of speech tag. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Tag tag = 1; + */ + private $tag = 0; + /** + * The grammatical aspect. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Aspect aspect = 2; + */ + private $aspect = 0; + /** + * The grammatical case. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Case case = 3; + */ + private $case = 0; + /** + * The grammatical form. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Form form = 4; + */ + private $form = 0; + /** + * The grammatical gender. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Gender gender = 5; + */ + private $gender = 0; + /** + * The grammatical mood. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Mood mood = 6; + */ + private $mood = 0; + /** + * The grammatical number. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Number number = 7; + */ + private $number = 0; + /** + * The grammatical person. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Person person = 8; + */ + private $person = 0; + /** + * The grammatical properness. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Proper proper = 9; + */ + private $proper = 0; + /** + * The grammatical reciprocity. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Reciprocity reciprocity = 10; + */ + private $reciprocity = 0; + /** + * The grammatical tense. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Tense tense = 11; + */ + private $tense = 0; + /** + * The grammatical voice. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Voice voice = 12; + */ + private $voice = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $tag + * The part of speech tag. + * @type int $aspect + * The grammatical aspect. + * @type int $case + * The grammatical case. + * @type int $form + * The grammatical form. + * @type int $gender + * The grammatical gender. + * @type int $mood + * The grammatical mood. + * @type int $number + * The grammatical number. + * @type int $person + * The grammatical person. + * @type int $proper + * The grammatical properness. + * @type int $reciprocity + * The grammatical reciprocity. + * @type int $tense + * The grammatical tense. + * @type int $voice + * The grammatical voice. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The part of speech tag. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Tag tag = 1; + * @return int + */ + public function getTag() + { + return $this->tag; + } + + /** + * The part of speech tag. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Tag tag = 1; + * @param int $var + * @return $this + */ + public function setTag($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Tag::class); + $this->tag = $var; + + return $this; + } + + /** + * The grammatical aspect. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Aspect aspect = 2; + * @return int + */ + public function getAspect() + { + return $this->aspect; + } + + /** + * The grammatical aspect. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Aspect aspect = 2; + * @param int $var + * @return $this + */ + public function setAspect($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Aspect::class); + $this->aspect = $var; + + return $this; + } + + /** + * The grammatical case. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Case case = 3; + * @return int + */ + public function getCase() + { + return $this->case; + } + + /** + * The grammatical case. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Case case = 3; + * @param int $var + * @return $this + */ + public function setCase($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Case::class); + $this->case = $var; + + return $this; + } + + /** + * The grammatical form. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Form form = 4; + * @return int + */ + public function getForm() + { + return $this->form; + } + + /** + * The grammatical form. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Form form = 4; + * @param int $var + * @return $this + */ + public function setForm($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Form::class); + $this->form = $var; + + return $this; + } + + /** + * The grammatical gender. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Gender gender = 5; + * @return int + */ + public function getGender() + { + return $this->gender; + } + + /** + * The grammatical gender. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Gender gender = 5; + * @param int $var + * @return $this + */ + public function setGender($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Gender::class); + $this->gender = $var; + + return $this; + } + + /** + * The grammatical mood. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Mood mood = 6; + * @return int + */ + public function getMood() + { + return $this->mood; + } + + /** + * The grammatical mood. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Mood mood = 6; + * @param int $var + * @return $this + */ + public function setMood($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Mood::class); + $this->mood = $var; + + return $this; + } + + /** + * The grammatical number. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Number number = 7; + * @return int + */ + public function getNumber() + { + return $this->number; + } + + /** + * The grammatical number. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Number number = 7; + * @param int $var + * @return $this + */ + public function setNumber($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Number::class); + $this->number = $var; + + return $this; + } + + /** + * The grammatical person. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Person person = 8; + * @return int + */ + public function getPerson() + { + return $this->person; + } + + /** + * The grammatical person. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Person person = 8; + * @param int $var + * @return $this + */ + public function setPerson($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Person::class); + $this->person = $var; + + return $this; + } + + /** + * The grammatical properness. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Proper proper = 9; + * @return int + */ + public function getProper() + { + return $this->proper; + } + + /** + * The grammatical properness. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Proper proper = 9; + * @param int $var + * @return $this + */ + public function setProper($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Proper::class); + $this->proper = $var; + + return $this; + } + + /** + * The grammatical reciprocity. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Reciprocity reciprocity = 10; + * @return int + */ + public function getReciprocity() + { + return $this->reciprocity; + } + + /** + * The grammatical reciprocity. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Reciprocity reciprocity = 10; + * @param int $var + * @return $this + */ + public function setReciprocity($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Reciprocity::class); + $this->reciprocity = $var; + + return $this; + } + + /** + * The grammatical tense. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Tense tense = 11; + * @return int + */ + public function getTense() + { + return $this->tense; + } + + /** + * The grammatical tense. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Tense tense = 11; + * @param int $var + * @return $this + */ + public function setTense($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Tense::class); + $this->tense = $var; + + return $this; + } + + /** + * The grammatical voice. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Voice voice = 12; + * @return int + */ + public function getVoice() + { + return $this->voice; + } + + /** + * The grammatical voice. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech.Voice voice = 12; + * @param int $var + * @return $this + */ + public function setVoice($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Language\V1\PartOfSpeech_Voice::class); + $this->voice = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/PartOfSpeech/Aspect.php b/Language/src/V1/PartOfSpeech/Aspect.php new file mode 100644 index 000000000000..95abc9c0df68 --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Aspect.php @@ -0,0 +1,71 @@ +google.cloud.language.v1.PartOfSpeech.Aspect + */ +class Aspect +{ + /** + * Aspect is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum ASPECT_UNKNOWN = 0; + */ + const ASPECT_UNKNOWN = 0; + /** + * Perfective + * + * Generated from protobuf enum PERFECTIVE = 1; + */ + const PERFECTIVE = 1; + /** + * Imperfective + * + * Generated from protobuf enum IMPERFECTIVE = 2; + */ + const IMPERFECTIVE = 2; + /** + * Progressive + * + * Generated from protobuf enum PROGRESSIVE = 3; + */ + const PROGRESSIVE = 3; + + private static $valueToName = [ + self::ASPECT_UNKNOWN => 'ASPECT_UNKNOWN', + self::PERFECTIVE => 'PERFECTIVE', + self::IMPERFECTIVE => 'IMPERFECTIVE', + self::PROGRESSIVE => 'PROGRESSIVE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Aspect::class, \Google\Cloud\Language\V1\PartOfSpeech_Aspect::class); + diff --git a/Language/src/V1/PartOfSpeech/Form.php b/Language/src/V1/PartOfSpeech/Form.php new file mode 100644 index 000000000000..0d3977bbd54a --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Form.php @@ -0,0 +1,130 @@ +google.cloud.language.v1.PartOfSpeech.Form + */ +class Form +{ + /** + * Form is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum FORM_UNKNOWN = 0; + */ + const FORM_UNKNOWN = 0; + /** + * Adnomial + * + * Generated from protobuf enum ADNOMIAL = 1; + */ + const ADNOMIAL = 1; + /** + * Auxiliary + * + * Generated from protobuf enum AUXILIARY = 2; + */ + const AUXILIARY = 2; + /** + * Complementizer + * + * Generated from protobuf enum COMPLEMENTIZER = 3; + */ + const COMPLEMENTIZER = 3; + /** + * Final ending + * + * Generated from protobuf enum FINAL_ENDING = 4; + */ + const FINAL_ENDING = 4; + /** + * Gerund + * + * Generated from protobuf enum GERUND = 5; + */ + const GERUND = 5; + /** + * Realis + * + * Generated from protobuf enum REALIS = 6; + */ + const REALIS = 6; + /** + * Irrealis + * + * Generated from protobuf enum IRREALIS = 7; + */ + const IRREALIS = 7; + /** + * Short form + * + * Generated from protobuf enum SHORT = 8; + */ + const SHORT = 8; + /** + * Long form + * + * Generated from protobuf enum LONG = 9; + */ + const LONG = 9; + /** + * Order form + * + * Generated from protobuf enum ORDER = 10; + */ + const ORDER = 10; + /** + * Specific form + * + * Generated from protobuf enum SPECIFIC = 11; + */ + const SPECIFIC = 11; + + private static $valueToName = [ + self::FORM_UNKNOWN => 'FORM_UNKNOWN', + self::ADNOMIAL => 'ADNOMIAL', + self::AUXILIARY => 'AUXILIARY', + self::COMPLEMENTIZER => 'COMPLEMENTIZER', + self::FINAL_ENDING => 'FINAL_ENDING', + self::GERUND => 'GERUND', + self::REALIS => 'REALIS', + self::IRREALIS => 'IRREALIS', + self::SHORT => 'SHORT', + self::LONG => 'LONG', + self::ORDER => 'ORDER', + self::SPECIFIC => 'SPECIFIC', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Form::class, \Google\Cloud\Language\V1\PartOfSpeech_Form::class); + diff --git a/Language/src/V1/PartOfSpeech/Gender.php b/Language/src/V1/PartOfSpeech/Gender.php new file mode 100644 index 000000000000..510fead88faf --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Gender.php @@ -0,0 +1,71 @@ +google.cloud.language.v1.PartOfSpeech.Gender + */ +class Gender +{ + /** + * Gender is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum GENDER_UNKNOWN = 0; + */ + const GENDER_UNKNOWN = 0; + /** + * Feminine + * + * Generated from protobuf enum FEMININE = 1; + */ + const FEMININE = 1; + /** + * Masculine + * + * Generated from protobuf enum MASCULINE = 2; + */ + const MASCULINE = 2; + /** + * Neuter + * + * Generated from protobuf enum NEUTER = 3; + */ + const NEUTER = 3; + + private static $valueToName = [ + self::GENDER_UNKNOWN => 'GENDER_UNKNOWN', + self::FEMININE => 'FEMININE', + self::MASCULINE => 'MASCULINE', + self::NEUTER => 'NEUTER', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Gender::class, \Google\Cloud\Language\V1\PartOfSpeech_Gender::class); + diff --git a/Language/src/V1/PartOfSpeech/Mood.php b/Language/src/V1/PartOfSpeech/Mood.php new file mode 100644 index 000000000000..3b0c97066083 --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Mood.php @@ -0,0 +1,92 @@ +google.cloud.language.v1.PartOfSpeech.Mood + */ +class Mood +{ + /** + * Mood is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum MOOD_UNKNOWN = 0; + */ + const MOOD_UNKNOWN = 0; + /** + * Conditional + * + * Generated from protobuf enum CONDITIONAL_MOOD = 1; + */ + const CONDITIONAL_MOOD = 1; + /** + * Imperative + * + * Generated from protobuf enum IMPERATIVE = 2; + */ + const IMPERATIVE = 2; + /** + * Indicative + * + * Generated from protobuf enum INDICATIVE = 3; + */ + const INDICATIVE = 3; + /** + * Interrogative + * + * Generated from protobuf enum INTERROGATIVE = 4; + */ + const INTERROGATIVE = 4; + /** + * Jussive + * + * Generated from protobuf enum JUSSIVE = 5; + */ + const JUSSIVE = 5; + /** + * Subjunctive + * + * Generated from protobuf enum SUBJUNCTIVE = 6; + */ + const SUBJUNCTIVE = 6; + + private static $valueToName = [ + self::MOOD_UNKNOWN => 'MOOD_UNKNOWN', + self::CONDITIONAL_MOOD => 'CONDITIONAL_MOOD', + self::IMPERATIVE => 'IMPERATIVE', + self::INDICATIVE => 'INDICATIVE', + self::INTERROGATIVE => 'INTERROGATIVE', + self::JUSSIVE => 'JUSSIVE', + self::SUBJUNCTIVE => 'SUBJUNCTIVE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Mood::class, \Google\Cloud\Language\V1\PartOfSpeech_Mood::class); + diff --git a/Language/src/V1/PartOfSpeech/Number.php b/Language/src/V1/PartOfSpeech/Number.php new file mode 100644 index 000000000000..1663eed86eb7 --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Number.php @@ -0,0 +1,71 @@ +google.cloud.language.v1.PartOfSpeech.Number + */ +class Number +{ + /** + * Number is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum NUMBER_UNKNOWN = 0; + */ + const NUMBER_UNKNOWN = 0; + /** + * Singular + * + * Generated from protobuf enum SINGULAR = 1; + */ + const SINGULAR = 1; + /** + * Plural + * + * Generated from protobuf enum PLURAL = 2; + */ + const PLURAL = 2; + /** + * Dual + * + * Generated from protobuf enum DUAL = 3; + */ + const DUAL = 3; + + private static $valueToName = [ + self::NUMBER_UNKNOWN => 'NUMBER_UNKNOWN', + self::SINGULAR => 'SINGULAR', + self::PLURAL => 'PLURAL', + self::DUAL => 'DUAL', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Number::class, \Google\Cloud\Language\V1\PartOfSpeech_Number::class); + diff --git a/Language/src/V1/PartOfSpeech/PBCase.php b/Language/src/V1/PartOfSpeech/PBCase.php new file mode 100644 index 000000000000..156b6963e012 --- /dev/null +++ b/Language/src/V1/PartOfSpeech/PBCase.php @@ -0,0 +1,150 @@ +google.cloud.language.v1.PartOfSpeech.Case + */ +class PBCase +{ + /** + * Case is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum CASE_UNKNOWN = 0; + */ + const CASE_UNKNOWN = 0; + /** + * Accusative + * + * Generated from protobuf enum ACCUSATIVE = 1; + */ + const ACCUSATIVE = 1; + /** + * Adverbial + * + * Generated from protobuf enum ADVERBIAL = 2; + */ + const ADVERBIAL = 2; + /** + * Complementive + * + * Generated from protobuf enum COMPLEMENTIVE = 3; + */ + const COMPLEMENTIVE = 3; + /** + * Dative + * + * Generated from protobuf enum DATIVE = 4; + */ + const DATIVE = 4; + /** + * Genitive + * + * Generated from protobuf enum GENITIVE = 5; + */ + const GENITIVE = 5; + /** + * Instrumental + * + * Generated from protobuf enum INSTRUMENTAL = 6; + */ + const INSTRUMENTAL = 6; + /** + * Locative + * + * Generated from protobuf enum LOCATIVE = 7; + */ + const LOCATIVE = 7; + /** + * Nominative + * + * Generated from protobuf enum NOMINATIVE = 8; + */ + const NOMINATIVE = 8; + /** + * Oblique + * + * Generated from protobuf enum OBLIQUE = 9; + */ + const OBLIQUE = 9; + /** + * Partitive + * + * Generated from protobuf enum PARTITIVE = 10; + */ + const PARTITIVE = 10; + /** + * Prepositional + * + * Generated from protobuf enum PREPOSITIONAL = 11; + */ + const PREPOSITIONAL = 11; + /** + * Reflexive + * + * Generated from protobuf enum REFLEXIVE_CASE = 12; + */ + const REFLEXIVE_CASE = 12; + /** + * Relative + * + * Generated from protobuf enum RELATIVE_CASE = 13; + */ + const RELATIVE_CASE = 13; + /** + * Vocative + * + * Generated from protobuf enum VOCATIVE = 14; + */ + const VOCATIVE = 14; + + private static $valueToName = [ + self::CASE_UNKNOWN => 'CASE_UNKNOWN', + self::ACCUSATIVE => 'ACCUSATIVE', + self::ADVERBIAL => 'ADVERBIAL', + self::COMPLEMENTIVE => 'COMPLEMENTIVE', + self::DATIVE => 'DATIVE', + self::GENITIVE => 'GENITIVE', + self::INSTRUMENTAL => 'INSTRUMENTAL', + self::LOCATIVE => 'LOCATIVE', + self::NOMINATIVE => 'NOMINATIVE', + self::OBLIQUE => 'OBLIQUE', + self::PARTITIVE => 'PARTITIVE', + self::PREPOSITIONAL => 'PREPOSITIONAL', + self::REFLEXIVE_CASE => 'REFLEXIVE_CASE', + self::RELATIVE_CASE => 'RELATIVE_CASE', + self::VOCATIVE => 'VOCATIVE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(PBCase::class, \Google\Cloud\Language\V1\PartOfSpeech_Case::class); + diff --git a/Language/src/V1/PartOfSpeech/Person.php b/Language/src/V1/PartOfSpeech/Person.php new file mode 100644 index 000000000000..ba1a5a463fed --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Person.php @@ -0,0 +1,78 @@ +google.cloud.language.v1.PartOfSpeech.Person + */ +class Person +{ + /** + * Person is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum PERSON_UNKNOWN = 0; + */ + const PERSON_UNKNOWN = 0; + /** + * First + * + * Generated from protobuf enum FIRST = 1; + */ + const FIRST = 1; + /** + * Second + * + * Generated from protobuf enum SECOND = 2; + */ + const SECOND = 2; + /** + * Third + * + * Generated from protobuf enum THIRD = 3; + */ + const THIRD = 3; + /** + * Reflexive + * + * Generated from protobuf enum REFLEXIVE_PERSON = 4; + */ + const REFLEXIVE_PERSON = 4; + + private static $valueToName = [ + self::PERSON_UNKNOWN => 'PERSON_UNKNOWN', + self::FIRST => 'FIRST', + self::SECOND => 'SECOND', + self::THIRD => 'THIRD', + self::REFLEXIVE_PERSON => 'REFLEXIVE_PERSON', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Person::class, \Google\Cloud\Language\V1\PartOfSpeech_Person::class); + diff --git a/Language/src/V1/PartOfSpeech/Proper.php b/Language/src/V1/PartOfSpeech/Proper.php new file mode 100644 index 000000000000..694ba0a32b40 --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Proper.php @@ -0,0 +1,64 @@ +google.cloud.language.v1.PartOfSpeech.Proper + */ +class Proper +{ + /** + * Proper is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum PROPER_UNKNOWN = 0; + */ + const PROPER_UNKNOWN = 0; + /** + * Proper + * + * Generated from protobuf enum PROPER = 1; + */ + const PROPER = 1; + /** + * Not proper + * + * Generated from protobuf enum NOT_PROPER = 2; + */ + const NOT_PROPER = 2; + + private static $valueToName = [ + self::PROPER_UNKNOWN => 'PROPER_UNKNOWN', + self::PROPER => 'PROPER', + self::NOT_PROPER => 'NOT_PROPER', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Proper::class, \Google\Cloud\Language\V1\PartOfSpeech_Proper::class); + diff --git a/Language/src/V1/PartOfSpeech/Reciprocity.php b/Language/src/V1/PartOfSpeech/Reciprocity.php new file mode 100644 index 000000000000..c849d6e3463c --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Reciprocity.php @@ -0,0 +1,65 @@ +google.cloud.language.v1.PartOfSpeech.Reciprocity + */ +class Reciprocity +{ + /** + * Reciprocity is not applicable in the analyzed language or is not + * predicted. + * + * Generated from protobuf enum RECIPROCITY_UNKNOWN = 0; + */ + const RECIPROCITY_UNKNOWN = 0; + /** + * Reciprocal + * + * Generated from protobuf enum RECIPROCAL = 1; + */ + const RECIPROCAL = 1; + /** + * Non-reciprocal + * + * Generated from protobuf enum NON_RECIPROCAL = 2; + */ + const NON_RECIPROCAL = 2; + + private static $valueToName = [ + self::RECIPROCITY_UNKNOWN => 'RECIPROCITY_UNKNOWN', + self::RECIPROCAL => 'RECIPROCAL', + self::NON_RECIPROCAL => 'NON_RECIPROCAL', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Reciprocity::class, \Google\Cloud\Language\V1\PartOfSpeech_Reciprocity::class); + diff --git a/Language/src/V1/PartOfSpeech/Tag.php b/Language/src/V1/PartOfSpeech/Tag.php new file mode 100644 index 000000000000..3e67b7be11ae --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Tag.php @@ -0,0 +1,141 @@ +google.cloud.language.v1.PartOfSpeech.Tag + */ +class Tag +{ + /** + * Unknown + * + * Generated from protobuf enum UNKNOWN = 0; + */ + const UNKNOWN = 0; + /** + * Adjective + * + * Generated from protobuf enum ADJ = 1; + */ + const ADJ = 1; + /** + * Adposition (preposition and postposition) + * + * Generated from protobuf enum ADP = 2; + */ + const ADP = 2; + /** + * Adverb + * + * Generated from protobuf enum ADV = 3; + */ + const ADV = 3; + /** + * Conjunction + * + * Generated from protobuf enum CONJ = 4; + */ + const CONJ = 4; + /** + * Determiner + * + * Generated from protobuf enum DET = 5; + */ + const DET = 5; + /** + * Noun (common and proper) + * + * Generated from protobuf enum NOUN = 6; + */ + const NOUN = 6; + /** + * Cardinal number + * + * Generated from protobuf enum NUM = 7; + */ + const NUM = 7; + /** + * Pronoun + * + * Generated from protobuf enum PRON = 8; + */ + const PRON = 8; + /** + * Particle or other function word + * + * Generated from protobuf enum PRT = 9; + */ + const PRT = 9; + /** + * Punctuation + * + * Generated from protobuf enum PUNCT = 10; + */ + const PUNCT = 10; + /** + * Verb (all tenses and modes) + * + * Generated from protobuf enum VERB = 11; + */ + const VERB = 11; + /** + * Other: foreign words, typos, abbreviations + * + * Generated from protobuf enum X = 12; + */ + const X = 12; + /** + * Affix + * + * Generated from protobuf enum AFFIX = 13; + */ + const AFFIX = 13; + + private static $valueToName = [ + self::UNKNOWN => 'UNKNOWN', + self::ADJ => 'ADJ', + self::ADP => 'ADP', + self::ADV => 'ADV', + self::CONJ => 'CONJ', + self::DET => 'DET', + self::NOUN => 'NOUN', + self::NUM => 'NUM', + self::PRON => 'PRON', + self::PRT => 'PRT', + self::PUNCT => 'PUNCT', + self::VERB => 'VERB', + self::X => 'X', + self::AFFIX => 'AFFIX', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Tag::class, \Google\Cloud\Language\V1\PartOfSpeech_Tag::class); + diff --git a/Language/src/V1/PartOfSpeech/Tense.php b/Language/src/V1/PartOfSpeech/Tense.php new file mode 100644 index 000000000000..3d0e65618a04 --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Tense.php @@ -0,0 +1,92 @@ +google.cloud.language.v1.PartOfSpeech.Tense + */ +class Tense +{ + /** + * Tense is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum TENSE_UNKNOWN = 0; + */ + const TENSE_UNKNOWN = 0; + /** + * Conditional + * + * Generated from protobuf enum CONDITIONAL_TENSE = 1; + */ + const CONDITIONAL_TENSE = 1; + /** + * Future + * + * Generated from protobuf enum FUTURE = 2; + */ + const FUTURE = 2; + /** + * Past + * + * Generated from protobuf enum PAST = 3; + */ + const PAST = 3; + /** + * Present + * + * Generated from protobuf enum PRESENT = 4; + */ + const PRESENT = 4; + /** + * Imperfect + * + * Generated from protobuf enum IMPERFECT = 5; + */ + const IMPERFECT = 5; + /** + * Pluperfect + * + * Generated from protobuf enum PLUPERFECT = 6; + */ + const PLUPERFECT = 6; + + private static $valueToName = [ + self::TENSE_UNKNOWN => 'TENSE_UNKNOWN', + self::CONDITIONAL_TENSE => 'CONDITIONAL_TENSE', + self::FUTURE => 'FUTURE', + self::PAST => 'PAST', + self::PRESENT => 'PRESENT', + self::IMPERFECT => 'IMPERFECT', + self::PLUPERFECT => 'PLUPERFECT', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Tense::class, \Google\Cloud\Language\V1\PartOfSpeech_Tense::class); + diff --git a/Language/src/V1/PartOfSpeech/Voice.php b/Language/src/V1/PartOfSpeech/Voice.php new file mode 100644 index 000000000000..ea5996d4fe4d --- /dev/null +++ b/Language/src/V1/PartOfSpeech/Voice.php @@ -0,0 +1,72 @@ +google.cloud.language.v1.PartOfSpeech.Voice + */ +class Voice +{ + /** + * Voice is not applicable in the analyzed language or is not predicted. + * + * Generated from protobuf enum VOICE_UNKNOWN = 0; + */ + const VOICE_UNKNOWN = 0; + /** + * Active + * + * Generated from protobuf enum ACTIVE = 1; + */ + const ACTIVE = 1; + /** + * Causative + * + * Generated from protobuf enum CAUSATIVE = 2; + */ + const CAUSATIVE = 2; + /** + * Passive + * + * Generated from protobuf enum PASSIVE = 3; + */ + const PASSIVE = 3; + + private static $valueToName = [ + self::VOICE_UNKNOWN => 'VOICE_UNKNOWN', + self::ACTIVE => 'ACTIVE', + self::CAUSATIVE => 'CAUSATIVE', + self::PASSIVE => 'PASSIVE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Voice::class, \Google\Cloud\Language\V1\PartOfSpeech_Voice::class); + diff --git a/Language/src/V1/PartOfSpeech_Aspect.php b/Language/src/V1/PartOfSpeech_Aspect.php new file mode 100644 index 000000000000..87d4732dd0ef --- /dev/null +++ b/Language/src/V1/PartOfSpeech_Aspect.php @@ -0,0 +1,16 @@ + '/Users/dsupplee/Downloads/gcloud.json' +]); + +$document = new Document([ + 'content' => 'Greetings from Michigan!', + 'type' => Type::PLAIN_TEXT +]); +$features = new Features([ + 'extract_document_sentiment' => true, + 'extract_entities' => true, + 'extract_syntax' => true +]); + +// Annotate the document. +$response = $client->annotateText($document, $features); + +// Check the sentiment. +$sentimentScore = $response->getDocumentSentiment() + ->getScore(); + +if ($sentimentScore > 0) { + echo 'This is a positive message.' . PHP_EOL; +} + +// Detect entities. +foreach ($response->getEntities() as $entity) { + printf( + '[%s] %s', + EntityType::name($entity->getType()), + $entity->getName() + ); + echo PHP_EOL; +} + +// Parse the syntax. +foreach ($response->getTokens() as $token) { + $speechTag = Tag::name($token->getPartOfSpeech()->getTag()); + + printf( + '[%s] %s', + $speechTag, + $token->getText()->getContent() + ); + echo PHP_EOL; +} +``` diff --git a/Language/src/V1/Sentence.php b/Language/src/V1/Sentence.php new file mode 100644 index 000000000000..961a08054e76 --- /dev/null +++ b/Language/src/V1/Sentence.php @@ -0,0 +1,109 @@ +google.cloud.language.v1.Sentence + */ +class Sentence extends \Google\Protobuf\Internal\Message +{ + /** + * The sentence text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + */ + private $text = null; + /** + * For calls to [AnalyzeSentiment][] or if + * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment] + * is set to true, this field will contain the sentiment for the sentence. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 2; + */ + private $sentiment = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\TextSpan $text + * The sentence text. + * @type \Google\Cloud\Language\V1\Sentiment $sentiment + * For calls to [AnalyzeSentiment][] or if + * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment] + * is set to true, this field will contain the sentiment for the sentence. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The sentence text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + * @return \Google\Cloud\Language\V1\TextSpan + */ + public function getText() + { + return $this->text; + } + + /** + * The sentence text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + * @param \Google\Cloud\Language\V1\TextSpan $var + * @return $this + */ + public function setText($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\TextSpan::class); + $this->text = $var; + + return $this; + } + + /** + * For calls to [AnalyzeSentiment][] or if + * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment] + * is set to true, this field will contain the sentiment for the sentence. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 2; + * @return \Google\Cloud\Language\V1\Sentiment + */ + public function getSentiment() + { + return $this->sentiment; + } + + /** + * For calls to [AnalyzeSentiment][] or if + * [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1.AnnotateTextRequest.Features.extract_document_sentiment] + * is set to true, this field will contain the sentiment for the sentence. + * + * Generated from protobuf field .google.cloud.language.v1.Sentiment sentiment = 2; + * @param \Google\Cloud\Language\V1\Sentiment $var + * @return $this + */ + public function setSentiment($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\Sentiment::class); + $this->sentiment = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/Sentiment.php b/Language/src/V1/Sentiment.php new file mode 100644 index 000000000000..5bc1b78f8800 --- /dev/null +++ b/Language/src/V1/Sentiment.php @@ -0,0 +1,114 @@ +google.cloud.language.v1.Sentiment + */ +class Sentiment extends \Google\Protobuf\Internal\Message +{ + /** + * A non-negative number in the [0, +inf) range, which represents + * the absolute magnitude of sentiment regardless of score (positive or + * negative). + * + * Generated from protobuf field float magnitude = 2; + */ + private $magnitude = 0.0; + /** + * Sentiment score between -1.0 (negative sentiment) and 1.0 + * (positive sentiment). + * + * Generated from protobuf field float score = 3; + */ + private $score = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type float $magnitude + * A non-negative number in the [0, +inf) range, which represents + * the absolute magnitude of sentiment regardless of score (positive or + * negative). + * @type float $score + * Sentiment score between -1.0 (negative sentiment) and 1.0 + * (positive sentiment). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * A non-negative number in the [0, +inf) range, which represents + * the absolute magnitude of sentiment regardless of score (positive or + * negative). + * + * Generated from protobuf field float magnitude = 2; + * @return float + */ + public function getMagnitude() + { + return $this->magnitude; + } + + /** + * A non-negative number in the [0, +inf) range, which represents + * the absolute magnitude of sentiment regardless of score (positive or + * negative). + * + * Generated from protobuf field float magnitude = 2; + * @param float $var + * @return $this + */ + public function setMagnitude($var) + { + GPBUtil::checkFloat($var); + $this->magnitude = $var; + + return $this; + } + + /** + * Sentiment score between -1.0 (negative sentiment) and 1.0 + * (positive sentiment). + * + * Generated from protobuf field float score = 3; + * @return float + */ + public function getScore() + { + return $this->score; + } + + /** + * Sentiment score between -1.0 (negative sentiment) and 1.0 + * (positive sentiment). + * + * Generated from protobuf field float score = 3; + * @param float $var + * @return $this + */ + public function setScore($var) + { + GPBUtil::checkFloat($var); + $this->score = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/TextSpan.php b/Language/src/V1/TextSpan.php new file mode 100644 index 000000000000..8f884f53270e --- /dev/null +++ b/Language/src/V1/TextSpan.php @@ -0,0 +1,113 @@ +google.cloud.language.v1.TextSpan + */ +class TextSpan extends \Google\Protobuf\Internal\Message +{ + /** + * The content of the output text. + * + * Generated from protobuf field string content = 1; + */ + private $content = ''; + /** + * The API calculates the beginning offset of the content in the original + * document according to the + * [EncodingType][google.cloud.language.v1.EncodingType] specified in the API + * request. + * + * Generated from protobuf field int32 begin_offset = 2; + */ + private $begin_offset = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $content + * The content of the output text. + * @type int $begin_offset + * The API calculates the beginning offset of the content in the original + * document according to the + * [EncodingType][google.cloud.language.v1.EncodingType] specified in the API + * request. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The content of the output text. + * + * Generated from protobuf field string content = 1; + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * The content of the output text. + * + * Generated from protobuf field string content = 1; + * @param string $var + * @return $this + */ + public function setContent($var) + { + GPBUtil::checkString($var, True); + $this->content = $var; + + return $this; + } + + /** + * The API calculates the beginning offset of the content in the original + * document according to the + * [EncodingType][google.cloud.language.v1.EncodingType] specified in the API + * request. + * + * Generated from protobuf field int32 begin_offset = 2; + * @return int + */ + public function getBeginOffset() + { + return $this->begin_offset; + } + + /** + * The API calculates the beginning offset of the content in the original + * document according to the + * [EncodingType][google.cloud.language.v1.EncodingType] specified in the API + * request. + * + * Generated from protobuf field int32 begin_offset = 2; + * @param int $var + * @return $this + */ + public function setBeginOffset($var) + { + GPBUtil::checkInt32($var); + $this->begin_offset = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/Token.php b/Language/src/V1/Token.php new file mode 100644 index 000000000000..6baa1b9ec399 --- /dev/null +++ b/Language/src/V1/Token.php @@ -0,0 +1,169 @@ +google.cloud.language.v1.Token + */ +class Token extends \Google\Protobuf\Internal\Message +{ + /** + * The token text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + */ + private $text = null; + /** + * Parts of speech tag for this token. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech part_of_speech = 2; + */ + private $part_of_speech = null; + /** + * Dependency tree parse for this token. + * + * Generated from protobuf field .google.cloud.language.v1.DependencyEdge dependency_edge = 3; + */ + private $dependency_edge = null; + /** + * [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + * + * Generated from protobuf field string lemma = 4; + */ + private $lemma = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Language\V1\TextSpan $text + * The token text. + * @type \Google\Cloud\Language\V1\PartOfSpeech $part_of_speech + * Parts of speech tag for this token. + * @type \Google\Cloud\Language\V1\DependencyEdge $dependency_edge + * Dependency tree parse for this token. + * @type string $lemma + * [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Language\V1\LanguageService::initOnce(); + parent::__construct($data); + } + + /** + * The token text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + * @return \Google\Cloud\Language\V1\TextSpan + */ + public function getText() + { + return $this->text; + } + + /** + * The token text. + * + * Generated from protobuf field .google.cloud.language.v1.TextSpan text = 1; + * @param \Google\Cloud\Language\V1\TextSpan $var + * @return $this + */ + public function setText($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\TextSpan::class); + $this->text = $var; + + return $this; + } + + /** + * Parts of speech tag for this token. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech part_of_speech = 2; + * @return \Google\Cloud\Language\V1\PartOfSpeech + */ + public function getPartOfSpeech() + { + return $this->part_of_speech; + } + + /** + * Parts of speech tag for this token. + * + * Generated from protobuf field .google.cloud.language.v1.PartOfSpeech part_of_speech = 2; + * @param \Google\Cloud\Language\V1\PartOfSpeech $var + * @return $this + */ + public function setPartOfSpeech($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\PartOfSpeech::class); + $this->part_of_speech = $var; + + return $this; + } + + /** + * Dependency tree parse for this token. + * + * Generated from protobuf field .google.cloud.language.v1.DependencyEdge dependency_edge = 3; + * @return \Google\Cloud\Language\V1\DependencyEdge + */ + public function getDependencyEdge() + { + return $this->dependency_edge; + } + + /** + * Dependency tree parse for this token. + * + * Generated from protobuf field .google.cloud.language.v1.DependencyEdge dependency_edge = 3; + * @param \Google\Cloud\Language\V1\DependencyEdge $var + * @return $this + */ + public function setDependencyEdge($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Language\V1\DependencyEdge::class); + $this->dependency_edge = $var; + + return $this; + } + + /** + * [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + * + * Generated from protobuf field string lemma = 4; + * @return string + */ + public function getLemma() + { + return $this->lemma; + } + + /** + * [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + * + * Generated from protobuf field string lemma = 4; + * @param string $var + * @return $this + */ + public function setLemma($var) + { + GPBUtil::checkString($var, True); + $this->lemma = $var; + + return $this; + } + +} + diff --git a/Language/src/V1/resources/language_service_client_config.json b/Language/src/V1/resources/language_service_client_config.json new file mode 100644 index 000000000000..d370c9322e79 --- /dev/null +++ b/Language/src/V1/resources/language_service_client_config.json @@ -0,0 +1,56 @@ +{ + "interfaces": { + "google.cloud.language.v1.LanguageService": { + "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "non_idempotent": [] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "AnalyzeSentiment": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeEntities": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeEntitySentiment": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnalyzeSyntax": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ClassifyText": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "AnnotateText": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/Language/src/V1/resources/language_service_descriptor_config.php b/Language/src/V1/resources/language_service_descriptor_config.php new file mode 100644 index 000000000000..94504e67047b --- /dev/null +++ b/Language/src/V1/resources/language_service_descriptor_config.php @@ -0,0 +1,8 @@ + [ + 'google.cloud.language.v1.LanguageService' => [ + ], + ], +]; diff --git a/Language/src/V1/resources/language_service_rest_client_config.php b/Language/src/V1/resources/language_service_rest_client_config.php new file mode 100644 index 000000000000..b4c1f8cc7c1a --- /dev/null +++ b/Language/src/V1/resources/language_service_rest_client_config.php @@ -0,0 +1,38 @@ + [ + 'google.cloud.language.v1.LanguageService' => [ + 'AnalyzeSentiment' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/documents:analyzeSentiment', + 'body' => '*', + ], + 'AnalyzeEntities' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/documents:analyzeEntities', + 'body' => '*', + ], + 'AnalyzeEntitySentiment' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/documents:analyzeEntitySentiment', + 'body' => '*', + ], + 'AnalyzeSyntax' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/documents:analyzeSyntax', + 'body' => '*', + ], + 'ClassifyText' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/documents:classifyText', + 'body' => '*', + ], + 'AnnotateText' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/documents:annotateText', + 'body' => '*', + ], + ], + ], +]; diff --git a/Language/src/V1beta2/README.md b/Language/src/V1beta2/README.md index c89dbd02a159..f9a3f0cb5460 100644 --- a/Language/src/V1beta2/README.md +++ b/Language/src/V1beta2/README.md @@ -5,14 +5,57 @@ ```php require 'vendor/autoload.php'; +use Google\Cloud\Language\V1beta2\AnnotateTextRequest\Features; use Google\Cloud\Language\V1beta2\Document; +use Google\Cloud\Language\V1beta2\Document\Type; +use Google\Cloud\Language\V1beta2\Entity\Type as EntityType; use Google\Cloud\Language\V1beta2\LanguageServiceClient; +use Google\Cloud\Language\V1beta2\PartOfSpeech\Tag; -$languageServiceClient = new LanguageServiceClient(); -try { - $document = new Document(); - $response = $languageServiceClient->analyzeSentiment($document); -} finally { - $languageServiceClient->close(); +$client = new LanguageServiceClient([ + 'credentials' => '/Users/dsupplee/Downloads/gcloud.json' +]); + +$document = new Document([ + 'content' => 'Greetings from Michigan!', + 'type' => Type::PLAIN_TEXT +]); +$features = new Features([ + 'extract_document_sentiment' => true, + 'extract_entities' => true, + 'extract_syntax' => true +]); + +// Annotate the document. +$response = $client->annotateText($document, $features); + +// Check the sentiment. +$sentimentScore = $response->getDocumentSentiment() + ->getScore(); + +if ($sentimentScore > 0) { + echo 'This is a positive message.' . PHP_EOL; +} + +// Detect entities. +foreach ($response->getEntities() as $entity) { + printf( + '[%s] %s', + EntityType::name($entity->getType()), + $entity->getName() + ); + echo PHP_EOL; +} + +// Parse the syntax. +foreach ($response->getTokens() as $token) { + $speechTag = Tag::name($token->getPartOfSpeech()->getTag()); + + printf( + '[%s] %s', + $speechTag, + $token->getText()->getContent() + ); + echo PHP_EOL; } ``` diff --git a/Language/synth.metadata b/Language/synth.metadata index 99d091bf261e..8d5d56ff6afc 100644 --- a/Language/synth.metadata +++ b/Language/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-03-29T10:01:35.811232Z", + "updateTime": "2019-04-01T15:42:20.685206Z", "sources": [ { "generator": { @@ -12,12 +12,22 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "37386f1ebcaed51bcb7d15d00124d22c38606e45", - "internalRef": "240841842" + "sha": "396a61102a4ca1e08194a6a52026d2d17834bc66", + "internalRef": "241317525" } } ], "destinations": [ + { + "client": { + "source": "googleapis", + "apiName": "language", + "apiVersion": "v1", + "language": "php", + "generator": "gapic", + "config": "google/cloud/language/artman_language_v1.yaml" + } + }, { "client": { "source": "googleapis", diff --git a/Language/synth.py b/Language/synth.py index d6633abb9dca..574b2f1e8312 100644 --- a/Language/synth.py +++ b/Language/synth.py @@ -21,39 +21,45 @@ logging.basicConfig(level=logging.DEBUG) gapic = gcp.GAPICGenerator() -common = gcp.CommonTemplates() -library = gapic.php_library( - service='language', - version='v1beta2', - artman_output_name='google-cloud-language-v1beta2') +for version in ['V1', 'V1beta2']: + lower_version = version.lower() -# copy all src including partial veneer classes -s.move(library / 'src') + library = gapic.php_library( + service='language', + version=lower_version, + artman_output_name=f'google-cloud-language-{lower_version}') -# copy proto files to src also -s.move(library / 'proto/src/Google/Cloud/Language', 'src/') -s.move(library / 'tests/') + # copy all src including partial veneer classes + s.move(library / 'src') -# copy GPBMetadata file to metadata -s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Language', 'metadata/') + # copy proto files to src also + s.move(library / 'proto/src/Google/Cloud/Language', 'src/') + s.move(library / 'tests/') + + # copy GPBMetadata file to metadata + s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Language', 'metadata/') # fix year s.replace( - '**/Gapic/*GapicClient.php', + 'src/V1beta2/**/*.php', r'Copyright \d{4}', 'Copyright 2017') s.replace( - '**/V1beta2/LanguageServiceClient.php', + 'tests/*/V1beta2/*Test.php', r'Copyright \d{4}', - 'Copyright 2017') + 'Copyright 2018') s.replace( - 'tests/**/V1beta2/*Test.php', + 'src/V1/**/*.php', r'Copyright \d{4}', - 'Copyright 2018') + r'Copyright 2019') +s.replace( + 'tests/*/V1/*Test.php', + r'Copyright \d{4}', + r'Copyright 2019') # Use new namespaces s.replace( - 'src/V1beta2/Gapic/LanguageServiceGapicClient.php', + 'src/*/Gapic/LanguageServiceGapicClient.php', r'AnnotateTextRequest_Features', - 'AnnotateTextRequest\Features') + r'AnnotateTextRequest\\Features') diff --git a/Language/tests/System/V1/LanguageServiceSmokeTest.php b/Language/tests/System/V1/LanguageServiceSmokeTest.php new file mode 100644 index 000000000000..2bcd6d9e8d86 --- /dev/null +++ b/Language/tests/System/V1/LanguageServiceSmokeTest.php @@ -0,0 +1,49 @@ +setContent($content); + $document->setType($type); + $languageServiceClient->analyzeSentiment($document); + } +} diff --git a/Language/tests/Unit/V1/LanguageServiceClientTest.php b/Language/tests/Unit/V1/LanguageServiceClientTest.php new file mode 100644 index 000000000000..29202f6e5316 --- /dev/null +++ b/Language/tests/Unit/V1/LanguageServiceClientTest.php @@ -0,0 +1,510 @@ + $this->getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(), + ]; + + return new LanguageServiceClient($options); + } + + /** + * @test + */ + public function analyzeSentimentTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $language = 'language-1613589672'; + $expectedResponse = new AnalyzeSentimentResponse(); + $expectedResponse->setLanguage($language); + $transport->addResponse($expectedResponse); + + // Mock request + $document = new Document(); + + $response = $client->analyzeSentiment($document); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.language.v1.LanguageService/AnalyzeSentiment', $actualFuncCall); + + $actualValue = $actualRequestObject->getDocument(); + + $this->assertProtobufEquals($document, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function analyzeSentimentExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $document = new Document(); + + try { + $client->analyzeSentiment($document); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function analyzeEntitiesTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $language = 'language-1613589672'; + $expectedResponse = new AnalyzeEntitiesResponse(); + $expectedResponse->setLanguage($language); + $transport->addResponse($expectedResponse); + + // Mock request + $document = new Document(); + + $response = $client->analyzeEntities($document); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.language.v1.LanguageService/AnalyzeEntities', $actualFuncCall); + + $actualValue = $actualRequestObject->getDocument(); + + $this->assertProtobufEquals($document, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function analyzeEntitiesExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $document = new Document(); + + try { + $client->analyzeEntities($document); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function analyzeEntitySentimentTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $language = 'language-1613589672'; + $expectedResponse = new AnalyzeEntitySentimentResponse(); + $expectedResponse->setLanguage($language); + $transport->addResponse($expectedResponse); + + // Mock request + $document = new Document(); + + $response = $client->analyzeEntitySentiment($document); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.language.v1.LanguageService/AnalyzeEntitySentiment', $actualFuncCall); + + $actualValue = $actualRequestObject->getDocument(); + + $this->assertProtobufEquals($document, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function analyzeEntitySentimentExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $document = new Document(); + + try { + $client->analyzeEntitySentiment($document); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function analyzeSyntaxTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $language = 'language-1613589672'; + $expectedResponse = new AnalyzeSyntaxResponse(); + $expectedResponse->setLanguage($language); + $transport->addResponse($expectedResponse); + + // Mock request + $document = new Document(); + + $response = $client->analyzeSyntax($document); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.language.v1.LanguageService/AnalyzeSyntax', $actualFuncCall); + + $actualValue = $actualRequestObject->getDocument(); + + $this->assertProtobufEquals($document, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function analyzeSyntaxExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $document = new Document(); + + try { + $client->analyzeSyntax($document); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function classifyTextTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $expectedResponse = new ClassifyTextResponse(); + $transport->addResponse($expectedResponse); + + // Mock request + $document = new Document(); + + $response = $client->classifyText($document); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.language.v1.LanguageService/ClassifyText', $actualFuncCall); + + $actualValue = $actualRequestObject->getDocument(); + + $this->assertProtobufEquals($document, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function classifyTextExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $document = new Document(); + + try { + $client->classifyText($document); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function annotateTextTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + // Mock response + $language = 'language-1613589672'; + $expectedResponse = new AnnotateTextResponse(); + $expectedResponse->setLanguage($language); + $transport->addResponse($expectedResponse); + + // Mock request + $document = new Document(); + $features = new AnnotateTextRequest_Features(); + + $response = $client->annotateText($document, $features); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.language.v1.LanguageService/AnnotateText', $actualFuncCall); + + $actualValue = $actualRequestObject->getDocument(); + + $this->assertProtobufEquals($document, $actualValue); + $actualValue = $actualRequestObject->getFeatures(); + + $this->assertProtobufEquals($features, $actualValue); + + $this->assertTrue($transport->isExhausted()); + } + + /** + * @test + */ + public function annotateTextExceptionTest() + { + $transport = $this->createTransport(); + $client = $this->createClient(['transport' => $transport]); + + $this->assertTrue($transport->isExhausted()); + + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + + // Mock request + $document = new Document(); + $features = new AnnotateTextRequest_Features(); + + try { + $client->annotateText($document, $features); + // If the $client method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/README.md b/README.md index c01afa081458..cfc1882049e4 100644 --- a/README.md +++ b/README.md @@ -770,30 +770,58 @@ $ composer require google/cloud-dataproc ```php require 'vendor/autoload.php'; -use Google\Cloud\Language\LanguageClient; +use Google\Cloud\Language\V1\AnnotateTextRequest\Features; +use Google\Cloud\Language\V1\Document; +use Google\Cloud\Language\V1\Document\Type; +use Google\Cloud\Language\V1\Entity\Type as EntityType; +use Google\Cloud\Language\V1\LanguageServiceClient; +use Google\Cloud\Language\V1\PartOfSpeech\Tag; + +$client = new LanguageServiceClient([ + 'credentials' => '/Users/dsupplee/Downloads/gcloud.json' +]); -$language = new LanguageClient(); +$document = new Document([ + 'content' => 'Greetings from Michigan!', + 'type' => Type::PLAIN_TEXT +]); +$features = new Features([ + 'extract_document_sentiment' => true, + 'extract_entities' => true, + 'extract_syntax' => true +]); -// Analyze a sentence. -$annotation = $language->annotateText('Greetings from Michigan!'); +// Annotate the document. +$response = $client->annotateText($document, $features); // Check the sentiment. -if ($annotation->sentiment() > 0) { - echo "This is a positive message.\n"; +$sentimentScore = $response->getDocumentSentiment() + ->getScore(); + +if ($sentimentScore > 0) { + echo 'This is a positive message.' . PHP_EOL; } // Detect entities. -$entities = $annotation->entitiesByType('LOCATION'); - -foreach ($entities as $entity) { - echo $entity['name'] . "\n"; +foreach ($response->getEntities() as $entity) { + printf( + '[%s] %s', + EntityType::name($entity->getType()), + $entity->getName() + ); + echo PHP_EOL; } // Parse the syntax. -$tokens = $annotation->tokensByTag('NOUN'); +foreach ($response->getTokens() as $token) { + $speechTag = Tag::name($token->getPartOfSpeech()->getTag()); -foreach ($tokens as $token) { - echo $token['text']['content'] . "\n"; + printf( + '[%s] %s', + $speechTag, + $token->getText()->getContent() + ); + echo PHP_EOL; } ``` diff --git a/docs/contents/cloud-language.json b/docs/contents/cloud-language.json index 3ce2d1f99f1b..d7cf26c186fc 100644 --- a/docs/contents/cloud-language.json +++ b/docs/contents/cloud-language.json @@ -11,6 +11,16 @@ }, { "title": "Annotation", "type": "language/annotation" + }, { + "title": "v1", + "type": "language/v1/readme", + "patterns": [ + "language/v1/\\w{1,}" + ], + "nav": [{ + "title": "LanguageServiceClient", + "type": "language/v1/languageserviceclient" + }] }, { "title": "v1beta2", "type": "language/v1beta2/readme",