#
# <one line to give the library's name and an idea of what it does.>
# Copyright (C) 2015  <copyright holder> <email>
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# 
#

import mergerinterface

class PlwnMappingInterface(mergerinterface.MergerInterface):
  def __init__(self, bg, str_name):
    super(PlwnMappingInterface, self).__init__(str_name, bg)
    self.TOKEN_SYNSET_PROP = 'sense:ukb:syns_id'
  
  def get_sense_for_token(self, token):
    """!
    For a given token returns synset identifier. If the token dont have
    informatoion about disambiguated synset returns None value.

    @para token: corpus2.Token
    @return Synset identifier or None if identifier do not exists
    """
    token_md = token.get_metadata()
    if not token_md:
      return None
    sense_md = token_md.get_attribute(self.TOKEN_SYNSET_PROP)
    return int(sense_md) if sense_md else None