Package dnb.analyze

Examples of dnb.analyze.MatchResult


 
  // XXX return if part status has been assigned
  private static void assignMatchStati(NfoLyzeResult result, Repository repository) {
   
    Map<NfoField, MatchResult> m = result.getMatches();
    MatchResult mr;
       
    if((mr = m.get(NfoField.ARTIST)) != null) { // get the artist's match result, if set, proceed!     
      SimilarScanResult<Artist> f = repository.findSimilarArtist(mr.getMatch());
      mr.setSimilarScanResult(f); // ... attach similar matches to the match itself     
      assignMatchStatus(mr, f); // ... assign stati
      if (f != null) { // XXX compose alternatives & show on UI !
        System.out.println("*********" + f);
      }
    }
    if((mr = m.get(NfoField.GENRE)) != null) { // get the genre's match result, if set, proceed!     
      SimilarScanResult<Genre> f = repository.findSimilarGenre(mr.getMatch());
      mr.setSimilarScanResult(f); // ... attach similar matches to the match itself 
      assignMatchStatus(mr, f);
      if (f != null) { // XXX compose alternatives & show on UI !
        System.out.println("GENRE: *********" + f);
      }
    }
   
    if((mr = m.get(NfoField.RECORD_LABEL)) != null) { // get the label's match result, if set, proceed!
     
      SimilarScanResult<Label> f = repository.findSimilarLabel(mr.getMatch());
      mr.setSimilarScanResult(f); // ... attach similar matches to the match itself 
      assignMatchStatus(mr, f);
     
      if (f != null) { // XXX compose alternatives & show on UI !
        System.out.println("LABEL: *********" + f);       
      }
View Full Code Here


    }   
  }
 
  private static void assignLabelFieldMatchStati(Repository repository,
      Map<NfoField, MatchResult> matches) {
    MatchResult lcmatch;
    MatchResult labelmatch = matches.get(NfoField.RECORD_LABEL);
   
    if((lcmatch = matches.get(NfoField.LABEL_CODE)) != null) { // get the lc's match result, if set, proceed!
      // we found a label code, if a label name was also found, cross-reference!       
      if (labelmatch !=  null) { // label name parsed successfully
        // try find matching label from label object alternatives, if any
View Full Code Here

      Labelcode lc;
      SimilarScanResult<Labelcode> srlc = null; // holds the label code alternatives
      Match<Labelcode> mt = null; // holds the virtual match
      // => create virtual label code match from best label match having codes
      final int c = sr.size();
      MatchResult mr = null;
     
      for (int i = 0; i < c; i++) { // iterate label matches
        l = sr.get(i).getFoundObject(); // get label object from match
        if (l.size() == 0) { continue; } // label has no codes => skip
        // label has codes => create matches
        int ci = 0;
        if (mr == null) { // no match result yet => create from best entry & store
          mr = new MatchResult(l.get(ci++).getName(), Source.LOOKUP, Status.SIMILAR); // XXX derived, (not similar) entry ! 
          matches.put(NfoField.LABEL_CODE, mr);
        }
        for (int y = ci; y < l.size(); y++) { // => add other codes as alternatives
          lc = l.get(y);
          // XXX for now, use fake leven, but create virtual match type l8a on
          mt = new Match<Labelcode>(MatchType.LEVENSHTEIN, lc.getName(), lc);
          if (srlc == null) {
            srlc = new SimilarScanResult<Labelcode>(mt);
            mr.setSimilarScanResult(srlc);
          } else { srlc.add(mt); }
        }
      }
     
    } // else {} // no label object matches found, but labelname matched => leave unknown
View Full Code Here

  private static void findLabelByLabelcode(Repository labelLookup,
      MatchResult labelCodeMatch, Map<NfoField, MatchResult> matchStore) {
   
    String lc = labelCodeMatch.getMatch();
    MatchResult mlbl;
    Label other = labelLookup.findByLabelcode(lc);
    if (other != null) { // we got a label name for our code
      // => create virtual label name match!
      mlbl = new MatchResult(other.getName(), Source.LOOKUP, Status.KNOWN);
      mlbl.setSimilarScanResult(new SimilarScanResult<Label>(
          new Match<Label>(MatchType.EXACT, other.getName(), other)));
      matchStore.put(NfoField.RECORD_LABEL, mlbl);
      // set label code match to green & create EXACT scan result
      labelCodeMatch.setStatus(Status.KNOWN);
      Labelcode found = other.findLabelcode(lc); // refind to get the lc object
View Full Code Here

  }

  // XXX: => to postprocessor!
  private static void postProcess(NfoLyzeResult result) {
    // rule 1: known label code = title => set title known
    MatchResult lc = result.getMatches().get(NfoField.LABEL_CODE);
    MatchResult t = result.getMatches().get(NfoField.ALBUM_TITLE);                           
    if(lc != null && t != null // got both title & a known lc
      && lc.getStatus() == Status.KNOWN
      && lc.getMatch().equalsIgnoreCase(t.getMatch())) {     
      t.setStatus(Status.KNOWN);
    }
   
    // rule 2: label name contains a numeric that NfoField.LABEL_CODE_NO starts with => parsing probably failed!
    MatchResult ln = result.getMatches().get(NfoField.RECORD_LABEL);
    MatchResult lcn = result.getMatches().get(NfoField.LABEL_CODE_NO);
   
    if (ln != null && lcn != null) {
      Matcher m = NUMBER_AT_END_PATTERN.matcher(ln.getMatch());     
      String no = lcn.getMatch();     
      if (m.find()) {
        String mt = m.group(1);
        if (no.startsWith(mt)) {
          lcn.setMatch(no.substring(mt.length()));
          lcn.setStart(lcn.getStart() + 2);
          lc.setMatch(lc.getMatch() + mt);
          lc.setEnd(lc.getEnd() + 2);
          System.err.println("!!!!!!!ERROR!!!!!!!!!!!!!!!!");
          // XXX: => visualize this critital error & its correction on the ui
        }       
View Full Code Here

      highlightedResult = null;
    }
    if (filteredMatchMap == null) {
      return;
    }
    MatchResult m = filteredMatchMap.get(field);
    if (m == null) {
      return;     
    }
    highlightedResult = m; 
           
    doc.setCharacterAttributes(m.getStart(), m.getEnd() - m.getStart(),
        getStyle(styleKey(highlightedResult.getStatus(), true)), true);
    setCaretPosition(m.getStart());
  }
View Full Code Here

          return 0;
        }
      }});
   
    // mark results
    MatchResult m;
    int offs = 0;
    for (Entry<NfoField, MatchResult> e : filteredMatches) {
      m = e.getValue();
//      System.out.println(m); 
      if (m.getMatch().isEmpty()) {
        continue;
      }     
      doc.setCharacterAttributes(m.getStart() + offs, m.getEnd() - m.getStart(),
          getStyle(styleKey(m.getStatus(), false)), true);
      try {
        // adapt the MatchResults' positions
        m.setStart(m.getStart() + offs);
        m.setEnd(m.getEnd() + offs);
       
        doc.insertString(m.getEnd(), Integer.toString(e.getKey().ordinal()), getStyle(STYLE_SUPER));
        offs++;
      } catch (BadLocationException e1) {       
        e1.printStackTrace();
      }
    }
