Example #1
0
void segSOF() {
    int i,ch,com,temp,maxx,temp2;
    uint32 dusize;

    maxx=maxy=0;
    ch = fromseg();
    height = wordseg();
    width = wordseg();
    ch = fromseg();
    ncomp = ch;

    for (i=0; i<ch; i++) {
        com = fromseg();
        com--;
        temp = fromseg();
        temp2 = temp>>4;

        if (temp2 > maxx)
            maxx = temp2;

        sampx[com] = temp2;
        temp &= 0x0f;

        if (temp > maxy)
            maxy = temp;

        sampy[com] = temp;
        temp = fromseg();
        qpoint[com] = &quantable[temp][0];
    }

    widthDU  = maxx*8;
    heightDU = maxy*8;
    colsDU   = (width-1)/widthDU + 1;
    cols8    = maxx*colsDU;
    linesize = (widthDU * colsDU + 2) * 2;
    dusize   = (uint32) (heightDU + 1) * linesize;
    coltab   = malloc(maxy * cols8);

    for (i=0; i<ch; i++) {
        buff[i] = malloc(dusize);
        repx[i] = maxx/sampx[i];
        repy[i] = maxy/sampy[i];
        addx[i] = repx[i] * 8 * 2;
        addy[i] = repy[i] * 8 * linesize;
    }

    //printf("Width %d, Height %d\n", width, height);
    //printf("Display unit is %dx%d\n", widthDU, heightDU);
    //printf("Size of display unit %ld\n", dusize);
}
Example #2
0
File: Ltp.cpp Project: rudaoshi/ltp
// integrate postagger into LTP
int LTP::postag(XML4NLP & xml) {
  if ( xml.QueryNote(NOTE_POS) ) {
    return 0;
  }

  // dependency
  int ret = wordseg(xml);
  if (0 != ret) {
    ERROR_LOG("in LTP::postag, failed to perform word segment preprocess");
    return ret;
  }

  void * postagger = _resource.GetPostagger();
  if (0 == postagger) {
    ERROR_LOG("in LTP::postag, failed to init a postagger");
    return kPostagError;
  }

  int stnsNum = xml.CountSentenceInDocument();

  if (0 == stnsNum) {
    ERROR_LOG("in LTP::postag, number of sentence equals 0");
    return kEmptyStringError;
  }

  for (int i = 0; i < stnsNum; ++i) {
    vector<string> vecWord;
    vector<string> vecPOS;

    xml.GetWordsFromSentence(vecWord, i);

    if (0 == vecWord.size()) {
      ERROR_LOG("Input sentence is empty.");
      return kEmptyStringError;
    }

    if (vecWord.size() > MAX_WORDS_NUM) {
      ERROR_LOG("Input sentence is too long.");
      return kSentenceTooLongError;
    }

    if (0 == postagger_postag(postagger, vecWord, vecPOS)) {
      ERROR_LOG("in LTP::postag, failed to perform postag on sent. #%d", i+1);
      return kPostagError;
    }

    if (xml.SetPOSsToSentence(vecPOS, i) != 0) {
      ERROR_LOG("in LTP::postag, failed to write postag result to xml");
      return kWriteXmlError;
    }
  }

  xml.SetNote(NOTE_POS);

  return 0;
}
Example #3
0
void segDRI() {
    ducount = restinv = wordseg();
}