Package edu.harvard.wcfia.yoshikoder.concordance

Examples of edu.harvard.wcfia.yoshikoder.concordance.ConcordanceLine


  protected int[] getDocumentStats(String docTitle, Concordance conc, Node[] keys, CategoryNode catnode) throws IOException, TokenizationException {

    // pull out the right and left hand sides
    StringBuffer sb = new StringBuffer();
    for (Iterator iterator = conc.iterator(); iterator.hasNext();) {
      ConcordanceLine cl = (ConcordanceLine) iterator.next();
      sb.append(cl.getLeftHandSideView());
      sb.append(" ");
      sb.append(cl.getRightHandSideView());
      sb.append(" ");
    }
    // tokenize and apply dictionary to the 'document'
    YKDocument doc = new YKDocumentImpl(docTitle, sb.toString());
    TokenList tl = TokenizationService.getTokenizationService().tokenize(doc);
View Full Code Here


        data = new ArrayList<ConcLineWrapper>();
        for (YKDocument doc : c.keySet()) {
        Concordance conc = c.get(doc);
       
        for (Iterator<ConcordanceLine> iterator = conc.iterator(); iterator.hasNext();) {
          ConcordanceLine concordanceLine = iterator.next();
          int s1 = concordanceLine.getLeftHandSide().get(0).getStart();
          int e1 = concordanceLine.getLeftHandSide().get(0).getEnd();
          int s2 = concordanceLine.getTarget().getStart();
          int e2 = concordanceLine.getTarget().getEnd();
          int s3 = concordanceLine.getRightHandSide().get(concordanceLine.getRightHandSide().size()-1).getStart();
          int e3 = concordanceLine.getRightHandSide().get(concordanceLine.getRightHandSide().size()-1).getEnd();
          ConcLineWrapper wrapper = new ConcLineWrapper(doc, s1, e1, s2, e2, s3, e3);             
          data.add(wrapper);
        }
        }
       
View Full Code Here

    model1.clear();
    model2.clear();
    model3.clear();
    if (conc != null) {
      for (Iterator iter = conc.iterator(); iter.hasNext();) {
        ConcordanceLine line = (ConcordanceLine) iter.next();
        String[] els = concat(line);
        model1.addElement(els[0]);
        model2.addElement(els[1]);
        model3.addElement(els[2]);
      }
View Full Code Here

        if (end != start+p.length){ // can go further right
          for (int ii = start+p.length; ii < end; ii++)
          rightTL.add(get(ii));
        }
       
        ConcordanceLine line = new ConcordanceLineImpl(leftTL, middle, rightTL);
        conc.addLine(line);
      }
      return conc;
    }
View Full Code Here

            EntryFrequencyMap efm = null;
            for (YKDocument doc : concmap.keySet()) {
              TokenList tlist = new TokenListImpl();
              Concordance conc = concmap.get(doc);
              for (Iterator iter = conc.iterator(); iter.hasNext();) {
                ConcordanceLine line = (ConcordanceLine) iter.next();
                for (Iterator iterator = line.getLeftHandSide().iterator(); iterator.hasNext();) {
                  Token token = (Token) iterator.next();
                  tlist.add(token);
                }
                for (Iterator iterator = line.getRightHandSide().iterator(); iterator.hasNext();) {
                  Token token = (Token) iterator.next();
                  tlist.add(token);
                }
              }
              efm = new EntryFrequencyMap(yoshikoder.getDictionary(), tlist);
View Full Code Here

        return concordance != null ? concordance.size() : 0;
    }
   
    // implements an adaptor between the table model and the concordance
    public Object getValueAt(int rowIndex, int columnIndex) {
        ConcordanceLine line =
            (ConcordanceLine)concordance.getLines().get(rowIndex);
        if (line != null){
            if (columnIndex < windowSize){
                int diff = windowSize-line.getLeftHandSide().size();
                return columnIndex >= diff ?
                        line.getLeftHandSide().get(columnIndex-diff) : null;
            } else if (columnIndex == windowSize){
                return line.getTarget();
            } else {
                int rIndex = columnIndex - (windowSize+1);
                return rIndex < line.getRightHandSide().size() ?
                        line.getRightHandSide().get(rIndex) : null;
            }
        } else {
            return null;
        }
    }
