use of com.lingtuan.firefly.custom.contact.HanziToPinyin3.Token in project java-docs-samples by GoogleCloudPlatform.
the class Analyze method analyzeSyntaxFile.
/**
* Get the syntax of the GCS hosted file.
*/
public static List<Token> analyzeSyntaxFile(String gcsUri) throws Exception {
// Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
try (LanguageServiceClient language = LanguageServiceClient.create()) {
Document doc = Document.newBuilder().setGcsContentUri(gcsUri).setType(Type.PLAIN_TEXT).build();
AnalyzeSyntaxRequest request = AnalyzeSyntaxRequest.newBuilder().setDocument(doc).setEncodingType(EncodingType.UTF16).build();
// analyze the syntax in the given text
AnalyzeSyntaxResponse response = language.analyzeSyntax(request);
// print the response
for (Token token : response.getTokensList()) {
System.out.printf("\tText: %s\n", token.getText().getContent());
System.out.printf("\tBeginOffset: %d\n", token.getText().getBeginOffset());
System.out.printf("Lemma: %s\n", token.getLemma());
System.out.printf("PartOfSpeechTag: %s\n", token.getPartOfSpeech().getTag());
System.out.printf("\tAspect: %s\n", token.getPartOfSpeech().getAspect());
System.out.printf("\tCase: %s\n", token.getPartOfSpeech().getCase());
System.out.printf("\tForm: %s\n", token.getPartOfSpeech().getForm());
System.out.printf("\tGender: %s\n", token.getPartOfSpeech().getGender());
System.out.printf("\tMood: %s\n", token.getPartOfSpeech().getMood());
System.out.printf("\tNumber: %s\n", token.getPartOfSpeech().getNumber());
System.out.printf("\tPerson: %s\n", token.getPartOfSpeech().getPerson());
System.out.printf("\tProper: %s\n", token.getPartOfSpeech().getProper());
System.out.printf("\tReciprocity: %s\n", token.getPartOfSpeech().getReciprocity());
System.out.printf("\tTense: %s\n", token.getPartOfSpeech().getTense());
System.out.printf("\tVoice: %s\n", token.getPartOfSpeech().getVoice());
System.out.println("DependencyEdge");
System.out.printf("\tHeadTokenIndex: %d\n", token.getDependencyEdge().getHeadTokenIndex());
System.out.printf("\tLabel: %s\n\n", token.getDependencyEdge().getLabel());
}
return response.getTokensList();
}
// [END analyze_syntax_file]
}
use of com.lingtuan.firefly.custom.contact.HanziToPinyin3.Token in project SmartMesh_Android by SmartMeshFoundation.
the class PinYin method getPinYin.
// The same return return pinyin Chinese characters, letters, are converted to lowercase
public static String getPinYin(String input) {
ArrayList<Token> tokens = HanziToPinyin3.getInstance().get(input);
StringBuilder sb = new StringBuilder();
if (tokens != null && tokens.size() > 0) {
for (Token token : tokens) {
if (Token.PINYIN == token.type) {
sb.append(token.target);
} else {
sb.append(token.source);
}
}
}
return sb.toString().toLowerCase();
}
use of com.lingtuan.firefly.custom.contact.HanziToPinyin3.Token in project cloudbreak by hortonworks.
the class OpenStackClient method createAccessOrToken.
private void createAccessOrToken(AuthenticatedContext authenticatedContext) {
Access access = createAccess(authenticatedContext.getCloudCredential());
Token token = createToken(authenticatedContext.getCloudCredential());
if (token == null && access == null) {
throw new CloudConnectorException("Unsupported keystone version");
} else if (token != null) {
authenticatedContext.putParameter(Token.class, token);
} else {
authenticatedContext.putParameter(Access.class, access);
}
}
use of com.lingtuan.firefly.custom.contact.HanziToPinyin3.Token in project cloudbreak by hortonworks.
the class OpenStackClient method getRegion.
public Set<String> getRegion(CloudCredential cloudCredential) {
Access access = createAccess(cloudCredential);
Token token = createToken(cloudCredential);
Set<String> regions = new HashSet<>();
if (token == null && access == null) {
throw new CloudConnectorException("Unsupported keystone version");
} else if (token != null) {
for (Service service : token.getCatalog()) {
for (Endpoint endpoint : service.getEndpoints()) {
regions.add(endpoint.getRegion());
}
}
} else {
for (Access.Service service : access.getServiceCatalog()) {
for (org.openstack4j.model.identity.v2.Endpoint endpoint : service.getEndpoints()) {
regions.add(endpoint.getRegion());
}
}
}
LOGGER.info("regions from openstack: {}", regions);
return regions;
}
Aggregations