示例#1
0
array<tree>
collect_metadata_latex (tree t, array<tree>(*get_author_datas)(tree)) {
  array<tree> r;
  tree doc_data (APPLY, "\\doc-data");
  tree abstract_data (APPLY, "\\abstract-data");
  array<tree> doc_notes;
  bool dated= false, maketitle= false;
  int i, n=N(t);
  for (i=0; i<n; i++) {
    tree u= t[i];
    if (is_tuple (u, "\\maketitle")) maketitle= true;
    else if (is_tuple (u, "\\title", 1)  || is_tuple (u, "\\title*", 2)) {
      get_latex_title_notes (u[N(u)-1], doc_notes);
      doc_data << tuple ("\\doc-title", cltm (u[N(u)-1]));
    }
    else if (is_tuple (u, "\\author", 1)  || is_tuple (u, "\\author*", 2)) {
      array<tree> author_datas= (*get_author_datas) (u[1]);
      for (int j=0; j<N(author_datas); j++)
        doc_data << tree (APPLY, "\\doc-author", author_datas[j]);
    }
    else if (is_tuple (u, "\\date", 1)) {
      dated= true;
      get_latex_title_notes (u[1], doc_notes);
      doc_data << tuple ("\\doc-date", cltm (u[1]));
    }
    else if (is_tuple (u, "\\begin-abstract")) {
      tree abstract_text (CONCAT);
      i++;
      while (i<n && !is_tuple (t[i], "\\end-abstract"))
        abstract_text << t[i++];
      abstract_data << tree (APPLY, "\\abstract", abstract_text);
    }
    else if (is_tuple (u, "\\tmkeywords") || is_tuple (u, "\\tmmsc")  ||
             is_tuple (u, "\\tmacm")      || is_tuple (u, "\\tmpacs") ||
             is_tuple (u, "\\tmarxiv"))
      abstract_data << collect_abstract_data (u);
  }
  if (!dated && maketitle)
    doc_data << tuple ("\\doc-date", tree (APPLY, "\\date", ""));
  if (N(doc_notes) > 0) doc_data << doc_notes;
  if (N(doc_data) > 1) {
    r << doc_data;
    r << concat ("\n");
  }
  if (N(abstract_data) > 1) {
    r << abstract_data;
    r << concat ("\n");
  }
  return r;
}
示例#2
0
tree
collect_metadata_springer (tree t, bool llncs) {
  int i, n=N(t);
  tree u, r (CONCAT);
  tree doc_data (APPLY, "\\doc-data");
  tree abstract_data (APPLY, "\\abstract-data");
  array<tree> doc_notes, author_datas, author_affs;
  for (i=0; i<n; i++) {
    u= t[i];
    if (is_tuple (u, "\\dedication", 1))
      doc_notes << tree (APPLY, "\\doc-note", concat ("Dedication: ", u[1]));
    else if (is_tuple (u, "\\date", 1))
      doc_data << tree (APPLY, "\\doc-date", u[1]);
    else if (is_tuple (u, "\\title", 1)) {
      get_springer_title_notes (u[1], doc_notes);
      doc_data << tree (APPLY, "\\doc-title", cstm (u[1]));
    }
    else if (is_tuple (u, "\\subtitle", 1)) {
      get_springer_title_notes (u[1], doc_notes);
      doc_data << tree (APPLY, "\\doc-subtitle", cstm (u[1]));
    }
    else if (is_tuple (u, "\\author", 1))
      author_datas << get_springer_author_datas (u[1], "name", llncs);
    else if (!llncs && is_tuple (u, "\\institute", 1))
      author_affs << get_springer_affiliation_datas (u[1]);
    else if (llncs && is_tuple (u, "\\institute", 1))
      author_affs << get_llncs_affiliation_datas (u[1]);
    else if (is_tuple (u, "\\begin-abstract")) {
      tree abstract_text (CONCAT);
      i++;
      while (i<n && !is_tuple (t[i], "\\end-abstract")) {
        u= t[i];
        if (is_tuple (u, "\\keywords", 1))
          translate_springer_abstract_data (u, "keywords", abstract_data);
        else if (is_tuple (u, "\\tmmsc") || is_tuple (u, "\\tmarxiv") ||
                 is_tuple (u, "\\tmacm") || is_tuple (u, "\\tmpacs"))
          abstract_data << collect_abstract_data (u);
        else
          abstract_text << u;
        i++;
      }
      abstract_data << tree (APPLY, "\\abstract", abstract_text);
    }
    else if (is_tuple (u, "\\keywords", 1))
      translate_springer_abstract_data (u, "keywords", abstract_data);
    else if (is_tuple (u, "\\subclass", 1))
      translate_springer_abstract_data (u, "msc", abstract_data);
    else if (is_tuple (u, "\\PACS", 1))
      translate_springer_abstract_data (u, "pacs", abstract_data);
    else if (is_tuple (u, "\\CRclass", 1))
      translate_springer_abstract_data (u, "acm", abstract_data);
    else if (is_tuple (u, "\\tmarxiv"))
      abstract_data << collect_abstract_data (u);
  }
  bool spaced= false;
  if (llncs) {
    author_datas= merge_llncs_author_datas (author_datas, author_affs);
  }
  else {
    author_datas << author_affs;
    author_datas= filter_spaces (author_datas, spaced);
    author_datas= merge_springer_author_datas (author_datas);
  }
  for (int j=0; j<N(author_datas); j++)
    author_datas[j]= tree (APPLY, "\\doc-author", author_datas[j]);
  if (N(author_datas) > 0) doc_data << author_datas;
  if (N(doc_notes) > 0) doc_data << doc_notes;
  if (N(doc_data) > 1) r << doc_data << "\n";
  if (N(abstract_data) > 1) r << abstract_data << "\n";
  return r;
}
示例#3
0
tree
collect_metadata_acm (tree t) {
  int i, n=N(t);
  tree u, r (CONCAT);
  tree doc_data (APPLY, "\\doc-data");
  tree abstract_data (APPLY, "\\abstract-data");
  array<tree> doc_notes;
  for (i=0; i<n; i++) {
    u= t[i];
    if (is_tuple (u, "\\date", 1))
      doc_data << tree (APPLY, "\\doc-date", u[1]);
    else if (is_tuple (u, "\\title", 1))
      doc_data << tree (APPLY, "\\doc-title", u[1]);
    else if (is_tuple (u, "\\title*", 2)) {
      doc_data << tree (APPLY, "\\doc-running-title", u[1]);
      doc_data << tree (APPLY, "\\doc-title", u[2]);
    }
    else if (is_tuple (u, "\\subtitle", 1))
      doc_data << tree (APPLY, "\\doc-subtitle", u[1]);
    else if (is_tuple (u, "\\titlenote", 1))
      doc_data << tree (APPLY, "\\doc-note", u[1]);
    else if (is_tuple (u, "\\subtitlenote", 1))
      doc_data << tree (APPLY, "\\doc-note", u[1]);
    else if (is_tuple (u, "\\author", 1)) {
      array<tree> authors;
      while (i<n && is_tuple (t[i], "\\author", 1))
        authors << t[i++][1];
      array<tree> author_datas;
      while (i<n) {
        if (is_tuple (t[i], "\\affiliation", 1)) {
          tree aff= get_acm_affiliation (t[i++][1]);
          author_datas << tree (APPLY, "\\author-affiliation", aff);
        }
        else if (is_tuple (t[i], "\\orcid", 1))
          i++;
        else if (is_tuple (t[i], "\\authornote", 1))
          author_datas << tree (APPLY, "\\author-note", t[i++][1]);
        else if (is_tuple (t[i], "\\email", 1))
          author_datas << tree (APPLY, "\\author-email", t[i++][1]);
        else if (t[i] == "" || t[i] == " ")
          i++;
        else break;
      }
      for (int j=0; j<N(authors); j++) {
        tree author_data (APPLY, "\\author-data");
        author_data << tree (APPLY, "\\author-name", authors[j]);
        author_data << author_datas;
        doc_data << tree (APPLY, "\\doc-author", author_data);
      }
      i--;
    }
    else if (is_tuple (u, "\\begin-abstract")) {
      tree abstract_text (CONCAT);
      i++;
      while (i<n && !is_tuple (t[i], "\\end-abstract"))
        abstract_text << t[i++];
      abstract_data << tree (APPLY, "\\abstract", abstract_text);
    }
    else if (is_tuple (u, "\\begin-keywords")) {
      tree keywords (CONCAT);
      i++;
      while (i<n && !is_tuple (t[i], "\\end-keywords"))
        keywords << t[i++];
      array<tree> tmp= tokenize_concat (keywords, A(concat (",", ";",
              tree (TUPLE, "\\tmsep"), tree (TUPLE, "\\tmSep"))));
      if (N(tmp) > 0) {
        tree kw= tree (APPLY, "\\abstract-keywords");
        kw << tmp;
        abstract_data << kw;
      }
    }
    else if (is_tuple (u, "\\tmmsc")  || is_tuple (u, "\\tmarxiv") ||
             is_tuple (u, "\\tmpacs"))
      abstract_data << collect_abstract_data (u);
    else if (is_tuple (u, "\\keywords", 1) || is_tuple (u, "\\terms", 1)) {
      array<tree> tmp= tokenize_concat (u[N(u)-1], A(concat (",", ";",
              tree (TUPLE, "\\tmsep"), tree (TUPLE, "\\tmSep"))));
      if (N(tmp) > 0) {
        tree kw= tree (APPLY, "\\abstract-keywords");
        kw << tmp;
        abstract_data << kw;
      }
    }
    else if (is_tuple (u, "\\category") || is_tuple (u, "\\category*")) {
      tree tmp (APPLY, "\\abstract-acm");
      for (int j=1; j<N(u); j++) tmp << u[j];
      abstract_data << tmp;
    }
  }
  if (N(doc_notes) > 0) doc_data << doc_notes;
  if (N(doc_data) > 1) r << doc_data << "\n";
  if (N(abstract_data) > 1) r << abstract_data << "\n";
  return r;
}
示例#4
0
tree
collect_metadata_acm_old (tree t) {
  int i, n=N(t);
  tree u, r (CONCAT);
  tree doc_data (APPLY, "\\doc-data");
  tree abstract_data (APPLY, "\\abstract-data");
  array<tree> doc_notes;
  for (i=0; i<n; i++) {
    u= t[i];
    if (is_tuple (u, "\\date", 1))
      doc_data << tree (APPLY, "\\doc-date", u[1]);
    else if (is_tuple (u, "\\title", 1)) {
      get_acm_title_notes (u[1], doc_notes);
      doc_data << tree (APPLY, "\\doc-title", catm (u[1]));
    }
    else if (is_tuple (u, "\\subtitle", 1)) {
      get_acm_title_notes (u[1], doc_notes);
      doc_data << tree (APPLY, "\\doc-subtitle", catm (u[1]));
    }
    else if (is_tuple (u, "\\author", 1)) {
      array<tree> author_datas= get_acm_author_datas (u[1]);
      for (int j=0; j<N(author_datas); j++)
        doc_data << tree (APPLY, "\\doc-author", author_datas[j]);
    }
    else if (is_tuple (u, "\\additionalauthors", 1)) {
      doc_data << tree (APPLY, "\\doc-author",
                             tree (APPLY, "\\author-data",
                                        tree (APPLY, "\\author-name", u[1])));
    }
    else if (is_tuple (u, "\\begin-abstract")) {
      tree abstract_text (CONCAT);
      i++;
      while (i<n && !is_tuple (t[i], "\\end-abstract"))
        abstract_text << t[i++];
      abstract_data << tree (APPLY, "\\abstract", abstract_text);
    }
    else if (is_tuple (u, "\\begin-keywords")) {
      tree keywords (CONCAT);
      i++;
      while (i<n && !is_tuple (t[i], "\\end-keywords"))
        keywords << t[i++];
      array<tree> tmp= tokenize_concat (keywords, A(concat (",", ";",
              tree (TUPLE, "\\tmsep"), tree (TUPLE, "\\tmSep"))));
      if (N(tmp) > 0) {
        tree kw= tree (APPLY, "\\abstract-keywords");
        kw << tmp;
        abstract_data << kw;
      }
    }
    else if (is_tuple (u, "\\tmmsc")  || is_tuple (u, "\\tmarxiv") ||
             is_tuple (u, "\\tmpacs"))
      abstract_data << collect_abstract_data (u);
    else if (is_tuple (u, "\\keywords", 1) || is_tuple (u, "\\terms", 1)) {
      array<tree> tmp= tokenize_concat (u[N(u)-1], A(concat (",", ";",
              tree (TUPLE, "\\tmsep"), tree (TUPLE, "\\tmSep"))));
      if (N(tmp) > 0) {
        tree kw= tree (APPLY, "\\abstract-keywords");
        kw << tmp;
        abstract_data << kw;
      }
    }
    else if (is_tuple (u, "\\category") || is_tuple (u, "\\category*")) {
      tree tmp (APPLY, "\\abstract-acm");
      for (int j=1; j<N(u); j++) tmp << u[j];
      abstract_data << tmp;
    }
  }
  if (N(doc_notes) > 0) doc_data << doc_notes;
  if (N(doc_data) > 1) r << doc_data << "\n";
  if (N(abstract_data) > 1) r << abstract_data << "\n";
  return r;
}