Azure text analytics accuracy in german is different from the demo case - azure

I've created a website which communicates with my logic app while that uses the text analytics from azure. But my applications acts different from the demo case which you can find here: https://azure.microsoft.com/de-de/services/cognitive-services/text-analytics/ ! When you post for example:
Hallo E-Bike Team,
ich habe ein Problem mit meinem E-Bike. Es ist das Model ProRide2E.
Seit heute Morgen steht auf dem Display folgender Hinweis:
„Akkuleistung beeinträchtigt. Fehlercode: XB1200AB“
Das darf doch wohl nicht wahr sein. Ich bin echt sauer. Wieso ist das
doofe Bike immer kaputt?
Ein genervter Kunde
Name
which is very negative it responses with a sentimental score of 31% in the demo but in my app it responses with 50% which is clearly wrong because it is negative and it should be below 50%. I uses the same cognitive services as the demo but my accuracy is not similar to the demo.
Is there any way to improve my accuracy?
ps: I'm using the free subscription. Does the accuracy change if change that?

I tried to repro the issue at my side and found that when you don't set Language parameter it will give you the SENTIMENT score of 0.5
When you set the Language parameter to de it will give you exact SENTIMENT score of 0.30392158031463623.
Below is the screenshot to show how you can set the Language parameter:

Related

400 Error when trying to use jsonlines file with OpenAI answers

I uploaded a file to openai for the purpose of answers. I can't figure out how to access it without getting an error.
This is the contents of my file:
{"text":"We are focusing on improving communication to the customers."}
{"text":"The emphasis on the customer is working well."}
{"text":"Services initiatives"}
{"text":"CMM and focus on customer service."}
{"text":"We are working on CMM to focus on the customer."}
{"text":"Our emphasis on making our customers number one."}
{"text":"Customer relationships are continuing to improve."}
This is the information about the file when I query openai:
{"object":"file","id":"file-02fdY5PuZ1aO4cnd2r1PxaB7","purpose":"answers","filename":"f3f1c105-5217-4132-8950-a040b6183ed7","bytes":458,"created_at":1648396701,"status":"processed","status_details":null}
Now I ask a question at https://api.openai.com/v1/answers with this POST:
{"file":"file-02fdY5PuZ1aO4cnd2r1PxaB7","question":"What is the main theme?","search_model": "davinci","model": "davinci","examples_context": "In 2017, U.S. life expectancy was 78.6 years.","examples": [["What is human life expectancy in the United States?","The life expectancy in the United States is 78 years."]],"max_tokens": 100,"stop": ["\n", "<|endoftext|>"]}
The server returns a 400 error. If in my request I replace the "file" field with a "documents" array using same data, the request is successful.
I don't know what more to look at. If someone can suggest something or if you seen an issue in what I am trying to do, I would deeply appreciate hearing from you.
Thanks

How to implement the language automatically in detect sentiment in azure text analytics in a logic app?

I've created a logic app which detects the language of a text and then the sentiment with cognitive services. I want to change the language parameter to the actual language which is detected. I've tried the following and much other stuff but it doesn't work out for me.
Can anyone suggest me a solution?
(The text is German but when I run it it says: "Supplied language not supported. Pass in one of: ar,da,de,el,en,es,fi,fr,it,ja,nl,no,pl,pt-PT,ru,sv,tr,zh-Hans")
For a copy:
Hallo E-Bike Team, ich habe ein Problem mit meinem E-Bike. Es ist das
Model ProRide2E. Seit heute Morgen steht auf dem Display folgender
Hinweis: „Akkuleistung beeinträchtigt. Fehlercode: XB1200AB“ Das darf
doch wohl nicht wahr sein. Ich bin echt sauer. Wieso ist das doofe
Bike immer kaputt?
Ein genervter Kunde
Name
I added dynamic content instead of the #('Detect_Language')?['iso6391Name']. The dynamic content was Language Code. That created a for each loop. In the response I didnt output score as usual I added a expression (body('Detect_Sentiment')[0]?['score']) That worked out!

Issue with translating multiple languages in a single document

I am trying a language translation code where I am using the translate package where the provider is Microsoft. The input text has 2 languages english and Russian and my to language is english. The translated text does not change to English. Can anyone provide some inputs ?
from translate import Translator
to_lang = "en"
translator = Translator(provider='microsoft', to_lang=to_lang, secret_access_key=secret)
translator.translate("Elapsed Task Time – время в течение, которого выполнялась задача ")
'Elapsed Task Time – время в течение, которого выполнялась задача '
Here is what I tried to compare the issue
from googletrans import Translator
translator = Translator()
translator.translate(r.text, dest='en').text
"Elapsed Task Time - the time during which the task was performed"
Expected result :
"Elapsed Task Time - the time during which the task was performed"
For whatever reason, the (older) version of the Microsoft translator API used in this library won't autodetect mixed languages properly. It will work if your mixed languages include English and you specify from_lang for the other language. It always detects English. For example, if you specify from_lang='ru' and translate to 'it', the English portion will also be translated to Italian.
So, back to your scenario, this should work:
translator = Translator(provider='microsoft', to_lang=to_lang, from_lang='ru', secret_access_key=secret)
That said, I recommend you look at: https://github.com/MicrosoftTranslator/Text-Translation-API-V3-Python. In particular, Translate.py. This should work as expected and uses the latest API (well, more precisely, you get control over which API).

