{"action":"created","comment":{"url":"https://api.github.com/repos/ubtue/ub_tools/pulls/comments/69133799","id":69133799,"diff_hunk":"@@ -0,0 +1,225 @@\n+\n+/* We would like to have a tool that extracts translations for given\n+   authority data\n+   The german term is found in Field 150 \n+   Currently there are two different kinds of translations:\n+   TxTheo-Translations with the following definitions:\n+\n+   710: Körperschaft - fremdsprachige Äquivalenz        \n+   711: Konferenz - fremdsprachige Äquivalenz  \n+   700: Person - fremdsprachige Äquivalenz     \n+   730: Titel - fremdsprachige Äquivalenz      \n+   750: Sachbegriff - fremdsprachige Äquivalenz  \n+   751: Geografikum - fremdsprachige Äquivalenz    \n+\n+   LoC/Rameau Translations:\n+   \n+   700: Person - Bevorzugter Name in einem anderen Datenbestand\n+   710: Körperschaft - Bevorzugter Name in einem anderen Datenbestand              \n+   711: Konferenz - Bevorzugte Benennung in einem anderen Datenbestand\n+   730: Einheitstitel - Bevorzugter Name in einem anderen Datenbestand\n+   750: Sachbegriff - Bevorzugte Benennung in einem anderen Datenbestand\n+   751: Geografikum - Bevorzugter Name in einem anderen Datenbestand  \n+   \n+*/ \n+\n+\n+#include <iostream>\n+#include <vector>\n+#include <cstdlib>\n+#include \"Compiler.h\"\n+#include \"MarcUtil.h\"\n+#include \"MediaTypeUtil.h\"\n+#include \"StringUtil.h\"\n+#include \"Subfields.h\"\n+#include \"util.h\"\n+\n+// Languages to handle\n+//enum languages { \"en\",\"fr\" };\n+\n+const unsigned int NUMBER_OF_LANGUAGES = 2;\n+const std::string languages_to_create_str = \"en, fr\";\n+enum languages { en, fr };\n+\n+void Usage() {\n+    std::cerr << \"Usage: \" << ::progname << \" norm_data_marc_input extracted_translations\\n\";\n+    std::exit(EXIT_FAILURE);\n+}\n+\n+void augment_ixtheo_tag_with_language(const MarcUtil::Record &record, const std::string tag, std::vector<std::string> &translations) {\n+    auto ixtheo_pos = std::find(translations.begin(), translations.end(), \"IxTheo\");\n+    if (ixtheo_pos != translations.end()) {\n+        std::vector<std::string> ixtheo_lang_code;\n+        record.extractSubfields(tag, \"9\" , &ixtheo_lang_code);\n+        for (auto lang_code : ixtheo_lang_code) {\n+            if (lang_code.find(\"eng\") != std::string::npos && *ixtheo_pos != \"IxTheo_eng\")\n+               *ixtheo_pos = *ixtheo_pos + \"_eng\";\n+            // FIXME: There are currently no french translations... \n+            else if (lang_code.find(\"fra\") != std::string::npos && *ixtheo_pos != \"IxTheo_fra\")\n+               *ixtheo_pos = *ixtheo_pos + \"_fra\";\n+        }\n+    }\n+}\n+\n+\n+void ExtractTranslations(File* const marc_norm_input, \n+                         const std::string german_term_field_spec,\n+                         const std::string translation_field_spec,\n+                         std::map<std::string,std::string> term_to_translation_map[]) {\n+\n+    std::set<std::string> german_tags_and_subfield_codes;\n+    if (unlikely(StringUtil::Split(german_term_field_spec, ':', &german_tags_and_subfield_codes) < 1))\n+        Error(\"ExtractTranslations: Need at least one translation field\");\n+\n+    std::set<std::string> translation_tags_and_subfield_codes;\n+    if (unlikely(StringUtil::Split(translation_field_spec, ':', &translation_tags_and_subfield_codes) < 1))\n+        Error(\"ExtractTranslations: Need at least one translation field\");\n+\n+    unsigned count(0);\n+    \n+    while (const MarcUtil::Record record = MarcUtil::Record::XmlFactory(marc_norm_input)) {\n+\n+        std::vector<std::string> german_term;\n+\n+        // Determine the german term we will have translations for\n+\n+        for (auto tag_and_subfields : german_tags_and_subfield_codes) {\n+             const std::string tag(tag_and_subfields.substr(0, 3));\n+             const std::string subfields(tag_and_subfields.substr(3));\n+             \n+             std::vector<std::string> german_term_for_one_field;\n+             record.extractSubfields(tag, subfields, &german_term_for_one_field);\n+             \n+             // We may get the german term from only one field\n+             if (german_term.size() > 1)  \n+                 Warning(\"We have german terms in more than one field for PPN: \" + record.getFields()[0]);\n+\n+             if (not german_term_for_one_field.empty()) \n+                 german_term = german_term_for_one_field;\n+        }        \n+\n+        std::vector<std::string> all_translations;\n+\n+        // Extract all additional translations\n+\n+        for (auto tag_and_subfields : translation_tags_and_subfield_codes) {\n+            const std::string tag(tag_and_subfields.substr(0, 3));\n+            const std::string subfields(tag_and_subfields.substr(3));\n+\n+            std::vector<std::string> translations;\n+            record.extractSubfields(tag, subfields, &translations);\n+\n+            // For IxTheo-Translations add the language code in the same field\n+            augment_ixtheo_tag_with_language(record, tag, translations);\n+            \n+            all_translations.insert(std::end(all_translations), std::begin(translations), std::end(translations));\n+        }\n+ \n+        for (auto it = all_translations.begin(); it != all_translations.end(); it++) {\n+            if (*it == \"IxTheo_eng\") {\n+                term_to_translation_map[en].emplace(StringUtil::Join(german_term, ' '), *(it+1));\n+                ++it;\n+            }\n+            else if (*it == \"IxTheo_fra\") {\n+                term_to_translation_map[fr].emplace(StringUtil::Join(german_term, ' '), *(it+1));\n+                ++it;\n+            }\n+\n+            else if (*it == \"lcsh\") {\n+                term_to_translation_map[en].emplace(StringUtil::Join(german_term, ' '), *(it+1));\n+                ++it;\n+            }\n+            else if (*it == \"ram\") {\n+                term_to_translation_map[fr].emplace(StringUtil::Join(german_term, ' '), *(it+1));\n+                ++it;\n+            }\n+            \n+        }\n+       ","path":"cpp/extract_normdata_translations.cc","position":138,"original_position":138,"commit_id":"390d7c1bd8f1983568c990f24ae52c624a89b357","original_commit_id":"390d7c1bd8f1983568c990f24ae52c624a89b357","user":{"login":"ruschein","id":991243,"avatar_url":"https://avatars.githubusercontent.com/u/991243?v=3","gravatar_id":"","url":"https://api.github.com/users/ruschein","html_url":"https://github.com/ruschein","followers_url":"https://api.github.com/users/ruschein/followers","following_url":"https://api.github.com/users/ruschein/following{/other_user}","gists_url":"https://api.github.com/users/ruschein/gists{/gist_id}","starred_url":"https://api.github.com/users/ruschein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruschein/subscriptions","organizations_url":"https://api.github.com/users/ruschein/orgs","repos_url":"https://api.github.com/users/ruschein/repos","events_url":"https://api.github.com/users/ruschein/events{/privacy}","received_events_url":"https://api.github.com/users/ruschein/received_events","type":"User","site_admin":false},"body":"Redundant blank line.","created_at":"2016-06-30T13:43:02Z","updated_at":"2016-06-30T13:43:02Z","html_url":"https://github.com/ubtue/ub_tools/pull/436#discussion_r69133799","pull_request_url":"https://api.github.com/repos/ubtue/ub_tools/pulls/436","_links":{"self":{"href":"https://api.github.com/repos/ubtue/ub_tools/pulls/comments/69133799"},"html":{"href":"https://github.com/ubtue/ub_tools/pull/436#discussion_r69133799"},"pull_request":{"href":"https://api.github.com/repos/ubtue/ub_tools/pulls/436"}}},"pull_request":{"url":"https://api.github.com/repos/ubtue/ub_tools/pulls/436","id":75666403,"html_url":"https://github.com/ubtue/ub_tools/pull/436","diff_url":"https://github.com/ubtue/ub_tools/pull/436.diff","patch_url":"https://github.com/ubtue/ub_tools/pull/436.patch","issue_url":"https://api.github.com/repos/ubtue/ub_tools/issues/436","number":436,"state":"open","locked":false,"title":"Riedl","user":{"login":"jriedl","id":13135579,"avatar_url":"https://avatars.githubusercontent.com/u/13135579?v=3","gravatar_id":"","url":"https://api.github.com/users/jriedl","html_url":"https://github.com/jriedl","followers_url":"https://api.github.com/users/jriedl/followers","following_url":"https://api.github.com/users/jriedl/following{/other_user}","gists_url":"https://api.github.com/users/jriedl/gists{/gist_id}","starred_url":"https://api.github.com/users/jriedl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jriedl/subscriptions","organizations_url":"https://api.github.com/users/jriedl/orgs","repos_url":"https://api.github.com/users/jriedl/repos","events_url":"https://api.github.com/users/jriedl/events{/privacy}","received_events_url":"https://api.github.com/users/jriedl/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-29T15:11:40Z","updated_at":"2016-06-30T13:43:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e94859f7f1321b01ab56d7455d930f1889263928","assignee":{"login":"ruschein","id":991243,"avatar_url":"https://avatars.githubusercontent.com/u/991243?v=3","gravatar_id":"","url":"https://api.github.com/users/ruschein","html_url":"https://github.com/ruschein","followers_url":"https://api.github.com/users/ruschein/followers","following_url":"https://api.github.com/users/ruschein/following{/other_user}","gists_url":"https://api.github.com/users/ruschein/gists{/gist_id}","starred_url":"https://api.github.com/users/ruschein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruschein/subscriptions","organizations_url":"https://api.github.com/users/ruschein/orgs","repos_url":"https://api.github.com/users/ruschein/repos","events_url":"https://api.github.com/users/ruschein/events{/privacy}","received_events_url":"https://api.github.com/users/ruschein/received_events","type":"User","site_admin":false},"assignees":[{"login":"ruschein","id":991243,"avatar_url":"https://avatars.githubusercontent.com/u/991243?v=3","gravatar_id":"","url":"https://api.github.com/users/ruschein","html_url":"https://github.com/ruschein","followers_url":"https://api.github.com/users/ruschein/followers","following_url":"https://api.github.com/users/ruschein/following{/other_user}","gists_url":"https://api.github.com/users/ruschein/gists{/gist_id}","starred_url":"https://api.github.com/users/ruschein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruschein/subscriptions","organizations_url":"https://api.github.com/users/ruschein/orgs","repos_url":"https://api.github.com/users/ruschein/repos","events_url":"https://api.github.com/users/ruschein/events{/privacy}","received_events_url":"https://api.github.com/users/ruschein/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ubtue/ub_tools/pulls/436/commits","review_comments_url":"https://api.github.com/repos/ubtue/ub_tools/pulls/436/comments","review_comment_url":"https://api.github.com/repos/ubtue/ub_tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ubtue/ub_tools/issues/436/comments","statuses_url":"https://api.github.com/repos/ubtue/ub_tools/statuses/390d7c1bd8f1983568c990f24ae52c624a89b357","head":{"label":"ubtue:riedl","ref":"riedl","sha":"390d7c1bd8f1983568c990f24ae52c624a89b357","user":{"login":"ubtue","id":12495698,"avatar_url":"https://avatars.githubusercontent.com/u/12495698?v=3","gravatar_id":"","url":"https://api.github.com/users/ubtue","html_url":"https://github.com/ubtue","followers_url":"https://api.github.com/users/ubtue/followers","following_url":"https://api.github.com/users/ubtue/following{/other_user}","gists_url":"https://api.github.com/users/ubtue/gists{/gist_id}","starred_url":"https://api.github.com/users/ubtue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubtue/subscriptions","organizations_url":"https://api.github.com/users/ubtue/orgs","repos_url":"https://api.github.com/users/ubtue/repos","events_url":"https://api.github.com/users/ubtue/events{/privacy}","received_events_url":"https://api.github.com/users/ubtue/received_events","type":"Organization","site_admin":false},"repo":{"id":35827831,"name":"ub_tools","full_name":"ubtue/ub_tools","owner":{"login":"ubtue","id":12495698,"avatar_url":"https://avatars.githubusercontent.com/u/12495698?v=3","gravatar_id":"","url":"https://api.github.com/users/ubtue","html_url":"https://github.com/ubtue","followers_url":"https://api.github.com/users/ubtue/followers","following_url":"https://api.github.com/users/ubtue/following{/other_user}","gists_url":"https://api.github.com/users/ubtue/gists{/gist_id}","starred_url":"https://api.github.com/users/ubtue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubtue/subscriptions","organizations_url":"https://api.github.com/users/ubtue/orgs","repos_url":"https://api.github.com/users/ubtue/repos","events_url":"https://api.github.com/users/ubtue/events{/privacy}","received_events_url":"https://api.github.com/users/ubtue/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ubtue/ub_tools","description":"Various C++ utility programs typically relating to MARC 21 manipulation.","fork":false,"url":"https://api.github.com/repos/ubtue/ub_tools","forks_url":"https://api.github.com/repos/ubtue/ub_tools/forks","keys_url":"https://api.github.com/repos/ubtue/ub_tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubtue/ub_tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubtue/ub_tools/teams","hooks_url":"https://api.github.com/repos/ubtue/ub_tools/hooks","issue_events_url":"https://api.github.com/repos/ubtue/ub_tools/issues/events{/number}","events_url":"https://api.github.com/repos/ubtue/ub_tools/events","assignees_url":"https://api.github.com/repos/ubtue/ub_tools/assignees{/user}","branches_url":"https://api.github.com/repos/ubtue/ub_tools/branches{/branch}","tags_url":"https://api.github.com/repos/ubtue/ub_tools/tags","blobs_url":"https://api.github.com/repos/ubtue/ub_tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubtue/ub_tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubtue/ub_tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubtue/ub_tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubtue/ub_tools/statuses/{sha}","languages_url":"https://api.github.com/repos/ubtue/ub_tools/languages","stargazers_url":"https://api.github.com/repos/ubtue/ub_tools/stargazers","contributors_url":"https://api.github.com/repos/ubtue/ub_tools/contributors","subscribers_url":"https://api.github.com/repos/ubtue/ub_tools/subscribers","subscription_url":"https://api.github.com/repos/ubtue/ub_tools/subscription","commits_url":"https://api.github.com/repos/ubtue/ub_tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubtue/ub_tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubtue/ub_tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubtue/ub_tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubtue/ub_tools/contents/{+path}","compare_url":"https://api.github.com/repos/ubtue/ub_tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubtue/ub_tools/merges","archive_url":"https://api.github.com/repos/ubtue/ub_tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubtue/ub_tools/downloads","issues_url":"https://api.github.com/repos/ubtue/ub_tools/issues{/number}","pulls_url":"https://api.github.com/repos/ubtue/ub_tools/pulls{/number}","milestones_url":"https://api.github.com/repos/ubtue/ub_tools/milestones{/number}","notifications_url":"https://api.github.com/repos/ubtue/ub_tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubtue/ub_tools/labels{/name}","releases_url":"https://api.github.com/repos/ubtue/ub_tools/releases{/id}","deployments_url":"https://api.github.com/repos/ubtue/ub_tools/deployments","created_at":"2015-05-18T16:02:47Z","updated_at":"2016-01-11T08:51:29Z","pushed_at":"2016-06-29T15:53:23Z","git_url":"git://github.com/ubtue/ub_tools.git","ssh_url":"git@github.com:ubtue/ub_tools.git","clone_url":"https://github.com/ubtue/ub_tools.git","svn_url":"https://github.com/ubtue/ub_tools","homepage":null,"size":67041,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"ubtue:master","ref":"master","sha":"007b7e8d2a6b02d1f7bb5ab7d7e920a35b61cee0","user":{"login":"ubtue","id":12495698,"avatar_url":"https://avatars.githubusercontent.com/u/12495698?v=3","gravatar_id":"","url":"https://api.github.com/users/ubtue","html_url":"https://github.com/ubtue","followers_url":"https://api.github.com/users/ubtue/followers","following_url":"https://api.github.com/users/ubtue/following{/other_user}","gists_url":"https://api.github.com/users/ubtue/gists{/gist_id}","starred_url":"https://api.github.com/users/ubtue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubtue/subscriptions","organizations_url":"https://api.github.com/users/ubtue/orgs","repos_url":"https://api.github.com/users/ubtue/repos","events_url":"https://api.github.com/users/ubtue/events{/privacy}","received_events_url":"https://api.github.com/users/ubtue/received_events","type":"Organization","site_admin":false},"repo":{"id":35827831,"name":"ub_tools","full_name":"ubtue/ub_tools","owner":{"login":"ubtue","id":12495698,"avatar_url":"https://avatars.githubusercontent.com/u/12495698?v=3","gravatar_id":"","url":"https://api.github.com/users/ubtue","html_url":"https://github.com/ubtue","followers_url":"https://api.github.com/users/ubtue/followers","following_url":"https://api.github.com/users/ubtue/following{/other_user}","gists_url":"https://api.github.com/users/ubtue/gists{/gist_id}","starred_url":"https://api.github.com/users/ubtue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubtue/subscriptions","organizations_url":"https://api.github.com/users/ubtue/orgs","repos_url":"https://api.github.com/users/ubtue/repos","events_url":"https://api.github.com/users/ubtue/events{/privacy}","received_events_url":"https://api.github.com/users/ubtue/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ubtue/ub_tools","description":"Various C++ utility programs typically relating to MARC 21 manipulation.","fork":false,"url":"https://api.github.com/repos/ubtue/ub_tools","forks_url":"https://api.github.com/repos/ubtue/ub_tools/forks","keys_url":"https://api.github.com/repos/ubtue/ub_tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubtue/ub_tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubtue/ub_tools/teams","hooks_url":"https://api.github.com/repos/ubtue/ub_tools/hooks","issue_events_url":"https://api.github.com/repos/ubtue/ub_tools/issues/events{/number}","events_url":"https://api.github.com/repos/ubtue/ub_tools/events","assignees_url":"https://api.github.com/repos/ubtue/ub_tools/assignees{/user}","branches_url":"https://api.github.com/repos/ubtue/ub_tools/branches{/branch}","tags_url":"https://api.github.com/repos/ubtue/ub_tools/tags","blobs_url":"https://api.github.com/repos/ubtue/ub_tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubtue/ub_tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubtue/ub_tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubtue/ub_tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubtue/ub_tools/statuses/{sha}","languages_url":"https://api.github.com/repos/ubtue/ub_tools/languages","stargazers_url":"https://api.github.com/repos/ubtue/ub_tools/stargazers","contributors_url":"https://api.github.com/repos/ubtue/ub_tools/contributors","subscribers_url":"https://api.github.com/repos/ubtue/ub_tools/subscribers","subscription_url":"https://api.github.com/repos/ubtue/ub_tools/subscription","commits_url":"https://api.github.com/repos/ubtue/ub_tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubtue/ub_tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubtue/ub_tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubtue/ub_tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubtue/ub_tools/contents/{+path}","compare_url":"https://api.github.com/repos/ubtue/ub_tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubtue/ub_tools/merges","archive_url":"https://api.github.com/repos/ubtue/ub_tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubtue/ub_tools/downloads","issues_url":"https://api.github.com/repos/ubtue/ub_tools/issues{/number}","pulls_url":"https://api.github.com/repos/ubtue/ub_tools/pulls{/number}","milestones_url":"https://api.github.com/repos/ubtue/ub_tools/milestones{/number}","notifications_url":"https://api.github.com/repos/ubtue/ub_tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubtue/ub_tools/labels{/name}","releases_url":"https://api.github.com/repos/ubtue/ub_tools/releases{/id}","deployments_url":"https://api.github.com/repos/ubtue/ub_tools/deployments","created_at":"2015-05-18T16:02:47Z","updated_at":"2016-01-11T08:51:29Z","pushed_at":"2016-06-29T15:53:23Z","git_url":"git://github.com/ubtue/ub_tools.git","ssh_url":"git@github.com:ubtue/ub_tools.git","clone_url":"https://github.com/ubtue/ub_tools.git","svn_url":"https://github.com/ubtue/ub_tools","homepage":null,"size":67041,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ubtue/ub_tools/pulls/436"},"html":{"href":"https://github.com/ubtue/ub_tools/pull/436"},"issue":{"href":"https://api.github.com/repos/ubtue/ub_tools/issues/436"},"comments":{"href":"https://api.github.com/repos/ubtue/ub_tools/issues/436/comments"},"review_comments":{"href":"https://api.github.com/repos/ubtue/ub_tools/pulls/436/comments"},"review_comment":{"href":"https://api.github.com/repos/ubtue/ub_tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ubtue/ub_tools/pulls/436/commits"},"statuses":{"href":"https://api.github.com/repos/ubtue/ub_tools/statuses/390d7c1bd8f1983568c990f24ae52c624a89b357"}}}}
{"actor":{"display_login":"ruschein"}}