예제 #1
0
 def output_sense_translation(self, lang, foreign, english, disambiguation):
     if 'Wik' in foreign or 'Wik' in english:
         return
     if lang == 'zh-cn':
         lang = 'zh_CN'
     elif lang == 'zh-tw':
         lang = 'zh_TW'
     source = make_concept_uri(unicodedata.normalize('NFKC', foreign), lang)
     target = make_concept_uri(english, 'en', disambiguation)
     relation = '/r/TranslationOf'
     try:
         surfaceRel = "is %s for" % (langs.english_name(lang))
     except KeyError:
         surfaceRel = "is [language %s] for" % lang
     surfaceText = "[[%s]] %s [[%s (%s)]]" % (
         foreign, surfaceRel, english,
         disambiguation.split('/')[-1].replace('_', ' '))
     print surfaceText
     edge = make_edge(relation,
                      source,
                      target,
                      '/d/wiktionary/en/%s' % lang,
                      license='/l/CC/By-SA',
                      sources=[SOURCE, TRANSLATE],
                      context='/ctx/all',
                      weight=1.5,
                      surfaceText=surfaceText)
     self.writer.write(edge)
예제 #2
0
 def output_sense_translation(self, lang, foreign, german, disambiguation):
     if 'Wik' in foreign or 'Wik' in german:
         return
     if lang == 'zh-cn':
         lang = 'zh_CN'
     elif lang == 'zh-tw':
         lang = 'zh_TW'
     source = make_concept_uri(
       unicodedata.normalize('NFKC', foreign), lang
     )
     target = make_concept_uri(
       german, 'de', disambiguation
     )
     relation = '/r/TranslationOf'
     try:
         surfaceRel = "is %s for" % (langs.english_name(lang))
     except KeyError:
         surfaceRel = "is [language %s] for" % lang
     surfaceText = "[[%s]] %s [[%s (%s)]]" % (foreign, surfaceRel, english, disambiguation.split('/')[-1].replace('_', ' '))
     #print surfaceText
     edge = make_edge(relation, source, target, '/d/wiktionary/en/%s' % lang,
                      license='/l/CC/By-SA',
                      sources=[SOURCE, TRANSLATE],
                      context='/ctx/all',
                      weight=1.5,
                      surfaceText=surfaceText)
     self.writer.write(edge)
예제 #3
0
 def output_sense_translation(self, lang, foreign, translated, disambiguation):
     if u':' in foreign or u':' in translated:
         return
     if lang == 'zh-cn':
         lang = 'zh_CN'
     elif lang == 'zh-tw':
         lang = 'zh_TW'
     source = make_concept_uri_safe(
       unicodedata.normalize('NFKC', foreign), lang
     )
     target = make_concept_uri_safe(
       translated, self.langcode, disambiguation
     )
     relation = '/r/TranslationOf'
     try:
         surfaceRel = "is %s for" % (langs.english_name(lang))
     except KeyError:
         surfaceRel = "is [language %s] for" % lang
     if disambiguation and '/' in disambiguation:
         surfaceText = "[[%s]] %s [[%s (%s)]]" % (foreign, surfaceRel, translated, disambiguation.split('/')[-1].replace('_', ' '))
     else:
         surfaceText = "[[%s]] %s [[%s]]" % (foreign, surfaceRel, translated)
     #print surfaceText
     edge = make_edge(relation, source, target, '/d/wiktionary/ja/%s' % (self.langcode),
                      license='/l/CC/By-SA',
                      sources=[SOURCE, TRANSLATE],
                      context='/ctx/all',
                      weight=1.0,
                      surfaceText=surfaceText)
     self.writer.write(edge)
예제 #4
0
 def output_sense_translation(self, lang, foreign, german, disambiguation):
     if "Wik" in foreign or "Wik" in german:
         return
     if lang == "zh-cn":
         lang = "zh_CN"
     elif lang == "zh-tw":
         lang = "zh_TW"
     source = make_concept_uri(unicodedata.normalize("NFKC", foreign), lang)
     target = make_concept_uri(german, "de", disambiguation)
     relation = "/r/TranslationOf"
     try:
         surfaceRel = "is %s for" % (langs.english_name(lang))
     except KeyError:
         surfaceRel = "is [language %s] for" % lang
     surfaceText = "[[%s]] %s [[%s (%s)]]" % (
         foreign,
         surfaceRel,
         english,
         disambiguation.split("/")[-1].replace("_", " "),
     )
     # print surfaceText
     edge = make_edge(
         relation,
         source,
         target,
         "/d/wiktionary/en/%s" % lang,
         license="/l/CC/By-SA",
         sources=[SOURCE, TRANSLATE],
         context="/ctx/all",
         weight=1.5,
         surfaceText=surfaceText,
     )
     self.writer.write(edge)
예제 #5
0
 def output_translation(self, foreign, english, locale=''):
     source = make_concept_uri(unicodedata.normalize('NFKC', foreign),
                               self.langcode + locale)
     target = make_concept_uri(english, 'en')
     relation = '/r/TranslationOf'
     try:
         surfaceRel = "is %s for" % (langs.english_name(self.langcode))
     except KeyError:
         surfaceRel = "is [language %s] for" % self.langcode
     surfaceText = "[[%s]] %s [[%s]]" % (foreign, surfaceRel, english)
     edge = make_edge(relation,
                      source,
                      target,
                      '/d/wiktionary/en/%s' % self.langcode,
                      license='/l/CC/By-SA',
                      sources=[SOURCE, INTERLINGUAL],
                      context='/ctx/all',
                      weight=1.5,
                      surfaceText=surfaceText)
     self.writer.write(edge)
예제 #6
0
 def output_translation(self, foreign, english, locale=''):
     source = make_concept_uri(
       unicodedata.normalize('NFKC', foreign),
       self.langcode+locale
     )
     target = make_concept_uri(
       english, 'en'
     )
     relation = '/r/TranslationOf'
     try:
         surfaceRel = "is %s for" % (langs.english_name(self.langcode))
     except KeyError:
         surfaceRel = "is [language %s] for" % self.langcode
     surfaceText = "[[%s]] %s [[%s]]" % (foreign, surfaceRel, english)
     edge = make_edge(relation, source, target, '/d/wiktionary/en/%s' % self.langcode,
                      license='/l/CC/By-SA',
                      sources=[SOURCE, INTERLINGUAL],
                      context='/ctx/all',
                      weight=1.5,
                      surfaceText=surfaceText)
     self.writer.write(edge)