Monday, October 13, 2008

Machine Translation/NLP Resources

Here is something useful for NLP/MT:

http://wt.jrc.it/lt/acquis/
http://www.mt-archive.info/
http://nl.ijs.si/telri/Vanilla/
http://www.essex.ac.uk/linguistics/clmt/MTBook/
http://portal.acm.org/
http://www.cs.unt.edu/~rada/wpt/WordAlignment.Guidelines.txt
http://www.iro.umontreal.ca/~simardm/lrec98/
http://www.informatik.uni-trier.de/~ley/db/conf/acl/acl2005.html
http://www.informatik.uni-trier.de/~ley/db/conf/acl/acl2006.html
http://www.informatik.uni-trier.de/~ley/db/conf/acl/acl2007.html
http://en.wikipedia.org/wiki/Bilingual_Evaluation_Understudy
http://nl.ijs.si/telri/
http://en.wikipedia.org/wiki/AntConc
http://corpora.wordpress.com/category/antconc/
http://nltk.sourceforge.net/

Related Mongolian:
http://acl.ldc.upenn.edu/P/P06/P06-1083.pdf
http://crlp.num.edu.mn/
http://www.infocon.mn/tts/ (Mongolian TTS engine in progress)
http://if-lab.slis.tsukuba.ac.jp/fujii/paper/ijcnlp2008khab.pdf

Friday, July 4, 2008

Difference between Response.Redirect and Server.Transfer

I've a secured page that requires users to be logged in.
At the beginning of the page, checks if an user is authenticated and is in right role. When not authenticated, control is redirected to login.aspx which is included Login form.

if (!User.Identity.IsAuthenticated)
{
if (!User.IsInRole("admin"))
{
Server.Transfer("login.aspx");
}
}

This piece of code is telling you cannot see the page if you are not an administrator.
Another one is:

if (!User.Identity.IsAuthenticated)
{
if (!User.IsInRole("admin"))
{
Response.Redirect("login.aspx");
}
}

The difference is Redirect tells client to see login.aspx, Transfer directly executes login.aspx and returns result. I choose Server.Transfer, cus it can be faster.

One more thing:

if (!User.Identity.IsAuthenticated)
{
if (!User.IsInRole("admin"))
{
Response.Redirect("login.aspx?ref=any_page.aspx");
}
}
In login.aspx.cs:
LoginView1.DestinationPageUrl= Request.Params["ref"];

In this case, control jumps to any_page.aspx. I didn't experience it when using Server.Transfer.
I'm not sure its possible.

Wednesday, June 18, 2008

Failed to access IIS metabase problem

I was using VS2008. it had installed .NET framework 3.5 version. This error occurred when i try to view web application that is in IIS. I googled for it and found following soln. It's working perpectly ;)

Possible Cause:-
When you install IIS AFTER .NET 2.0 framework, the rights of the ASPNET user had not been set correctly.

Resolution
Repair (Uninstall if repair does not work for you) .NET Framework 2.0

Simply run the following from command line to reset the IIS registry settings for aspnet user. Usually framework directory for .Net Framework 2.0 resides under C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

Thursday, May 29, 2008

Tree in a datagrid

I used DevExpress.XtraTreeList.TreeList component to show tree structured DB table on a form. It was so easy.

create table treesamp (
nodeid number(5),
parentnodeid number(5),
datatext varchar2(50)
);

Sample table data:
1 0 "Root"
2 1 "Leaf 1"
3 1 "Leaf 2"
4 2 "Leaf 1 of Leaf 1"
5 2 "Leaf 2 of Leaf 1"
6 3 "Leaf 1 of Leaf 2"
7 3 "Leaf 2 of Leaf 2"
8 4 "Leaf 1 of Leaf 1 of Leaf 1"
...

Place your TreeList on a form and just set following values:

treelist1.DataSource= treeDataTable;
treelist1.KeyFieldName= "nodeid";
treelist1.ParentFieldName= "parentid";
treelist1.PreviewFieldName= "datatext";
RootValue= 0; // if id of parent is zero, it must be root node

