Extract article from non-english text
GoogleCodeExporter opened this issue · comments
Google Code Exporter commented
I am trying to use boilerpipe to extract article from URLS containing
non-english language. However it generates some ascii text, check
this(http://boilerpipe-web.appspot.com/extract?url=http%3A%2F%2Fwww.sandesh.com%
2Farticle.aspx%3Fnewsid%3D2905443&extractor=ArticleExtractor&output=htmlFragment
&extractImages=). I saw this
issue(https://code.google.com/p/boilerpipe/issues/detail?id=16&q=non%20english).
I tried to make some changes in the code.
1) Modified HTMLfetcher.java. Appended following lines before end of method
fetch
byte[] utf8 = new String(data, cs.displayName()).getBytes("UTF-8"); //new one
(convertion)
cs = Charset.forName("UTF-8"); //set the charset to UFT-8
Or/And then 2) Changed code in my class by using UTF-8 charset with inputsource
URL url = new URL(urls);
InputSource is = new InputSource();
is.setEncoding("UTF-8");
is.setByteStream(url.openStream());
text = ArticleExtractor.INSTANCE.getText(is);
still I am not able to get desired result.
Test URL :http://www.sandesh.com/article.aspx?newsid=2905443
Test Text(In gujarati language): મુંબઈ, 30
જાન્યુઆરી સલમાન ખાને
ગુજરાતમાં આવીને નરેન્દ્ર
મોદીના વખાણ શુ કર્યા તેની
મુસીબતોમાં ખૂબ વધારો થઈ ગયો
છે. સલમાન ખાન ફિલ્મ 'જય હો'ના
પ્રમોશન માટે ઉત્તરાયણમાં
અમદાવાદ આવ્યા હોવાથી અને તે
સમયે તેણે નરેન્દ્ર મોદીના
વખાણ કર્યા હોવાથી કોંગ્રેસ
દ્વારા મુસ્લિમોને તેની ફિલ્મ
'જય હો' ના જોવાની અરજી કરવામાં
આવી હતી અને હવે મુસ્લિમ
મૌલવીઓ દ્વારા તેના સામે ફતવો
જાહેર કરી દેવામાં આવ્યો છે.
Test Result: મ��બ�, 30
�ાન�ય��ર�
સલમાન �ાન�
���રાતમા�
�વ�ન� નર�ન�દ�ર
મ�દ�ના વ�ાણ શ�
�ર�યા ત�ન�
મ�સ�બત�મા� ��બ
વધાર� થ� �ય� ��.
સલમાન �ાન
ફિલ�મ '�ય હ�'ના
પ�રમ�શન મા��
�ત�તરાયણમા�
�મદાવાદ �વ�યા
હ�વાથ� �ન� ત�
સમય� ત�ણ�
નર�ન�દ�ર
મà«�દà«�નàª
Original issue reported on code.google.com by ranjanba...@iblogee.com
on 2 Feb 2014 at 12:44
Google Code Exporter commented
Hi,
Save it as HTML page and use below lines to extract text as it is.
Reader r = new InputStreamReader(new FileInputStream("D:/test1.htm"));
String text = CommonExtractors.ARTICLE_EXTRACTOR.getText(r);
System.out.println("Text:"+text);
Regards,
Vanaja Jayaraman
Original comment by vanaja.u...@gmail.com
on 22 May 2014 at 12:01