Package edu.harvard.wcfia.yoshikoder.concordance

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


        for (Iterator iter = docs.iterator(); iter.hasNext();) {
          YKDocument d = (YKDocument) iter.next();
          TokenList tl2 = tcache.getTokenList(d);
          if (tl2 == null)
            tl2 = TokenizationService.getTokenizationService().tokenize(d);
          Concordance conc = dict.getConcordance(tl2, catnode, wsize);
         
          // note _all_categories counted (implicitly around catnode matches)
          counts = getDocumentStats(d.getTitle(), conc, keys, dict.getDictionaryRoot());

          row = sheet.createRow((short)rownum);
View Full Code Here


        for (Iterator iter = docs.iterator(); iter.hasNext();) {
          YKDocument d = (YKDocument) iter.next();
          TokenList tl2 = tcache.getTokenList(d);
          if (tl2 == null)
            tl2 = TokenizationService.getTokenizationService().tokenize(d);
          Concordance conc = dict.getConcordance(tl2, catnode, wsize);
         
          counts = getDocumentStats(d.getTitle(), conc, keys, dict.getDictionaryRoot());

          writer.write(FileUtil.escapeForCsv(d.getTitle()));
          for (int ii = 0; ii < keys.length; ii++) {
View Full Code Here

        TokenList tl = tcache.getTokenList(doc);
        if (tl == null){
          tl = service.tokenize(doc);
          tcache.putTokenList(doc, tl);
        }
        Concordance c = yoshikoder.getDictionary().getConcordance(tl, n, wsize);
        map.put(doc, c);
      }
      return map;
    }
View Full Code Here

    if (true)
      return;
   
    //Concordance c1 = new ConcordanceImpl(conc, winSize)
   
    Concordance c = ImportUtil.importConcordance(new File("/Users/will/Desktop/conc.ykc"));
    System.out.println(c);
    //YKDocument doc1 = YKDocumentFactory.createDummyDocument("Title 1", "foo", "UTF-8");
    //YKDocument doc2 = YKDocumentFactory.createDummyDocument("Title 2", "bar", "UTF-8");
    Map<YKDocument,Concordance> map = new HashMap<YKDocument,Concordance>();
    map.put(doc1, c);
View Full Code Here

        super(new String[]{"Document", "", "Target", "" }, c.size());
      map = c;
     
        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();
View Full Code Here

    protected Set<Token> getMatchingTokens(TokenList tl, PatternNode node){
        return tl.getMatchedTokens(node.getPattern());
    }
  
    protected Concordance getConcordance(TokenList tokens, PatternNode pnode, int wsize){
        Concordance conc = tokens.getConcordance(pnode.getPattern(), wsize);
      return conc;
  }
View Full Code Here

            return getConcordance(tl, (CategoryNode)node, wsize);   
        return getConcordance(tl, (PatternNode)node, wsize);       
    }
   
    protected Concordance getConcordance(TokenList tokens, CategoryNode cnode, int wsize){
        Concordance conc = new ConcordanceImpl( wsize );
        for (Enumeration<Node> enumeration = cnode.children(); enumeration.hasMoreElements();) {
            Object o = enumeration.nextElement();
            Concordance c = new ConcordanceImpl( wsize );
            // yuck
            if (o instanceof CategoryNode)
                c = getConcordance(tokens, (CategoryNode)o, wsize);
            else
                c = getConcordance(tokens, (PatternNode)o, wsize);
View Full Code Here

    public Concordance getConcordance(Pattern p, int win){
      return getConcordance(new Pattern[]{p}, win);
    }
   
    public Concordance getConcordance(Pattern[] p, int win){
      Concordance conc = new ConcordanceImpl(win);
     
      Set<Integer> startingIndices = getMatchStartingIndices(p);
      int tot = size();
      for (Integer start : startingIndices) {
        Token middle = null;
        if (p.length > 1)
          middle = createSingleFakeToken(start, start+p.length);
        else
          middle = get(start);
       
        int st = Math.max(0, start-win);
        TokenList leftTL = new TokenListImpl();
        if (st != start){ // can go further left
          for (int ii = st; ii < start; ii++)
          leftTL.add(get(ii));
        }
       
        int end = Math.min(tot, start+p.length+win);
        TokenList rightTL = new TokenListImpl();
        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

           
          protected void doWork() throws Exception {
            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);
                }
View Full Code Here

            new File(concordanceSaver.getDirectory(), FileUtil.suffix(fname, "ykc"));
        tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
             
              YKDocument d = concordance.keySet().iterator().next();
                Concordance conc = concordance.get(d);
                int ws = conc.getWindowSize();
              ExportUtil.exportAsXML(concordance, ws, file); // save in the new style
            }
            protected void onError() {
                DialogUtil.yelp(yoshikoder, "Could not save concordance", e);
            }
View Full Code Here

TOP

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

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.