To print the tree treeList1.ShowPrintPreview();
It prints it in XtraReport Preview, the same as in form grid.

Monday, March 24, 2008

oracle cast function in stored procedure

There is a thing can be called stupid in oracle. I can't understand the reason!
This is a piece of code in a Oracle Trigger. Decimal numbers are compared roundly by double precision.

if (cast(to_char(:new.unit_price) as number(14,2)) = cast(to_char(v_ppl_unit_price) as number(14,2))) then
:new.unit_price := v_temp_new_unit_price;
end if;

But after executed this code, an error is occurred:

Error: PLS-00103: Encountered the symbol "(" when expecting one of the following:
. ) @ %
The symbol ")" was substituted for "(" to continue.
Line: 122
Text: if ( cast(:new.unit_price as number(14, 5)) =

And i found out how to fix it.
that is declare a subtype, and use it on cast:

declare
subtype number_14_2 is number(14, 2);
...
begin
...
if (cast(to_char(:new.unit_price) as number_14_2) = cast(to_char(v_ppl_unit_price) as number_14_2)) then
:new.unit_price := v_temp_new_unit_price;
end if;
...
end

It's done! How strange!

Thursday, March 20, 2008

What's the difference between varchar, varchar2?

Монгол хэл дээр бичигдсэнийг харахыг хүсвэл:
http://mongolcoder.blogspot.com/2008/03/varchar-varchar2.html

Varchar and varchar2 are data types of Oracle DB and what's the difference between them?
First: Size, varchar can store 2000 bytes information, but varchar2 can store 4000 bytes information.
Second: Encoding or language chooser(:D), varchar supports ascii, but varchar2 supports unicode.
In addition to this, mongolian character's take 2 bytes space, but english characters take 1 bytes space.

Tuesday, March 11, 2008

ORA-06502 error occurred while calling stored procedure from C#

Here is a Oracle stored procedure.

create or replace procedure GETVPNOFROMPNO(p_pno in varchar2, ret out varchar2) is
r SYS_REFCURSOR;
npno1 varchar2(255);
retval varchar2(255);
begin
retval:= p_pno;
open r for
select npno from parts_for_update_npno where parts_for_update_npno.pno= p_pno and npno is not null;
fetch r into npno1;
if r%NOTFOUND then
ret:= retval;
return;
end if;
retval:= p_pno||' /'||npno1;
ret:= retval;
end GETVPNOFROMPNO;

As you see, there is no need of REF CURSOR. I declared it just for further use.
And here is a function that calls the stored procedure above.

public static string getVPNOfromPNO(OracleConnection c, string pno)
{
OracleCommand cmd = null;
try
{
c.Open();
cmd = c.CreateCommand();
cmd.CommandText = "GETVPNOFROMPNO";
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("p_pno", OracleType.VarChar);
cmd.Parameters["p_pno"].Value = pno;
cmd.Parameters["p_pno"].Direction = ParameterDirection.Input;

cmd.Parameters.Add("ret", OracleType.VarChar);
cmd.Parameters["ret"].Value = "";
cmd.Parameters["ret"].Direction = ParameterDirection.Output;

cmd.ExecuteNonQuery();
c.Close();
//MessageBox.Show("Suces");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
Program.setStatus("Error while getting ...!", ex);
}
return cmd.Parameters["ret"].Value.ToString();
}

Do you think there is any error? I thought not, but there was.
While executing, this code throws "ORA-06502: numeric or value error: character string buffer too small" exception.

The error is corrected by changing cmd.Parameters["ret"].Value = ""; to cmd.Parameters["ret"].Value = "__________________";

Why? I used parameter for getting output value. The too small string buffer in the error description is cmd.Parameters["ret"].Value that is length of zero. After setting enough space for this variable, it was OK. If i used oracle function, it would be OK without any problem.