diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/geosteering-out.html b/geosteering-out.html new file mode 100644 index 0000000000000000000000000000000000000000..c978999aafc42d68e7cd8f5b0dea9102d8663b80 --- /dev/null +++ b/geosteering-out.html @@ -0,0 +1,66 @@ +\ecvitem{\highlight{Publications}}{Journal Articles} +<center> <table class="submit-table" id="deadlines"> + <tr> <td>Authors</td><td> Wilson A. </td></tr> + <tr> <td>Title</td><td> New Geosteering Work Flow Integrates Real-Time Measurements With Geomodels </td></tr> +<tr> <td>Source</td> <td> Journal of Petroleum Technology </td> </tr> +<tr> <td>Publication Date</td> <td> 2018 </td> </tr> +<tr> <td>URL</td> <td> <a href="https://www.spe.org/en/jpt/jpt-article-detail/?art=4530">https://www.spe.org/en/jpt/jpt-article-detail/?art=4530</a> </td> </tr> +</table> </center> + +<center> <table class="submit-table" id="deadlines"> + <tr> <td>Authors</td><td> Jakobsen M., and Tveit S. </td></tr> + <tr> <td>Title</td><td> Distorted Born iterative T-matrix method for inversion of CSEM data in anisotropic media </td></tr> +<tr> <td>Source</td> <td> Geophysical Journal International </td> </tr> +<tr> <td>Publication Date</td> <td> 2018 </td> </tr> +<tr> <td>URL</td> <td> <a href="http://dx.doi.org/10.1093/gji/ggy197">http://dx.doi.org/10.1093/gji/ggy197</a> </td> </tr> +</table> </center> + +\ecvitem{\highlight{Other publications}}{} +<center> <table class="submit-table" id="deadlines"> + <tr> <td>Authors</td><td> Sergey Alyaev, Erich Suter, Reidar Bratvold, Aojie Hong, and Xiaodong Luo </td></tr> + <tr> <td>Title</td><td> A Decision Support System for Multi-target Geosteering </td></tr> +<tr> <td>Source</td> <td> </td> </tr> +<tr> <td>Publication Date</td> <td> 2019 </td> </tr> +<tr> <td>URL</td> <td> <a href="https://arxiv.org/abs/1903.03933">https://arxiv.org/abs/1903.03933</a> </td> </tr> +</table> </center> + +<center> <table class="submit-table" id="deadlines"> + <tr> <td>Authors</td><td> Suter E., KÃ¥rstad T., Escalona A., A. Friis H., Vefring E., and Alyaev S. </td></tr> + <tr> <td>Title</td><td> A Methodology for Effective Earth Model Management while Geosteering </td></tr> +<tr> <td>Source</td> <td> Second EAGE/SPE Geosteering and Well Placement Workshop </td> </tr> +<tr> <td>Publication Date</td> <td> 2018 </td> </tr> +<tr> <td>URL</td> <td> <a href="http://dx.doi.org/10.3997/2214-4609.201803215">http://dx.doi.org/10.3997/2214-4609.201803215</a> </td> </tr> +</table> </center> + +<center> <table class="submit-table" id="deadlines"> + <tr> <td>Authors</td><td> Sommer M., and Jakobsen M. </td></tr> + <tr> <td>Title</td><td> Towards a Fast Integral Equation Method for Inversion of Electromagnetic Data </td></tr> +<tr> <td>Source</td> <td> Second EAGE/SPE Geosteering and Well Placement Workshop </td> </tr> +<tr> <td>Publication Date</td> <td> 2018 </td> </tr> +<tr> <td>URL</td> <td> <a href="http://dx.doi.org/10.3997/2214-4609.201803216">http://dx.doi.org/10.3997/2214-4609.201803216</a> </td> </tr> +</table> </center> + +<center> <table class="submit-table" id="deadlines"> + <tr> <td>Authors</td><td> Alyaev S., Bratvold R.B., Luo X., Suter E., Vefring E.H., and others </td></tr> + <tr> <td>Title</td><td> An Interactive Decision Support System for Geosteering Operations </td></tr> +<tr> <td>Source</td> <td> in SPE Norway One Day Seminar </td> </tr> +<tr> <td>Publication Date</td> <td> 2018 </td> </tr> +<tr> <td>URL</td> <td> <a href="http://dx.doi.org/10.2118/191337-MS">http://dx.doi.org/10.2118/191337-MS</a> </td> </tr> +</table> </center> + +<center> <table class="submit-table" id="deadlines"> + <tr> <td>Authors</td><td> Alyaev S., Suter E., Bratvold R., Vefring E., and Jahani N. </td></tr> + <tr> <td>Title</td><td> Ensemble-based decision-support workflow for operational geosteering </td></tr> +<tr> <td>Source</td> <td> Second EAGE/SPE Geosteering and Well Placement Workshop </td> </tr> +<tr> <td>Publication Date</td> <td> 2018 </td> </tr> +<tr> <td>URL</td> <td> <a href="http://dx.doi.org/10.3997/2214-4609.201803140">http://dx.doi.org/10.3997/2214-4609.201803140</a> </td> </tr> +</table> </center> + +<center> <table class="submit-table" id="deadlines"> + <tr> <td>Authors</td><td> Alyaev S., Hong A., and B Bratvold R. </td></tr> + <tr> <td>Title</td><td> Are you myopic, naive or farsighted about your geosteering decisions? </td></tr> +<tr> <td>Source</td> <td> Second EAGE/SPE Geosteering and Well Placement Workshop </td> </tr> +<tr> <td>Publication Date</td> <td> 2018 </td> </tr> +<tr> <td>URL</td> <td> <a href="http://dx.doi.org/10.3997/2214-4609.201803217">http://dx.doi.org/10.3997/2214-4609.201803217</a> </td> </tr> +</table> </center> + diff --git a/geosteering.bib b/geosteering.bib new file mode 100644 index 0000000000000000000000000000000000000000..aeb111fcf2a48fdaf8bfe6a2181656704abd9d3d --- /dev/null +++ b/geosteering.bib @@ -0,0 +1,71 @@ +@article{jakobsen2018distorted, + title={Distorted Born iterative T-matrix method for inversion of CSEM data in anisotropic media}, + author={Jakobsen, Morten and Tveit, Svenn}, + journal={Geophysical Journal International}, + volume={214}, + number={3}, + pages={1524--1537}, + year={2018}, + publisher={Oxford University Press}, + doi = {10.1093/gji/ggy197} +} +@article{wilson2018new, + title={New Geosteering Work Flow Integrates Real-Time Measurements With Geomodels}, + author={Wilson, Adam}, + journal={Journal of Petroleum Technology}, + volume={70}, + number={09}, + pages={102--105}, + year={2018}, + publisher={Society of Petroleum Engineers}, + url = {https://www.spe.org/en/jpt/jpt-article-detail/?art=4530} +} +@inproceedings{sommer2018eage, + title={Towards a Fast Integral Equation Method for Inversion of Electromagnetic Data}, + author={Sommer, M. and Jakobsen, M.}, + journal={Second EAGE/SPE Geosteering and Well Placement Workshop }, + year={2018}, + publisher={SPE, EAGE}, + doi = {10.3997/2214-4609.201803216} +} +@inproceedings{suter2018eage, + title={A Methodology for Effective Earth Model Management while Geosteering}, + author={Suter, E. and KÃ¥rstad, T. and Escalona, A. and A. Friis, H. and Vefring, E. and Alyaev, S.}, + journal={Second EAGE/SPE Geosteering and Well Placement Workshop }, + year={2018}, + publisher={SPE, EAGE}, + doi = {10.3997/2214-4609.201803215} +} +@inproceedings{alyaev2018eage, + title={Are you myopic, naive or farsighted about your geosteering decisions?}, + author={Alyaev, S. and Hong, A and B Bratvold, R.}, + journal={Second EAGE/SPE Geosteering and Well Placement Workshop }, + year={2018}, + publisher={SPE, EAGE}, + doi = {10.3997/2214-4609.201803217} +} +@inproceedings{alyaev2018eageposter, + title={Ensemble-based decision-support workflow for operational geosteering}, + author={Alyaev, S. and Suter, E and Bratvold, R. and Vefring, E. and Jahani, N.}, + journal={Second EAGE/SPE Geosteering and Well Placement Workshop }, + year={2018}, + publisher={SPE, EAGE}, + doi = {10.3997/2214-4609.201803140} +} +@misc{alyaev2019decision, + title={A Decision Support System for Multi-target Geosteering}, + author={Sergey Alyaev and Erich Suter and Reidar Bratvold and Aojie Hong and Xiaodong Luo}, + year={2019}, + eprint={1903.03933}, + archivePrefix={arXiv}, + primaryClass={cs.CE}, + url={https://arxiv.org/abs/1903.03933} +} +@inproceedings{alyaev2018interactive, + title={An Interactive Decision Support System for Geosteering Operations}, + author={Alyaev, Sergey and Bratvold, Reidar Brumer and Luo, Xiaodong and Suter, Erich and Vefring, Erlend H and others}, + booktitle={SPE Norway One Day Seminar}, + year={2018}, + organization={Society of Petroleum Engineers}, + doi={10.2118/191337-MS} +} diff --git a/parser.py b/parser.py new file mode 100644 index 0000000000000000000000000000000000000000..e1686117d7fa152ff983d78638dcf4f79d3abb96 --- /dev/null +++ b/parser.py @@ -0,0 +1,497 @@ +__author__ = 'Sergey Alyaev' + +"""Collect command-line options in a dictionary""" + + +def getopts(argv): + opts = {} # Empty dictionary to store key-value pairs. + while argv: # While there are arguments left to parse... + if argv[0][0] == '-': # Found a "-name value" pair. + opts[argv[0]] = argv[1] # Add key and value to the dictionary. + argv = argv[1:] # Reduce the argument list by copying it starting from index 1. + return opts + + + +class bibentry(object): + + #staic + label_to_abbrev = dict() + abbreviations = set() + + def __init__(self, entry_type, entry_label = None): + self.entry_type = entry_type + self.entry_label = entry_label + self.fields = dict() + self.abbr = None + + def __str__(self): + return self.entry_label + ":[" + self.entry_type + "]" + + def __repr__(self): + return self.__str__() + + def strip_author_name(self, author_name, abbreviate=True, ceparator_space=' '): + """ + Makes name to desired format + :param author_name: + :param abbreviate: + :return: + """ + if abbreviate: + name_parts = author_name.split(',') + out = name_parts[0].strip() + if len(name_parts)>1: + out += ceparator_space + name_parts = name_parts[1].split(' ') + for i in range(len(name_parts)): + if len(name_parts[i].strip())>0: + out += name_parts[i].strip()[0]+'.' + return out + else: + return author_name.strip() + + + + + def get_authors(self, max_authors=3, abbreviate=True, ceparator_space=' '): + """ + + :param max_authors: + :return: + """ + out = "" + if 'author' in self.fields: + authors = self.fields['author'].split(' and ') + total_len = len(authors) + if total_len <= 1: + out += self.strip_author_name(authors[0], abbreviate) + elif (total_len > max_authors+1): + for i in range(max_authors-1): + out += self.strip_author_name(authors[i], abbreviate)+", " + out += self.strip_author_name(authors[max_authors-1], abbreviate)+" et" + ceparator_space +"al." + else: + for i in range(total_len-1): + out += self.strip_author_name(authors[i], abbreviate)+", " + out += "and " + self.strip_author_name(authors[total_len-1], abbreviate) + else: + out = 'x' + return out + + + def get_year(self): + """ + + :return: + """ + out = '' + if 'year' in self.fields: + out += (self.fields['year'].strip()) + return out + + def get_title(self): + """ + + :return: + """ + out = '' + if 'title' in self.fields: + out += (self.fields['title'].strip()) + return out + + url_prefix = 'URL ' + doi_prefix = 'http://dx.doi.org/' + + def get_url_html(self, prefer_doi = True): + """ + + :return: + """ + out = '' + added = False + if 'url' in self.fields: + out = self.fields['url'] + added = True + if 'doi' in self.fields: + if (not added) or prefer_doi: + out = self.doi_prefix+self.fields['doi'] + return out + + def get_url(self, url_enviorment, prefer_doi = True): + """ + + :return: + """ + out = '' + added = False + if 'url' in self.fields: + out = self.url_prefix + url_enviorment+'{'+ self.fields['url']+'}' + added = True + if 'doi' in self.fields: + if (not added) or prefer_doi: + out = self.url_prefix + url_enviorment+'{'+self.doi_prefix+self.fields['doi'] +'}' + return out + + + def get_publisher(self, always_with_publisher=False): + """ + gets the publisher e.g. journal + :return: + """ + out = '' + if self.entry_type.lower().find('mastersthesis')>=0: + out += 'Master\'s thesis. ' + if 'school' in self.fields: + out += self.fields['school'] + elif self.entry_type.lower().find('phdthesis')>=0: + out += 'PhD thesis. ' + if 'school' in self.fields: + out += self.fields['school'] + elif self.entry_type.lower().find('techreport')>=0: + out += 'Technical report. ' + if 'institution' in self.fields: + out += self.fields['institution'] + elif 'journal' in self.fields: + if self.entry_type.lower() == 'unpublished': + out += "submitted to " + out += self.fields['journal'] + elif 'booktitle' in self.fields: + out += 'in '+ self.fields['booktitle'] + elif 'note' in self.fields: + out += self.fields['note'] + + if always_with_publisher or len(out)==0: + if 'publisher' in self.fields: + out += ' (' + self.fields['publisher']+')' + elif 'organization' in self.fields: + out += ' (' + self.fields['organization']+')' + #elif 'institution' in self.fields: + # out += ' (' + self.fields['institution']+')' + + if (len(out)>0): + return out + else: + return '' + + def get_abbreviation(self): + """ + :return abbreviation + """ + #TODO test for multiple of the same to work correctly + if self.label_to_abbrev.has_key(self.entry_label): + return self.label_to_abbrev[self.entry_label] + abbr = '' + if 'author' in self.fields: + authors = self.fields['author'].split(' and ') + for a in authors: + abbr += a[0] + else: + abbr = 'x' + if 'year' in self.fields: + abbr += self.fields['year'] + if abbr in self.abbreviations: + abbr += 'a' + while abbr in self.abbreviations: + abbr[len(abbr)] = chr(int(abbr[len(abbr)])+1) + self.label_to_abbrev[self.entry_label] = abbr + self.abbreviations.add(abbr) + return abbr + + + + + + +def find_first_outer_brackets(st): + """ + :param st: + :return: finds closing "{}" paranthesis non-matching + """ + opened = 0 + open_b = -1 + index = 0 + while index < len(st): + c = st[index] + if (c == '{'): + opened +=1 + if open_b == -1: + open_b = index + if (c == '}'): + opened -=1 + if opened == 0: + close_b = index + return open_b, close_b + if (c == '\\'): + index += 1 + if opened < 0: + print("Incorrect parenthesis in ", st) + return -1, -1 + index+=1 + print("No bracket pairs found ", st) + return -1, -1 + +def populate_entry(entry, st): + clean = st.strip() + comma_pos = clean.find(',') + entry.entry_label = clean[0:comma_pos] + while True: + clean = clean[comma_pos+1:].strip() + p_in, p_out = find_first_outer_brackets(clean) + if (p_in<0 or p_out<0): + break + eq_ind = clean.find('=', 0, p_in) + key = clean[0:eq_ind].strip() + value = clean[p_in+1:p_out].strip() + entry.fields[key] = value + comma_pos = clean.find(',', p_out) + if comma_pos < 0: + break + + +def check_person(entry, person): + """ + checks if the person is the author of the entry + :param entry: + :param person: + :return: + """ + if person == None: + return True + if 'author' in entry.fields: + if entry.fields['author'].find(person) >= 0: + return True + return False + + +def find_entries(st, person_name = None): + entries = [] + while True: + index = st.find('@') + if index==-1: + break + st = st[index:] + b_in, b_out = find_first_outer_brackets(st) + + #print(st[b_in+1:b_out ]) + entry = bibentry(st[1:b_in]) + populate_entry(entry, st[b_in+1:b_out]) + if check_person(entry, person_name): + entries.append(entry) + st = st[b_out+1:] + + return entries + + +def parse_bib_file(filename, person_name): + file = open(filename, 'r') + lines = file.readlines() + st = '' + for line in lines: + st += line + file.close() + return find_entries(st, person_name) + + +def get_sorting(entry): + """ + + :param entry: bib entry + :return: gets 'year' + """ + if 'year' in entry.fields: + if 'author' in entry.fields: + return entry.fields['year'], entry.fields['author'] + else: + return entry.fields['year'], "ZZZ" + else: + return '0000', "ZZZ" + +def get_year(entry): + """ + + :param entry: bib entry + :return: gets 'year' + """ + if 'year' in entry.fields: + return entry.fields['year'] + else: + return '0000' + + + + +# "\\providecommand{\\url}[1]{\\texttt{#1}}\n" \ +file_prefix = "\\providecommand{\\urlprefix}{URL }\n" +file_suffix = "\n" + +def entry_to_tex(entry): + """ + + :param entry: + :return: + """ + s ="<center> <table class=\"submit-table\" id=\"deadlines\"> \n " \ + "<tr> " \ + " <td>Authors</td>" \ + "<td> {0} </td>" \ + "</tr> \n " \ + "<tr> " \ + " <td>Title</td>" \ + "<td> {4} </td>" \ + "</tr> \n" \ + "<tr> " \ + " <td>Source</td> " \ + " <td> {1} </td> " \ + "</tr> \n" \ + "<tr> " \ + " <td>Publication Date</td> " \ + " <td> {2} </td> " \ + "</tr> \n" \ + "<tr> " \ + " <td>URL</td> " \ + " <td> <a href=\"{3}\">{3}</a> </td> " \ + "</tr> \n" \ + "</table> </center> \n \n".format(entry.get_authors(max_authors=100), + entry.get_publisher(False), + entry.get_year(), + entry.get_url_html(prefer_doi=True), + entry.get_title()) + # s = '\\paperecvitem{' + # s += "\\label{" + entry.entry_label + "}" + # s += entry.get_authors() + # s += " ("+entry.get_year()+")" + # s += "}" + # s += "{" + # s += "\\highlight{" + # s += entry.get_title() + # s += ",} " + # s += entry.get_publisher(False) +' ' + # s += entry.get_url(url_enviorment='\\url',prefer_doi=True) + # s += "}\n" + #+"}{"+"}" + return s + + +def default_entry_filter(entry): + """ + returns True + :param entry: + :return: + """ + return True + + +def compare_entry_filter_type(entry, type=''): + """ + + :param entry: + :param type: + :return: + """ + if entry.entry_type.lower() == type.lower(): + return True + return False + + +def write_file_default(file, entries, entry_filter=default_entry_filter, + prefix='', suffix='', written=set()): + """ + + :param filename: name of a file + :param entries: collection of bibentries + :return: returns set of written items + """ + + #check if there is at lest one entry + count = 0 + for entry in entries: + if entry_filter(entry) and (not entry in written): + count += 1 + if count == 0: + return written + + file.write(prefix) + #write entries + for entry in entries: + if entry_filter(entry) and (not entry in written): + file.write(entry_to_tex(entry)) + written.add(entry) + #write suffix + file.write(suffix) + + return written + + + + + +if __name__ == '__main__': + from sys import argv + + my_args = getopts(argv) + if '-f' in my_args: # Example usage. + filename = my_args['-f'] + print("Processing file: ", filename) + print(my_args) + else: + print("Usage ... -f filename -o output_file_name -p author_family_name") + exit() + + person_name = None + if '-p' in my_args: + person_name = my_args['-p'] + print("Filtering person: ", person_name) + + entries = parse_bib_file(filename, person_name) + sorted_entries = sorted(entries, key=get_sorting, reverse=True) + #sorted_entries contain all the input + for entry in sorted_entries: + print(entry) + + output_file_name = 'publications.tex' + if '-o' in my_args: + output_file_name = my_args['-o'] + print("Outputting to: ", output_file_name) + + + file = open(output_file_name, 'w') + #write prefix + + # file.write(file_prefix) + #writting out articles + def filter_articles(entry): + return compare_entry_filter_type(entry, type='article') + + + #initializing a set of written items + written = set() + + written = write_file_default(file, sorted_entries, + entry_filter=filter_articles, + prefix='\\ecvitem{\\highlight{Publications}}{Journal Articles}\n', + written=written) + + #writting out articles + def filter_exclude_reports(entry): + return not compare_entry_filter_type(entry, type='TechReport') + + write_file_default(file, sorted_entries, + entry_filter=filter_exclude_reports, + prefix='\\ecvitem{\\highlight{Other publications}}{}\n', + written=written) + + #writting out articles + def filter_reports(entry): + return compare_entry_filter_type(entry, type='TechReport') + + write_file_default(file, sorted_entries, + entry_filter=filter_reports, + prefix='\\ecvitem{\\highlight{Technical Reports}}{}\n', + written=written) + + + # file.write(file_suffix) + file.close() + + + diff --git a/run_parser.sh b/run_parser.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0d7ed5b8424f0dad187663cd0f5ea3f7efab9b3 --- /dev/null +++ b/run_parser.sh @@ -0,0 +1,3 @@ + +python parser.py -f fromScholar.bib -p Alyaev +python parser.py -f reports.bib -p Alyaev -o reports.tex \ No newline at end of file