LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-20-2012, 03:06 AM   #1
vijay mishra
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Rep: Reputation: Disabled
to identify the language of string in perl?


hi sir/hello friends
i am stuck at a point in perl.
i coded to read a excel file which consist of English and Arabic strings in perl.

my task is to read each string from file and get the language type(English/Arabic).
========read each cell from excel file==========================

my $workbook = Spreadsheet::WriteExcel->new("test.xls");
for my $row ( $row_min .. $row_max ) {
for my $col ( $col_min .. $col_max ) {

my $cell = $worksheet->get_cell( $row, $col );
next unless $cell;

print "Row, Col = ($row, $col)\n";
print "Value = ", $cell->value(),
}
==================================================================
how to get the language type of string stored in $cell->value().

help me out

Last edited by vijay mishra; 04-20-2012 at 03:19 AM.
 
Old 04-20-2012, 03:11 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,491

Rep: Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429
how the excel file stored? is this an xls, or ??
can you give us a small example?
 
Old 04-20-2012, 06:48 AM   #3
vijay mishra
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
it is in .xls formate.
data stored in file is like this-
سبب التاععع 57675 انتلب لبال ععع
شلسا لشت allah ishwar is great pray him
 
Old 04-20-2012, 07:04 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,491

Rep: Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429
see $cell->encoding(); and $cell->get_rich_text(); this one will give you some information about the fonts used
 
Old 04-23-2012, 07:41 AM   #5
vijay mishra
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
hello sir/hi friends

I am trying to write a script in perl which reads a .xls (EXCEL) file and writes to other .xls(EXCEL) file in UNIX.

Entries in the file to be read are in ARABIC and ENGLISH.

My script is writing ENGLISH successfully but ARABIC is inserted as special characters in EXCEL file.

Please help me out
 
Old 04-23-2012, 10:40 AM   #6
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958
Please use [code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.

Go back and edit your earlier posts to include them too, please. As it stands, the long unbroken lines make my screen side-scroll.


I'm not very familiar with perl, but as I understand it, in general there's really no foolproof way to programmatically determine what language a string was written in. You can only use tricks and statistical methods. Checking what font or encoding is used is one, as suggested earlier. Or write up a test to see if the string contains characters other than those found in standard English. Or if the file is in a unicode encoding, test the characters to see if they fall within the Arabic range.


Also, a quick web search came up with this language detection plugin:
http://search.cpan.org/~ambs/Lingua-...ua/Identify.pm


Otherwise, I think you really need to explain what you are trying to do in more detail if you want to get more specific help. Provide some realistic examples of the input, the output you want, and any relevant code you have written up so far.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
read string after specific string from a text file using C++ programing language badwl24 Programming 5 10-08-2009 06:41 AM
[perl]How to treat string like "a b" as a single string when split? john.daker Programming 21 06-01-2009 06:57 PM
inquiry to Perl monks about Perl as a first programming language mannclay Programming 53 03-22-2009 02:35 PM
read string in c language dedexes Programming 5 03-05-2008 02:17 AM
Grep String Search, and identify source file. carl0ski Linux - General 4 01-21-2006 09:15 AM


All times are GMT -5. The time now is 06:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration