public DependencyInstance ReadFeatureVector(BinaryReader reader,
DependencyInstance inst,
FeatureVector[,,] fvs,
double[,,] probs,
FeatureVector[,,,] ntFvs,
double[,,,] ntProbs,
Parameters parameters)
{
int length = inst.Length;
// Get production crap.
for (int w1 = 0; w1 < length; w1++)
{
for (int w2 = w1 + 1; w2 < length; w2++)
{
for (int ph = 0; ph < 2; ph++)
{
var prodFV = new FeatureVector();
int indx = reader.ReadInt32();
while (indx != -2)
{
AddNewFeature(indx, 1.0, prodFV);
indx = reader.ReadInt32();
}
double prodProb = parameters.GetScore(prodFV);
fvs[w1, w2, ph] = prodFV;
probs[w1, w2, ph] = prodProb;
}
}
}
int last = reader.ReadInt32();
if (last != -3)
{
Console.WriteLine("Error reading file.");
throw new Exception("Bad File Format");
}
if (Labeled)
{
for (int w1 = 0; w1 < length; w1++)
{
for (int t = 0; t < Types.Length; t++)
{
string type = Types[t];
for (int ph = 0; ph < 2; ph++)
{
for (int ch = 0; ch < 2; ch++)
{
var prodFV = new FeatureVector();
int indx = reader.ReadInt32();
while (indx != -2)
{
AddNewFeature(indx, 1.0, prodFV);
indx = reader.ReadInt32();
}
double ntProb = parameters.GetScore(prodFV);
ntFvs[w1, t, ph, ch] = prodFV;
ntProbs[w1, t, ph, ch] = ntProb;
}
}
}
}
last = reader.ReadInt32();
if (last != -3)
{
Console.WriteLine("Error reading file.");
throw new Exception("Bad File Format");
}
}
var nfv = new FeatureVector();
int next = reader.ReadInt32();
while (next != -4)
{
AddNewFeature(next, 1.0, nfv);
next = reader.ReadInt32();
}
string[] toks = null;
string[] pos = null;
string[] labs = null;
string actParseTree = null;
try
{
int len = reader.ReadInt32();
toks = new string[len];
for (int i = 0; i < len; i++)
{
toks[i] = reader.ReadString();
}
next = reader.ReadInt32();
len = reader.ReadInt32();
pos = new string[len];
for (int i = 0; i < len; i++)
{
pos[i] = reader.ReadString();
}
next = reader.ReadInt32();
len = reader.ReadInt32();
labs = new string[len];
for (int i = 0; i < len; i++)
{
labs[i] = reader.ReadString();
}
next = reader.ReadInt32();
actParseTree = reader.ReadString();
next = reader.ReadInt32();
}
catch (Exception e)
{
Console.WriteLine("Error reading file.");
throw new Exception("Bad File Format");
}
if (next != -1)
{
Console.WriteLine("Error reading file.");
throw new Exception("Bad File Format");
}
var pti = new DependencyInstance(toks, pos, labs, nfv);
pti.ActParseTree = actParseTree;
return pti;
}