2017-04-19 5 views
2

Ich benutze natürlich verständliche API. Text Ich verwende 'hmmmm nawa ohh wen bin ich Gona win ds tin' und es wird geben FehlerWatsonException: Fehler: nicht unterstützte Textsprache, Code: 400

WatsonException: Error: unsupported text language, Code: 400 

Mein Code ist:

response = natural_language_understanding.analyze(
    text='hmmmm nawa ohh wen am I gona win ds tin', 
    features=[features.Sentiment(), features.Keywords(), features.Emotion(), features.Categories()]) 

, wie diese Art von Text zu NLU api passieren . brauche Hilfe.

Antwort

2

Es scheitert, weil es versucht, zu erraten, was die Sprache ist, bevor es versucht, Features zu bestimmen. Das Einstellen der Sprache verhindert dies.

Zum Beispiel:

question = 'hmmmm nawa ohh wen am I gona win ds tin' 

f = [ 
    features.Categories(), 
    features.Concepts(), 
    features.Emotion(), 
    features.Entities(), 
    features.Relations(), 
    features.SemanticRoles(), 
    features.Sentiment() 
] 
r = nlu.analyze(text=question, features=f, language='en') 

print(json.dumps(r, indent=2)) 

gibt diese:

{ 
    "sentiment": { 
    "document": { 
     "score": 0.0, 
     "label": "neutral" 
    } 
    }, 
    "semantic_roles": [ 
    { 
     "subject": { 
     "text": "I" 
     }, 
     "sentence": "hmmmm nawa ohh wen am I gona win ds tin", 
     "object": { 
     "text": "ds tin" 
     }, 
     "action": { 
     "verb": { 
      "text": "win", 
      "tense": "present" 
     }, 
     "text": "win", 
     "normalized": "win" 
     } 
    } 
    ], 
    "relations": [], 
    "language": "en", 
    "entities": [], 
    "emotion": { 
    "document": { 
     "emotion": { 
     "sadness": 0.193275, 
     "joy": 0.309168, 
     "fear": 0.167981, 
     "disgust": 0.06316, 
     "anger": 0.130959 
     } 
    } 
    }, 
    "concepts": [], 
    "categories": [ 
    { 
     "score": 0.899547, 
     "label": "/art and entertainment" 
    }, 
    { 
     "score": 0.365657, 
     "label": "/hobbies and interests/reading" 
    }, 
    { 
     "score": 0.189432, 
     "label": "/art and entertainment/movies and tv/movies" 
    } 
    ] 
} 

Es ist nicht richtig Englisch, aber, so würde ich die Ergebnisse gut zu sein, nicht erwarten.

können Sie sehen die unterstützte Sprache hier Features:

https://www.ibm.com/watson/developercloud/doc/natural-language-understanding/index.html#supported-languages

+0

Ja zuvor habe ich zur Verfügung gestellt Sprache nicht = ‚en‘ so, dass ich Fehler. Vielen Dank. – tom

Verwandte Themen