Specify the specific heat of a material with Revit 2017 Python API

With Revit 2017 Python API, I am trying to create new materials, and then assembling some of these to create new type of walls.
It goes pretty well for all properties, except for the specific heat!
Basically, what I do is:
create a thermalAsset:
themalA = ThermalAsset('Test', ThermalMaterialType.Solid)
Set the different thermal properties for that thermal asset (dummy values):
thermalA.ThermalConductivity = 0.01
thermalA.SpecificHeat = 0.001
thermalA.Density = 1000.0
Then I create a PropertySetElement with that thermal asset:
pse = PropertySetElement.Create(doc, thermalA)
Then I assign it to my material (that I previously created):
mat.SetMaterialAspectByPropertySet(MaterialAspect.Thermal, pse)
Afetr that, I take a look in my materials list in Revit, and look at the thermal properties. Everything seems ok, except the Specific Heat, which remains at 0.0239 btu/(lb. F), whatever the value I input when I assign the specific heat. Density is ok, thermal conductivity is ok, but not specific heat.
I got no error message.
What am I missing?
Thanks a lot for any help.
Arnaud.
Is the value you specify in the expected unit? Feet per Kelvin, squared-second. Cf., http://thebuildingcoder.typepad.com/blog/2013/04/whats-new-in-the-revit-2014-api.html > ThermalAsset.SpecificHeat.
I submitted this to the development team for further analysis as issue REVIT-111206 [API: setting ThermalAsset SpecificHeat fails]. Can you please provide a full reproducible case for them to test, e.g., a minimal RVT model with an embedded macro to run, cf., http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b? Thank you!

Finding Related Topics using Google Knowledge Graph API

I'm currently working on a behavioral targeting application and I need a considerably large keyword database/tool/provider that enables applications to reach to the similar keywords via given keyword for my app. I've recently found that Freebase, which had been providing a similar service before Google acquired them and then integrated to their Knowledge Graph. I was wondering if it's possible to have a list of related topics/keywords for the given entity.
import json
import urllib
api_key = 'API_KEY_HERE'
query = 'Yoga'
service_url = 'https://kgsearch.googleapis.com/v1/entities:search'
params = {
'query': query,
'limit': 10,
'indent': True,
'key': api_key,
}
url = service_url + '?' + urllib.urlencode(params)
response = json.loads(urllib.urlopen(url).read())
for element in response['itemListElement']:
print element['result']['name'] + ' (' + str(element['resultScore']) + ')'
The script above returns the queries below, though I'd like to receive related topics to yoga, such as health, fitness, gym and so on, rather than the things that has the word "Yoga" in their name.
Yoga Sutras of Patanjali (71.245544)
Yōga, Tokyo (28.808222)
Sri Aurobindo (28.727333)
Yoga Vasistha (28.637642)
Yoga Hosers (28.253984)
Yoga Lin (27.524054)
Patanjali (27.061115)
Yoga Journal (26.635073)
Kripalu Center (26.074436)
Yōga Station (25.10318)
I'd really appreciate any suggestions, and I'm also open to using any other API if there is any that I could make use of. Cheers.
See your point:) So here's the script I use for that using Serpstat's API. Here's how it works:
Script collects the keywords from Serpstat's database
Then, collects search suggestions from Serpstat's database
Finally, collects search suggestions from Google's suggestions
Note that to make script work correctly, it's preferable to fill all input boxes. But not all of them are required.
Keyword — required keyword
Search Engine — a search engine for which the analysis will be carried out. For example, for the US Google, you need to set the g_us. The entire list of available search engines can be found here.
Limit the maximum number of phrases from the organic issue, which will participate in the analysis. You cannot set more than 1000 here.
Default keys — list of two-word keywords. You should give each of them some "weight" to receive some kind of result if something goes wrong.
Format: type, keyword, "weight". Every keyword should be written from a new line.
Types:
w — one word
p — two words
Examples:
"w; bottle; 50" — initial weight of word bottle is 50.
"p; plastic bottle; 30" — initial weight of phrase plastic bottle is 30.
"w; plastic bottle; 20" — incorrect. You cannot use a two-word phrase for the "w" type.
Bad words — comma-separated list of words you want the script to exclude from the results.
Token — here you need to enter your token for API access. It can be found on your profile page.
You can download the source code for script here

Resources