Translating Names/Surnames from Arabic [closed] - ruby

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I'm working with Ruby, I have a list of names/surnames in the Arabic Language, I want to translate them to Latin, as they are pronounced, for example, I have the name "رضوان" => "Redouane" (I can also accept Radouane, Radwan or anything like this).
Public APIs like google translate work fine on some names, but when the name has a meaning, they fail to translate it "as it is pronounced", for example, with Google translate, to English, it gives : "رمزي" => "symbolic" while what I want is "Ramzy" (I can also accept "Ramzi")
are there any good Ruby gems to translate names?
I'm trying to translate because I haven't been able to print arabic text to Ruby consoles directly, see : Printing a CP850 encoded string with Ruby (IRB)

Not a definite answer, but have you seen the Unidecoder gem? It provides basic transliteration from any unicode letters to plain ASCII. However, it is indeed only a simple transliteration, e.g. it does not add vowels to the transcription. Quoting from the README:
Other languages, like Hebrew and Arabic, don't write vowels, but assume them from context, so the ASCII representation of these langages given by this library will look fairly ugly to native speakers.
Your two examples yield to these transliterations:
require 'unidecoder'
=> true
>> "رضوان".to_ascii
=> "rDwn"
>> "رمزي".to_ascii
=> "rmzy"

Related

How to validate a raw Zebra Programming Language (ZPL) file with a regular expression? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
When receiving ZPL raw labels (text files) from a third party, I would like to run a regular expression on them to validate them.
Rather than a 100% strict validation, I am mostly looking to avoid sending to the printer obviously wrong files, such as completely unrelated text files, or binary files.
I am not familiar enough with ZPL/ZPL-II and I would prefer to use an existing resource for that. Would you know if one exists?
I've never heard of one. But it wouldn't be too hard to validate. ZPL is pretty straightforward, especially if there's a very defined set that you send to your printer...
The ZPL command characters are ~ for immediate commands an ^ for formatting commands.
Label formats must begin with a ^XA and end with a ^XZ.
Download commands typically begin with a ~D<something>, like ~DY, ~DG, ~DT, ~DC etc.
There are a couple status commands like ~HI and ~HS
There may be a couple other edge cases, but these are the most common commands.

Conversion to Python 3 using 2to3 (and UTF-8) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm given a task of converting a bunch of code written in Python 2 to Python 3,
and this task was given with emphasis on having UTF-8 (didn't quite comprehend the concept but anyway..)
I've automated the conversion using 2to3, but not sure if using 2to3 achieves the goal of having UTF-8, or if there's some other parts that I should manually work on.
What is it exactly, and is it done automatically by using 2to3?
Thank you in advance.
"I was just told the importance of converting it into Python 3 due to importance of UTF-8 so that the program can work with any other language"
Whoever told you that was misinformed.
2to3 does not do anything towards "having UTF-8" whatever that means. 2to3 is to move your code from Python 2 to Python 3. Python 3 does mean you have have Unicode variable names, but I would strongly recommend against that anyway. Bad Idea. Otherwise Python 2 supports Unicode and UTF-8 perfectly well.
It seems your actual goal is not UTF-8, but translating the program to other language, also known as internationalization, or "18n". That's a completely different issue, and has nothing to do with 2to3. Instead you need to manually change all your text strings to gettext tokens that will be translated when rendered. See http://docs.python.org/library/gettext.html
See also http://regebro.wordpress.com/2011/03/23/unconfusing-unicode-what-is-unicode/ for more information on Unicode.

Trying to find a reference to the manual but can't [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Simple question, what is the best way on windows to search the documentation. This time I was wanting information on 'while'(resolved now by google) but I still can't can't get ri or the chm documentation on windows to give a result to while.
If I type in the Keyword in search in the chm it doesn't return 'while' it returns many results but not 'while' same for index search.
so In installed ri.
>rdoc --all --ri
but if I search while
C:\Ruby193\bin>ri 'while'
Nothing known about .while
I would like to read from the official results. Whats the best?
Also tried ri interactive but same result.
C:\Documents and Settings\renshaw>ri -i
Enter the method name you want to look up.
You can use tab to autocomplete.
Enter a blank line to exit.
>> while
Nothing known about .while
>>
That's because ri gives you information about methods, and not language syntax. while is Ruby's keyword, just like begin. If you try you won't find anything about begin in ri. Instead you can try ri File::read for example.
For Ruby core language keywords and topics, use the ruby: prefix.
If you ran ri ruby:while, you would get a list of pages. In that list is syntax/control_expressions.rdoc, which probably contains the information that you want.
ri ruby:control_expressions
Gives you the documentation for core Ruby control expressions (which includes while).

Ruby - Songkick api - Need help with events.location() query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm using this Songkick wrapper and it works for getting grabbing events by artist like so:
sk.events(:artist_name => "Balimurphy")
But I'm having trouble grabbing events by location. Songkick is expecting the query to look like this
location=geo:lat,lng
I'm having trouble finding the right syntax to pass lng=-73.5833, lat=45.5. Here are some variations I've tried:
sk.events(:location => :geo=>{:lng=>"-73.5833", :lat=>"45.5"})
sk.events(:location => {:geo=>lng=-73.5833, lat=45.5})
sk.events(:location => "geo=-73.5833,45.5")
Any ideas?
Where can I find documentation that might cover this?
I've been looking through the following 3 sources:
https://github.com/jrmehle/songkickr
http://rubydoc.info/gems/songkickr/0.1.0/frames
http://www.songkick.com/developer/event-search
and I think you need to change your last attempt to
sk.events(:location => "geo:-73.5833,45.5") # geo:
One example on the songkick page has location=ip:94.228.36.39. This makes me think that it for location, it wants location=type:data.
I assume that the hash you pass gets turned into key=value (just looking at the songkick page and your working example).
Therefore, you would want your value to be "geo:-73.5833,45.5" and your key to be "location".
I hope this works for you!

How do I add existing comments to RDoc in Ruby? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I want to format my existing comments as 'RDoc comments' so they can be viewed using ri.
What are some recommended resources for starting out using RDoc?
A few things that have bitten me:
:main: -- RDoc uses only the last one evaluated; best to make sure there's only one in your project and you don't also use the --main command-line argument.
same as previous, but for :title:
:section: doesn't work very well
RDoc uses SimpleMarkup so it's fairly simple to create lists, etc. using *, - or a number. It also treats lines that are indented at the same column number as part of the same paragraph until there is an empty line which signifies a new paragraph. Do you have a few examples of comments you want RDoc'ed so we could show you how to do them and then you could extrapolate that for the rest of your comments?

Resources