Google.Cloud.Translate.V3 only gives one translation result - google-translate

I just switched from Google.Cloud.Translate.V2 to Google.Cloud.Translate.V3, expecting to get multiple translation options, but I only get one.
The example code seems geared for it:
foreach (Translation translation in response.Translations)
{
Console.WriteLine($"Translated text: {translation.TranslatedText}");
}
For example, the Google Translate web page translates the Spanish "Cumplan" with a main translation of English "meet" and other possibilities listed in a pane below, i.e.:
Translations of cumplir
comply
cumplir, consentir, compadecer
fulfill
cumplir, realizar
accomplish
lograr, cumplir, realizar, conseguir, alcanzar, llevar a cabo
satisfy
satisfacer, cumplir, cumplir con, aplacar, contentar, liquidar
etc.
How can I get those additional translations?
Is there a way to get the frequency it lists?

The cloud translation API doesn't support all the alternative translations - much to my chagrin - so you can't get them (as of October 2020).
The support for 'multiple' translations refers to the fact that the API supports your passing a list of strings to be translated, and so can return a response containing the translations for each string you sent it.
The API supports the translation of fairly large blocks of text, so if it returned a simple list of all the possible translations it would be really long. If there were just three words in the whole text with five possible translations instead of one, you'd have 125 different possibilities. What's needed is a more complex data structure to capture all the reasonable alternatives.
N.B. there are some existing feature requests around this issue, which you can view and indicate your interest in by 'starring' them here.

Related

How to add hash keys to Wordpress tags

