Example #1
0
static array<tree>
get_latex_author_datas (tree t) {
  int i, n=N(t);
  array<tree> r;
  tree u;
  tree author_data (APPLY, "\\author-data");
  tree author_name (CONCAT);
  for (i=0; i<=n; i++) {
    if (i<n) u= t[i];
    else u= concat();
    if (i==n || is_tuple (u, "\\and")) {
      if (N(author_name) > 1) {
        author_data << tree (APPLY, "\\author-name", author_name);
        author_name= tree (CONCAT);
      }
      if (N(author_data) > 1) {
        r << author_data;
        author_data= tree (APPLY, "\\author-data");
      }
    }
    else if (is_tuple (u, "\\thanks", 1))
      author_data << tree (APPLY, "\\author-misc", u[1]);
    else if (is_tuple (u, "\\tmaffiliation", 1) ||
             is_tuple (u, "\\tmfnaffiliation", 1))
      author_data << tree (APPLY, "\\author-affiliation", cltm (u[1]));
    else if (is_tuple (u, "\\tmmisc", 1))
      author_data << tree (APPLY, "\\author-misc", cltm (u[1]));
    else if (is_tuple (u, "\\tmnote", 1))
      author_data << tree (APPLY, "\\author-note", cltm (u[1]));
    else if (is_tuple (u, "\\tmemail", 1) ||
             is_tuple (u, "\\tmfnemail", 1))
      author_data << tree (APPLY, "\\author-email", cltm (u[1]));
    else if (is_tuple (u, "\\tmhomepage", 1) ||
             is_tuple (u, "\\tmfnhomepage", 1))
      author_data << tree (APPLY, "\\author-homepage", cltm (u[1]));
    else
      author_name << u;
  }
  return r;
}
Example #2
0
static array<tree>
get_springer_author_datas (tree t, string s, bool llncs=false) {
  s= "\\author-" * s;
  int i, n=N(t);
  bool line_break= true;
  array<tree> r;
  tree u;
  tree author_data (APPLY, "\\author-data");
  tree author_name (CONCAT);
  for (i=0; i<n; i++) {
    u= t[i];
    if (is_tuple (u, "\\and")) {
      line_break= false;
      if (N(author_name) > 1) {
        tree tmp= concat();
        for (int j=0; j<N(author_name); j++)
          if (j+1 < N(author_name) || !is_line_break (author_name[j]))
            tmp << author_name[j];
        if (N(tmp) > 1)
          author_data << tree (APPLY, s, tmp);
        author_name= tree (CONCAT);
      }
      if (N(author_data) > 1) {
        r << author_data;
        author_data= tree (APPLY, "\\author-data");
      }
      line_break= true;
    }
    else if (is_springer_titlenote (u))
      author_data << tree (APPLY, "\\author-note", u[1]);
    else if (llncs && is_tuple (u, "\\inst", 1))
      author_data << tree (APPLY, "\\author-inst", string_arg (u[1]));
    else if (is_tuple (u, "\\email", 1))
      author_data << tree (APPLY, "\\author-email", u[1]);
    else if (is_tuple (u, "\\tmhomepage", 1))
      author_data << tree (APPLY, "\\author-homepage", u[1]);
    else if (is_tuple (u, "\\tmmisc", 1))
      author_data << tree (APPLY, "\\author-misc", u[1]);
    else if (!line_break || !is_line_break (u)) {
      if (!line_break || (u != " " && u != concat (" ") && u != concat ()))
        author_name << u;
      if (is_line_break (u)) line_break= true;
      else if (u != " " && u != concat (" ") && u != concat ())
        line_break= false;
    }
  }

  if (N(author_name) > 1) {
    tree tmp= concat();
    for (int j=0; j<N(author_name); j++)
      if (j+1 < N(author_name) || !is_line_break (author_name[j]))
        tmp << author_name[j];
    if (N(tmp) > 1)
      author_data << tree (APPLY, s, tmp);
    author_name= tree (CONCAT);
  }
  if (N(author_data) > 1) {
    r << author_data;
    author_data= tree (APPLY, "\\author-data");
  }
  return r;
}
Example #3
0
static array<tree>
get_acm_author_datas (tree t) {
  int i, n=N(t);
  bool line_break= true;
  array<tree> r;
  tree u;
  tree author_data (APPLY, "\\author-data");
  tree author_name (CONCAT);
  for (i=0; i<n; i++) {
    u= t[i];
    if (is_tuple (u, "\\alignauthor")) {
      line_break= false;
      if (N(author_name) > 1) {
        tree tmp= concat();
        for (int j=0; j<N(author_name); j++)
          if (j+1 < N(author_name) || !is_line_break (author_name[j]))
            tmp << author_name[j];
        if (N(tmp) > 1)
          author_data << tree (APPLY, "\\author-name", tmp);
        author_name= tree (CONCAT);
      }
      if (N(author_data) > 1) {
        r << author_data;
        author_data= tree (APPLY, "\\author-data");
      }
      line_break= true;
    }
    else if (is_acm_titlenote (u))
      author_data << tree (APPLY, "\\author-note", u[1]);
    else if (is_tuple (u, "\\affaddr", 1))
      author_data << tree (APPLY, "\\author-affiliation", u[1]);
    else if (is_tuple (u, "\\email", 1))
      author_data << tree (APPLY, "\\author-email", u[1]);
    else if (is_tuple (u, "\\tmacmhomepage", 1))
      author_data << tree (APPLY, "\\author-homepage", u[1]);
    else if (is_tuple (u, "\\tmacmmisc", 1))
      author_data << tree (APPLY, "\\author-misc", u[1]);
    else if (!line_break || !is_line_break (u)) {
      if (!line_break || (u != " " && u != concat (" ") && u != concat ()))
        author_name << u;
      if (is_line_break (u)) line_break= true;
      else if (u != " " && u != concat (" ") && u != concat ())
        line_break= false;
    }
  }

  if (N(author_name) > 1) {
    tree tmp= concat();
    for (int j=0; j<N(author_name); j++)
      if (j+1 < N(author_name) || !is_line_break (author_name[j]))
        tmp << author_name[j];
    if (N(tmp) > 1)
      author_data << tree (APPLY, "\\author-name", tmp);
    author_name= tree (CONCAT);
  }
  if (N(author_data) > 1) {
    r << author_data;
    author_data= tree (APPLY, "\\author-data");
  }
  return r;
}
Example #4
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;
}