View Full Code Here

        cell.setCellValue(localTitle);
       
        if (concordance != null) {
            ii = 0;
            for (Iterator<ConcordanceLine> iter = concordance.getLines().iterator(); iter.hasNext();) {
                ConcordanceLine line = (ConcordanceLine)iter.next();
                // contents
                row = sheet.createRow((short)ii + 2);
               
                cell = row.createCell((short)0);
                cell.setEncoding(HSSFCell.ENCODING_UTF_16);
                cell.setCellStyle(lhs);
                cell.setCellValue(line.getLeftHandSideView());
               
                cell = row.createCell((short)1);
                cell.setEncoding(HSSFCell.ENCODING_UTF_16);
                cell.setCellStyle(tar);
                cell.setCellValue(line.getTargetView());
               
                cell = row.createCell((short)2);
                cell.setEncoding(HSSFCell.ENCODING_UTF_16);
                cell.setCellStyle(rhs);
                cell.setCellValue(line.getRightHandSideView());
               
                ii++;
            }
        }
        FileOutputStream fout = new FileOutputStream(f.toString());
View Full Code Here

        String doclab = "<td><b>" + escapeXML(doc.getTitle()) + "</b>&nbsp;&nbsp;</td>\n";
        String doclabDimmed = "<td class='dimmed'>" + escapeXML(doc.getTitle()) + "</td>\n";
        Concordance conc = map.get(doc);
        int counter = 0;
        for (Iterator<ConcordanceLine> iter = conc.iterator(); iter.hasNext();) {
          ConcordanceLine line = iter.next();
          if (counter > 0)
              sb.append(doclabDimmed);
          else
            sb.append(doclab);
          counter++;
         
          TokenList lhs = line.getLeftHandSide();
          sb.append("<td class='right'>");
          for (Iterator<Token> iterator = lhs.iterator(); iterator.hasNext();) {
            Token word = iterator.next();
            sb.append(escapeXML(word.getText()) + " ")
          }
          sb.append("</td><td><b>");
          sb.append(escapeXML(line.getTarget().getText()));
          TokenList rhs = line.getRightHandSide();
          sb.append("</b>");
          for (Iterator<Token> iterator = rhs.iterator(); iterator.hasNext();) {
            Token word = iterator.next();
            sb.append(" " + escapeXML(word.getText()))
          }
View Full Code Here

        for (YKDocument doc : map.keySet()) {
          sb.append("<concgroup>\n");
          sb.append(toXML(doc));
          Concordance conc = map.get(doc);
          for (Iterator<ConcordanceLine> iter = conc.iterator(); iter.hasNext();) {
            ConcordanceLine line = iter.next();
            sb.append("<line>");
            TokenList lhs = line.getLeftHandSide();
            for (Iterator<Token> iterator = lhs.iterator(); iterator.hasNext();) {
              Token word = iterator.next();
              sb.append("<w txt=\"" + escapeXML(word.getText()) + "\"/>")
            }
            sb.append( "<w txt=\"" + escapeXML(line.getTarget().getText())
            "\" target=\"true\"/>");
            TokenList rhs = line.getRightHandSide();
            for (Iterator<Token> iterator = rhs.iterator(); iterator.hasNext();) {
              Token word = iterator.next();
              sb.append("<w txt=\"" + escapeXML(word.getText()) + "\"/>")
            }
            sb.append("</line>\n");
View Full Code Here

        sb.append(xmlHeader);
        sb.append("<concordance style=\"050805\"");
        sb.append(" windowsize=\"" + conc.getWindowSize() + "\"")
        sb.append(" creationdate=\"" + (new java.util.Date()) + "\">\n");
        for (Iterator<ConcordanceLine> iter = conc.iterator(); iter.hasNext();) {
            ConcordanceLine line = iter.next();
            sb.append("    <line>");
            TokenList lhs = line.getLeftHandSide();
            for (Iterator<Token> iterator = lhs.iterator(); iterator.hasNext();) {
                Token word = iterator.next();
                sb.append("<w txt=\"" + escapeXML(word.getText()) + "\"/>")
            }
            sb.append( "<w txt=\"" + escapeXML(line.getTarget().getText())
            "\" target=\"true\"/>");
            TokenList rhs = line.getRightHandSide();
            for (Iterator<Token> iterator = rhs.iterator(); iterator.hasNext();) {
                Token word = iterator.next();
                sb.append("<w txt=\"" + escapeXML(word.getText()) + "\"/>")
            }
            sb.append("</line>\n");
View Full Code Here

TOP

Related Classes of edu.harvard.wcfia.yoshikoder.concordance.ConcordanceLine

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.