I'm building a website about music chords.
Sharp chords look like this example: F#m7b5.
That chord (F#m7b5) can be called in many other way like:
F# half-diminished,
F# minor seventh flat fifth,
F# minor seventh flat five,
F#m7b5,
F#∅,
F#m7(b5),
F#º7,
F#1/2dim,
F#1/2dim7,
F#m7(-5),
Fa# ∅,
Fa# m7b5,
Fa# m7(b5)
I would like that my users will find my F#m7b5 post searching for any of the alternative nomenclature so I've added those as tags but Wordpress doesn't accept the hash keys into tags and after a post update all hash keys disappear.
There's a proper way to add hash keys into tags?

Pass search strategy to filter from rest URI

First time using api-platform and Symfony 4 to create an API interface for a MySQL db.
I'm updating an old search interface for the db for which I need to replicate many of the search options. This includes being able to search on a given field using various matching operators/strategies. e.g. starts with, contains exactly equals, etc.
I've set everything up for the api using Annotations.
The #ApiFilter(SearchFilter::class, properties={"fieldname": "strategy"} annotation on my table class works as designed, but I am limited to one-and-only-one strategy per field. I need to be able to pass the strategy to the api search function in the url. something like:
/api/staff?lastname[start]=dav
or
/api/staff?lastname=david&match=contains
or
/api/staff/lastname/son?searchtype=end
would be fine.
I can't figure out how to set this up. Shockingly, to me anyway, this common requirement doesn't seem to be documented at all.
The file CustomSearchFilter.php located at the repo https://github.com/jordonedavidson/custom_search_filter solves this use-case using the
/api/staff?lastname[start]=dav
syntax.
The file was written by Kévin Dunglas (the author of Api Platform) and is presented with his blessing.

Searching a DICOM server for metadata

I want to search the DICOM server. if for example user enters a patient id to serach, then my app populate a table with all the metadata relating to that id , such as id, name, accession number e.tc. if tha study id exists in the dicom server, How can this be done using dcm4chee kit. –
You can use dcm4che3 tool dcm4che-tool-findscu. This code shows you how to do a C-FIND against a PACS (or whatever implementing C-FIND as SCP).
FindSCU.java is quite clear, take a while and don't get missed through Apache Commons CLI code to understand input from console. Most of CLI management code is not in this project, but you can find it in the dcm4che3 tool dcm4che-tool-common project, org.dcm4che3.tool.common.CLIUtils.java class.
Take into account following considerations:
Specify the search level of Query/Retrieve. You can use several search levels in order to match attributes into a PACS. If you look at lines 260:265 of FindSCU.java, you will see that you can manage four different levels: PATIENT|STUDY|SERIES|IMAGE.This will instruct C-FIND SCP how to search matching attributes.
Tell C-FIND SCP what attributes do you want to retrieve. If you want to search studies to be retrieved later, you must ask for 0020, 000D Study​InstanceUID tag.
Of course, add all attributes that you want to populate your table.
Use retrieved 0020, 000D Study​InstanceUID tag value to do the C-GET/C-MOVE operation.
You can see how to configure attribute keys to do C-FIND SCU into CLIUtils.java class that is part of dcm4che3 tool dcm4che-tool-common project. See CLIUtils.addAttributes(Attributes, String[]).
Hope it helps!
Edit
Due to you comment you are using dcm4che2 and that you already have a DicomObject with the search result, if you want to obtain metadata from this DicomObject you must parse it before, using DicomInputStream, and then you can use getXXXX(Tag) from BasiDicomObject, something like this:
DicomObject dcmObj;
DicomInputStream dis = null;
dis = new DicomInputStream(file);
dcmObj = dis.readDicomObject();
String someVar = dcmObj.getString(Tag.SeriesInstanceUID);
Keep in mind, some attributes are inside sequences, and thus you have to search it before.
You can also take a look into dcm4che-tool-dcm2txt, you will see Dcm2Txt.java and in lines 170 and so on, there is how to parse whole dicom object.
If you need some general description about the DICOM network protocol, you could read the "Understanding DICOM with Orthanc" guide, and more specifically the section about C-Find.

Yahoo Pipes - Build an RSS-URL using specific parameters pulled from another RSS feed's content

The main Data Type used by Yahoo Pipes is the [Item], which is RSS feed content. I want to take an RSS's content or sub-element, make it into [Text] (or a number might work), and then use it as an INPUT into a [Module] to build a RSS-URL with specific parameters. I will then use the new RSS-URL to pull more content.
Could possibly use the [URL Builder Module] or some work-around.
The key here is using "dynamic" data from an RSS feed (not user input, or a static data), and getting that data into a Data Type that is compatible (and/or accessible) as an INPUT into a module.
It seems like a vital functionality, but I cannot figure it out. I have tried many, many work-around attempts, with no success.
The Specific API and Methods (if you are interested)
Using the LastFM API.
1st Method: user.getWeeklyChartList. Then pick the "from" (start) and "to" (end) Unix timestamps from 1 year-ago-today.
2nd Method: user.getWeeklyAlbumChart using those specific (and "dynamic") timestamps to pull my top albums for that week.
tl;dr. Build an RSS-URL using specific parameters from another RSS feed's content.
I think I may have figured it out. I doubt it is the best way, but it works. The problem was the module I needed to use didn't have and input node. But the Loop module has an input node, so if I embed the URL builder into the Loop module I can then access sub-element content from the 1st feed to use as parameters to build the URL for the 2nd feed! Then I can just scrap all the extra stuff generated by the Loop, by using Truncate.

Nested REST Routing

Simple situation: I have a server with thousands of pictures on it. I want to create a restful business layer which will allow me to add tags (categories) to each picture. That's simple. I also want to get lists of pictures that match a single tag. That's simple too. But now I also want to create a method that accepts a list of tags and which will return only pictures that match all these tags. That's a bit more complex, but I can still do that.
The problem is this, however. Say, my rest service is at pictures.example.com, I want to be able to make the following calls:
pictures.example.com/Image/{ID} - Should return a specific image
pictures.example.com/Images - Should return a list of image IDs.
pictures.example.com/Images/{TAG} - Should return a list of image IDs with this tag.
pictures.example.com/Images/{TAG}/{TAG} - Should return a list of image IDs with these tags.
pictures.example.com/Images/{TAG}/{TAG}/{TAG} - Should return a list of image IDs with these tags.
pictures.example.com/Images/{TAG}/{TAG}/{TAG}/{TAG}/{TAG} - Should return a list of image IDs with these tags.
etcetera...
So, how do I set up a RESTful web service projects that will allow me to nest tags like this and still be able to read them all? Without any limitations for the number of tags, although the URL length would be a limit. I might want to have up to 30 tags in a selection and I don't want to set up 30 different routing thingies to get it to work. I want one routing thingie that could technically allow unlimited tags.
Yes, I know there could be other ways to send such a list back and forth. Better even, but I want to know if this is possible. And if it's easy to create. So the URL cannot be different from above examples.
Must be simple, I think. Just can't come up with a good solution...
The URL structure you choose should be based on whatever is easy to implement with your web framework. I would expect something like:
http://pictures.example.com/images?tags=tag1,tag2,tag3,tag4
Is going to be much easier to handle on the server, and I can see no advantage to the path segment approach that you are having trouble with.
I assume you can figure out how to actually write the SQL or filesystem query to filter by multiple tags. In CherryPy, for example, hooking that up to a URL is as simple as:
class Images:
#cherrypy.tools.json_out()
def index(self):
return [cherrypy.url("/images/" + x.id)
for x in mylib.images()]
index.exposed = True
#cherrypy.tools.json_out()
def default(self, *tags):
return [cherrypy.url("/images/" + x.id)
for x in mylib.images(*tags)]
default.exposed = True
...where the *tags argument is a tuple of all the /{TAG} path segments the client sends. Other web frameworks will have similar options.

Resources