

 
Manual Reference Pages  TEXT::NSP::MEASURES::4D (3)
.ds Aq ’
NAME
Text::NSP::Measures::4D  Perl module that provides basic framework for
building measure of association for 4grams.
CONTENTS
SYNOPSIS
This module can be used as a foundation for building 4dimensional
measures of association that can then be used by statistic.pl. In
particular this module provides methods that give convenient access to
4d (i.e., 4gram) frequency counts as created by count.pl, as well as
some degree of error handling that verifies the data.
Basic Usage
use Text::NSP::Measures::4D::MI::ll;
$ll_value = calculateStatistic(
n1111=>8,
n1ppp=>306,
np1pp=>83,
npp1p=>83,
nppp1=>57,
n11pp=>8,
n1p1p=>8,
n1pp1=>8,
np11p=>83,
np1p1=>56,
npp11=>56,
n111p=>8,
n11p1=>8,
n1p11=>8,
np111=>56,
npppp=>15180);
if( ($errorCode = getErrorCode()))
{
print STDERR $erroCode."  ".getErrorMessage()."\n";
}
else
{
print getStatisticName."value for 4gram is ".$ll_value."\n";
}
DESCRIPTION
The methods in this module retrieve observed 4gram frequency counts and
marginal totals, and also compute expected values. They also provide
support for error checking of the output produced by count.pl. These
methods are used in all the 4gram (4d) measure modules provided in NSP.
If you are writing your own 4d measure, you can use these methods as well.
With 4gram or 4d measures we use a 4x4 contingency table to store the
frequency counts associated with each word in the trigram, as well as the
number of times the trigram occurs. The notation we employ is as follows:
Marginal Frequencies:
n1ppp = the number of ngrams where the first word is word1.
np1pp = the number of ngrams where the second word is word2.
npp1p = the number of ngrams where the third word is word3
nppp1 = the number of ngrams where the fourth word is word4
n2ppp = the number of ngrams where the first word is not word1.
np2pp = the number of ngrams where the second word is not word2.
npp2p = the number of ngrams where the third word is not word3.
nppp2 = the number of ngrams where the fourth words is not word4
Observed Frequencies:
n1111 = number of times word1, word2 and word3 occur together in
their respective positions, joint frequency.
n1112 = number of times word1, word 2 and word3 occur in their respective
positions but word4 does not.
n1121 = number of times word1, word2 and word4 occur in their respective
positions but word3 does not.
n1122 = number of times word1 and word2 occur in their repsective positions
but word3 and word4 do not.
n1211 = number of times word1, word3 and word4 occur in their respective
positions but word2 does not.
n1212 = number of times word1 and word3 occur in their respective positions
but word2 and word4 do not.
n1221 = number of times word1 and word4 occur in their respective positions
but word2 and word3 do not
n1222 = number of times word1 occurs in its respective position but word2,
word3 and word4 do not.
n2111 = number of times word2, word3 and word4 occur in their respective
positions but word1 does not.
n2112 = number of times word2 and word3 occur in their respective positions
but word1 and word4 do not.
n2121 = number of times word2 and word4 occur in their respective positions
but word1 and word3 do not.
n2122 = number of times word2 occurs in its respective position but word1,
word3 and word4 do not.
n2211 = number of times word3 and word4 occur in their respective positions
but word1 and word2 do not.
n2212 = number of times word3 occurs in its respective position but word1,
word2 and word4 do not.
n2221 = number of times word4 occurs in its respective position but word1,
word2, and word3 do not.
n2222 = number of times neither word1, word2, word3 or word4 occur in their
respective positions.
Expected Frequencies:
m1111 = expected number of times word1, word2 and word3 occur together in
their respective positions, joint frequency.
m1112 = expected number of times word1, word 2 and word3 occur in their respective
positions but word4 does not.
m1121 = expected number of times word1, word2 and word4 occur in their respective
positions but word3 does not.
m1122 = expected number of times word1 and word2 occur in their repsective positions
but word3 and word4 do not.
m1211 = expected number of times word1, word3 and word4 occur in their respective
positions but word2 does not.
m1212 = expected number of times word1 and word3 occur in their respective positions
but word2 and word4 do not.
m1221 = expected number of times word1 and word4 occur in their respective positions
but word2 and word3 do not
m1222 = expected number of times word1 occurs in its respective position but word2,
word3 and word4 do not.
m2111 = expected number of times word2, word3 and word4 occur in their respective
positions but word1 does not.
m2112 = expected number of times word2 and word3 occur in their respective positions
but word1 and word4 do not.
m2121 = expected number of times word2 and word4 occur in their respective positions
but word1 and word3 do not.
m2122 = expected number of times word2 occurs in its respective position but word1,
word3 and word4 do not.
m2211 = expected number of times word3 and word4 occur in their respective positions
but word1 and word2 do not.
m2212 = expected number of times word3 occurs in its respective position but word1,
word2 and word4 do not.
m2221 = expected number of times word4 occurs in its respective position but word1,
word2, and word3 do not.
m2222 = expected number of times neither word1, word2, word3 or word4 occur in their
respective positions.
=head2 Methods

computeObservedValues($count_values)  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($count_values)  A method to compute expected values.

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

computeMarginalTotals($marginal_values)  This method computes the marginal totals from the valuescomputed by the count.pl program and are passed to the calculateStatistic() method.

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
<bthomson@cs.umn.edu>
Saiyam Kohli, University of Minnesota Duluth
<kohli003@d.umn.edu>
HISTORY
Last updated: $Id: 4D.pm,v 1.3 2010/11/12 18:40:23 btmcinnes Exp $
BUGS
SEE ALSO
<http://groups.yahoo.com/group/ngram/>
<http://www.d.umn.edu/~tpederse/nsp.html>
COPYRIGHT
Copyright (C) 20002008, 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::4D (3)  20101112 
Visit the GSP FreeBSD Man Page Interface. Output converted with manServer 1.07. 