Manual Reference Pages  TEXT::NSP::MEASURES::2D (3)
.ds Aq ’
NAME
Text::NSP::Measures::2D  Perl module that provides basic framework
for building measure of association for
bigrams.
CONTENTS
SYNOPSIS
Basic Usage
use Text::NSP::Measures::2D::MI::ll;
my $npp = 60; my $n1p = 20; my $np1 = 20; my $n11 = 10;
$ll_value = calculateStatistic( n11=>$n11,
n1p=>$n1p,
np1=>$np1,
npp=>$npp);
if( ($errorCode = getErrorCode()))
{
print STDERR $errorCode."  ".getErrorMessage()."\n"";
}
else
{
print getStatisticName."value for bigram is ".$ll_value."\n"";
}
DESCRIPTION
This module is to be used as a foundation for building 2dimensional
measures of association. The methods in this module retrieve observed
bigram frequency counts, marginal totals, and also compute expected
values. They also provide error checks for these counts.
With bigram or 2d measures we use variables with corresponding names
to store the 2x2 contingency table to store the frequency counts
associated with each word in the bigram, as well as the number of
times the bigram occurs. A contingency table looks like
word2  notword2

word1  n11  n12  n1p
notword1  n21  n22  n2p

np1 np2 npp
Marginal Frequencies:
n1p = the number of bigrams where the first word is word1.
np1 = the number of bigrams where the second word is word2.
n2p = the number of bigrams where the first word is not word1.
np2 = the number of bigrams where the second word is not word2.
These marginal totals are stored in variables which have names
corresponding to the cell they represent. These values may then be
referred to as follows:
$n1p,
$np1,
$n2p,
$np2,
$npp
Observed Frequencies:
n11 = number of times the bigram occurs, joint frequency
n12 = number of times word1 occurs in the first position of a bigram
when word2 does not occur in the second position.
n21 = number of times word2 occurs in the second position of a
bigram when word1 does not occur in the first position.
n22 = number of bigrams where word1 is not in the first position and
word2 is not in the second position.
The observed frequencies are also stored in variables with corresponding names.
These values may then be referred to as follows:
$n11,
$n12,
$n21,
$n22
Expected Frequencies:
m11 = expected number of times both words in the bigram occur
together if they are independent. (n1p*np1/npp)
m12 = expected number of times word1 in the bigram will occur in
the first position when word2 does not occur in the second
position given that the words are independent. (n1p*np2/npp)
m21 = expected number of times word2 in the bigram will occur
in the second position when word1 does not occur in the first
position given that the words are independent. (np1*n2p/npp)
m22 = expected number of times word1 will not occur in the first
position and word2 will not occur in the second position
given that the words are independent. (n2p*np2/npp)
Similarly the expected values are stored as
$m11,
$m12,
$m21,
$m22
Methods
computeObservedValues()  A method to compute observed values, and also to verify that the computed Observed values are correct, That is they are positive, less than the marginal totals and the total bigram count.

INPUT PARAMS : $count_values .. Reference to an hash consisting
of the count values passed to
the calculateStatistic() method.
RETURN VALUES : 1/undef ..returns ’1’ to indicate success
and an undefined(NULL) value to indicate
failure.

computeExpectedValues()  A method to compute expected values.

INPUT PARAMS :none
RETURN VALUES : 1/undef ..returns ’1’ to indicate success
and an undefined(NULL) value to indicate
failure.

computeMarginalTotals()  This method computes the marginal totals from the count values as passed to it.

INPUT PARAMS : $count_values .. Reference to an hash consisting
of the frequency combination
output.
RETURN VALUES : 1/undef ..returns ’1’ to indicate success
and an undefined(NULL) value to indicate
failure.


AUTHOR
Ted Pedersen, University of Minnesota Duluth
<tpederse@d.umn.edu>
Satanjeev Banerjee, Carnegie Mellon University
<satanjeev@cmu.edu>
Amruta Purandare, University of Pittsburgh
<amruta@cs.pitt.edu>
Bridget ThomsonMcInnes, University of Minnesota Twin Cities
<bthompson@d.umn.edu>
Saiyam Kohli, University of Minnesota Duluth
<kohli003@d.umn.edu>
HISTORY
Last updated: $Id: 2D.pm,v 1.28 2008/03/26 17:25:13 tpederse Exp $
BUGS
SEE ALSO
<http://groups.yahoo.com/group/ngram/>
<http://www.d.umn.edu/~tpederse/nsp.html>
COPYRIGHT
Copyright (C) 20002006, Ted Pedersen, Satanjeev Banerjee,
Amruta Purandare, Bridget ThomsonMcInnes and Saiyam Kohli
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to
The Free Software Foundation, Inc.,
59 Temple Place  Suite 330,
Boston, MA 021111307, USA.
Note: a copy of the GNU General Public License is available on the web
at <http://www.gnu.org/licenses/gpl.txt> and is included in this
distribution as GPL.txt.
perl v5.20.3  TEXT::NSP::MEASURES::2D (3)  20080326 
Visit the GSP FreeBSD Man Page Interface. Output converted with manServer 1.07. 