View Full Code Here

      parseLabelcode(m.group(1), m.start(1), result);             
    }
   
    m = PATTERN_LABEL.matcher(nfo);
    if(m.find()) {
      result.put(NfoField.RECORD_LABEL, new MatchResult(m.start(1), m.end(1), m.group(1),
          MatchResult.Source.NFO));
   
   
    m = PATTERN_MEDIATYPE.matcher(nfo);   
    if(m.find()) { // find the whole option record => store groups as separate & KNOWN fields
      result.put(NfoField.MEDIA_TYPE, new MatchResult(m.start(1), m.end(1), m.group(1),
          MatchResult.Source.NFO));
    }
  } 
View Full Code Here

    // general, easy stuff
    super.parse(nfo, result);
    // sour specialties
    Matcher m = PATTERN_LABEL.matcher(nfo);
    if(m.find()) {
      result.put(NfoField.RECORD_LABEL, new MatchResult(m.start(1), m.end(1), m.group(1),
          MatchResult.Source.NFO));
      parseLabelcode(m.group(2), m.start(2), result);           
    }
   
    m = PATTERN_MEDIATYPE.matcher(nfo);   
    if(m.find()) { // find the whole option record => store groups as separate & KNOWN fields
      result.put(NfoField.MEDIA_TYPE_VINYL, new MatchResult(m.start(1), m.end(1), m.group(1), MatchResult.Status.KNOWN,
          MatchResult.Source.NFO));
      result.put(NfoField.MEDIA_TYPE_TAPE, new MatchResult(m.start(2), m.end(2), m.group(2), MatchResult.Status.KNOWN,
          MatchResult.Source.NFO));
      result.put(NfoField.MEDIA_TYPE_CD, new MatchResult(m.start(3), m.end(3), m.group(3), MatchResult.Status.KNOWN,
          MatchResult.Source.NFO));
      result.put(NfoField.MEDIA_TYPE_RADIO, new MatchResult(m.start(4), m.end(4), m.group(4), MatchResult.Status.KNOWN,
          MatchResult.Source.NFO));     
    }
  } 
View Full Code Here

  }
 
  // method for overall worst-status for Interaction impl 2 check whether 2 bother the user !
  public MatchResult.Status getWorstMatchResultStatus() {
    MatchResult.Status ret = MatchResult.Status.KNOWN; // assume known @ start & get worse ;-)
    MatchResult m;
    MatchResult.Status s;
    for (NfoField f : OVERALL_STATUS_FIELDS) {
      m = matches.get(f);
      if (m == null) { // elementary field not set => worst, worst case
        return MatchResult.Status.UNKNOWN; // => bail out with unknown
      }
      s = m.getStatus();     
      if (s.isWorseThan(ret)) {
        ret = s;
      }
    }
    return ret;
View Full Code Here

TOP

Related Classes of dnb.analyze.MatchResult

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.