Package com.clearnlp.util.map

Examples of com.clearnlp.util.map.Prob2DMap


  }
 
  public void evaluateInflection(Map<String,Prob2DMap> rmap, Set<String> baseSet, String goldBase, String form)
  {
    if (!form.endsWith(s_affixForm)) return;
    Prob2DMap map = rmap.get(s_affixForm);
   
    if (map == null)
    {
      map = new Prob2DMap();
      rmap.put(s_affixForm, map);
    }

    int subLen = form.length() - s_affixForm.length();
    String stem = form.substring(0, subLen);
View Full Code Here


  }
 
  public void evaluateDerivation(Map<String,Prob2DMap> rmap, Map<String,Set<String>> baseMap, boolean correct, String form)
  {
    if (!form.endsWith(s_affixForm)) return;
    Prob2DMap map = rmap.get(s_affixForm);
   
    if (map == null)
    {
      map = new Prob2DMap();
      rmap.put(s_affixForm, map);
    }

    int subLen = form.length() - s_affixForm.length();
    String stem = form.substring(0, subLen);
View Full Code Here

  public EnglishOnlinePOSTagger(JointFtrXml[] xmls, Set<String> sLsfs)
  {
    super(xmls);
    f_xml  = f_xmls[0];
    s_lsfs = sLsfs;
    p_ambi = new Prob2DMap();
  }
View Full Code Here

 
  void extractVerbPP(String[] args)
  {
    SRLReader reader = new SRLReader(0, 1, 2, 3, 4, 5, 6, 8);
    reader.open(UTInput.createBufferedFileReader(args[0]));
    Prob2DMap map = new Prob2DMap();
    DEPTree tree;
   
    while ((tree = reader.next()) != null)
      extractVerbPPAux(tree, map);
   
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[1]);
    List<String> verbs = Lists.newArrayList(map.keySet());
    Collections.sort(verbs);
    StringIntPair[] ps;
   
    for (String verb : verbs)
    {
      ps = map.getCounts(verb);
      UTArray.sortReverseOrder(ps);
     
      for (StringIntPair p : ps)
      {
        if (p.i > 1)
View Full Code Here

  void getVerbForms(String[] args)
  {
    DEPReader fin = new DEPReader(0, 1, 2, 3, 4, 5, 6);
    fin.open(UTInput.createBufferedFileReader(args[0]));
    Set<String> keys = new TreeSet<String>();
    Prob2DMap mVBD = new Prob2DMap();
    Prob2DMap mVBN = new Prob2DMap();
    String form, base, past, part;
    int i, size, cutoff = 1;
    DEPTree tree;
    DEPNode node;
   
    while ((tree = fin.next()) != null)
    {
      size = tree.size();
     
      for (i=1; i<size; i++)
      {
        node = tree.get(i);
        base = node.lemma;
        form = node.form.toLowerCase();
        past = LGVerbEn.getPastRegularForm(base);
       
        if (node.isPos(CTLibEn.POS_VBD))
        {
          if (!form.equals(past))
            mVBD.add(base, form);
        }
        else if (node.isPos(CTLibEn.POS_VBN))
        {
          if (!form.equals(past))
            mVBN.add(base, form);
        }
      }
    }
   
    keys.addAll(mVBD.keySet());
    keys.addAll(mVBN.keySet());
   
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[1]);
   
    for (String key : keys)
    {
      past = (mVBD.getTotal1D(key) > cutoff) ? mVBD.getBestProb1D(key).s : UNPunct.UNDERSCORE;
      part = (mVBN.getTotal1D(key) > cutoff) ? mVBN.getBestProb1D(key).s : UNPunct.UNDERSCORE;
     
      if (!past.equals(UNPunct.UNDERSCORE) || !part.equals(UNPunct.UNDERSCORE))
        fout.println(key+"\t"+past+"\t"+part);
    }
   
View Full Code Here

    final String NONE = "NONE";

    SRLReader reader = new SRLReader(0, 1, 2, 3, 4, 5, 6, 8);
    reader.open(UTInput.createBufferedFileReader(inputFile));
    PrintStream fout = UTOutput.createPrintBufferedFileStream(outputFile);
    Prob2DMap map = new Prob2DMap();
    DEPNode node, head;
    String deprel, label, ftags;
    DEPTree tree;
    int i, size;
   
    while ((tree = reader.next()) != null)
    {
      size = tree.size();
     
      for (i=1; i<size; i++)
      {
        node   = tree.get(i);
        head   = node.getHead();
        deprel = node.getLabel();
        if ((ftags = node.getFeat(DEPLib.FEAT_SEM)) != null)
          deprel = ftags;
       
        for (DEPArc arc : node.getSHeads())
        {
          label = arc.getLabel();
        //  if (label.startsWith("R-AM"))
        //    label = label.substring(2);
         
          if (arc.getNode() == head)
            map.add(label, deprel);
          else
            map.add(label, NONE);
        }
      }
    }
   
    List<String> keys = new ArrayList<String>(map.keySet());
    DecimalFormat format = new DecimalFormat("##.##");
    Collections.sort(keys);
    StringDoublePair[] ps;
    StringBuilder build;
    double none;
    String tmp;
   
    for (String key : keys)
    {
      build = new StringBuilder();
      ps = map.getProb1D(key);
      Arrays.sort(ps);
      none = 0;
     
      for (StringDoublePair p : ps)
      {
        if (p.s.equals(NONE))
          none = p.d;
        else if (p.d >= 0.2)
        {
          build.append("\\d"+p.s.toUpperCase());
          build.append(":");
          build.append(format.format(100d*p.d));
          build.append(", ");
        }
      }
     
      tmp = build.length() == 0 ? "" : build.substring(0, build.length()-2);
      fout.printf("%s\t%s\t%f\t%d\t%d\n", key, tmp, 100d*none, map.get(key).get(NONE), map.getTotal1D(key));
    }
   
    fout.close();
  }
View Full Code Here

    double threshold = 0.95;
   
    BufferedReader fin = UTInput.createBufferedFileReader(semlinkFile);
    PrintStream fout = UTOutput.createPrintBufferedFileStream(outFile+"."+threshold);
    Set<String> set = new HashSet<String>();
    Prob2DMap poly = new Prob2DMap();
    String line, roleset, verbnet;
    Set<String> vnset;
    String[] t;

    while ((line = fin.readLine()) != null)
    {
      t = DELIM.split(line);
      set.add(getKey(t));
     
      verbnet = t[5];
      roleset = t[7];
      vnset   = pvMap.getVNSet(roleset);
     
      if (vnset.size() > 1)
        poly.add(roleset, verbnet);
    }
   
    List<String> keys = new ArrayList<String>(poly.keySet());
    Map<String,String> map = new HashMap<String,String>();
    Collections.sort(keys);
    StringDoublePair[] ps;
   
    for (String key : keys)
    {
      ps = poly.getProb1D(key);
      Arrays.sort(ps);
     
      if (ps[0].d < threshold)
      {
        fout.println(toString(key, ps));
View Full Code Here

  public AbstractPOSTagger(JointFtrXml[] xmls, Set<String> sLsfs)
  {
    super(xmls);

    s_lsfs = sLsfs;
    p_ambi = new Prob2DMap();
  }
View Full Code Here

 
  private void printEvaluation(Map<String,Map<String,Prob2DMap>> smap)
  {
    Map<String,Prob2DMap> rmap;
    List<String> skeys, rkeys;
    Prob2DMap map;
   
    skeys = Lists.newArrayList(smap.keySet());
    Collections.sort(skeys);
   
    for (String skey : skeys)
    {
      System.out.println(skey);
      rmap = smap.get(skey);
      rkeys = Lists.newArrayList(rmap.keySet());
      Collections.sort(rkeys);
     
      for (String rkey : rkeys)
      {
        map = rmap.get(rkey);
       
        for (String key : map.keySet())
          System.out.printf("%s\t%s\t%s\t%d\n", rkey, key, Arrays.toString(map.getProb1D(key)), map.getTotal1D(key));
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.clearnlp.util.map.Prob2DMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.