# Path: coolisf/shallow.py
# class Analyser(object):
# 
#     def __init__(self, lang=None):
#         self.lang = lang  # use ISO 639-2 three-letter codes
# 
#     def tokenize(self, text):
#         return text.split()
# 
#     def lemmatize(self, words):
#         return words
# 
#     def pos_tag(self, words):
#         # everything is a noun
#         return [(w, 'n') for w in words]
# 
#     def analyse(self, text):
#         tsent = ttl.Sentence(text)
#         words = self.tokenize(text)
#         tsent.import_tokens(words)
#         for tk, lm in zip(tsent, self.lemmatize(words)):
#             tk.lemma = lm
#         for tk, pos in zip(tsent, [pos for w, pos in self.pos_tag(words)]):
#             tk.pos = pos
#         return tsent
# 
# class EnglishAnalyser(Analyser):
# 
#     wnl = WordNetLemmatizer()
# 
#     def __init__(self):
#         super().__init__(lang="eng")
# 
#     def tokenize(self, sent):
#         return nltk.word_tokenize(sent)
# 
#     def pos2wnpos(self, pos):
#         if pos:
#             p = pos[0].lower()
#             if p == 'j':
#                 return 'a'
#             if p in 'svarn':
#                 return p
#         return 'n'  # default is a noun
# 
#     def lemmatize(self, words):
#         return [self.wnl.lemmatize(w, pos=self.pos2wnpos(p)) for w, p in self.pos_tag(words)]
# 
#     def pos_tag(self, words):
#         return nltk.pos_tag(words)
# 
#     def analyse(self, text):
#         tsent = ttl.Sentence(text)
#         words = self.tokenize(text)
#         tsent.import_tokens(words)
#         for tk, pos in zip(tsent, [pos for w, pos in self.pos_tag(words)]):
#             tk.pos = pos
#             tk.lemma = self.wnl.lemmatize(tk.text, pos=self.pos2wnpos(pos))
#         return tsent
# 
# class JapaneseAnalyser(Analyser):
# 
#     def __init__(self):
#         super().__init__(lang="jpn")
# 
#     def tokenize(self, sent):
#         return deko_tokenize(sent)
# 
#     def lemmatize(self, words):
#         msent = txt2mecab(' '.join(words))
#         return [m.root for m in msent if not m.is_eos]
# 
#     def pos_tag(self, words):
#         msent = txt2mecab(' '.join(words))
#         return [(m.surface, m.pos3()) for m in msent]
# 
#     def analyse(self, sent):
#         msent = txt2mecab(sent)
#         return msent.to_ttl()


import unittest
import logging
from lelesk import LeLeskWSD, LeskCache
from coolisf.shallow import Analyser, EnglishAnalyser, JapaneseAnalyser
        lemmas = a.lemmatize(words)
        tags = a.pos_tag(words)
        tsent = a.analyse(txt)
        self.assertEqual(words, ['Some', 'dogs', 'barked.'])
        self.assertEqual(lemmas, ['Some', 'dogs', 'barked.'])
        self.assertEqual(tags, [('Some', 'n'), ('dogs', 'n'), ('barked.', 'n')])
        twords = [t.text for t in tsent]
        self.assertEqual(twords, ['Some', 'dogs', 'barked.'])
        for t in tsent:
            self.assertEqual(t.text, txt[t.cfrom:t.cto])

    def test_eng(self):
        a = EnglishAnalyser()
        txt = 'Some dogs barked.'
        words = a.tokenize(txt)
        lemmas = a.lemmatize(words)
        tags = a.pos_tag(words)
        tsent = a.analyse(txt)
        self.assertEqual(words, ['Some', 'dogs', 'barked', '.'])
        self.assertEqual(lemmas, ['Some', 'dog', 'bark', '.'])
        self.assertEqual(tags, [('Some', 'DT'), ('dogs', 'NNS'), ('barked', 'VBD'), ('.', '.')])
        twords = [t.text for t in tsent]
        self.assertEqual(twords, ['Some', 'dogs', 'barked', '.'])
        for tk, lm, tg in zip(tsent, lemmas, tags):
            self.assertEqual(tk.text, txt[tk.cfrom:tk.cto])
            self.assertEqual(tk.lemma, lm)
            self.assertEqual(tk.pos, tg[1])

    def test_wsd_shallow(self):
        txt = 'The dogs barked.'

# Path: coolisf/shallow.py
# class Analyser(object):
# 
#     def __init__(self, lang=None):
#         self.lang = lang  # use ISO 639-2 three-letter codes
# 
#     def tokenize(self, text):
#         return text.split()
# 
#     def lemmatize(self, words):
#         return words
# 
#     def pos_tag(self, words):
#         # everything is a noun
#         return [(w, 'n') for w in words]
# 
#     def analyse(self, text):
#         tsent = ttl.Sentence(text)
#         words = self.tokenize(text)
#         tsent.import_tokens(words)
#         for tk, lm in zip(tsent, self.lemmatize(words)):
#             tk.lemma = lm
#         for tk, pos in zip(tsent, [pos for w, pos in self.pos_tag(words)]):
#             tk.pos = pos
#         return tsent
# 
# class EnglishAnalyser(Analyser):
# 
#     wnl = WordNetLemmatizer()
# 
#     def __init__(self):
#         super().__init__(lang="eng")
# 
#     def tokenize(self, sent):
#         return nltk.word_tokenize(sent)
# 
#     def pos2wnpos(self, pos):
#         if pos:
#             p = pos[0].lower()
#             if p == 'j':
#                 return 'a'
#             if p in 'svarn':
#                 return p
#         return 'n'  # default is a noun
# 
#     def lemmatize(self, words):
#         return [self.wnl.lemmatize(w, pos=self.pos2wnpos(p)) for w, p in self.pos_tag(words)]
# 
#     def pos_tag(self, words):
#         return nltk.pos_tag(words)
# 
#     def analyse(self, text):
#         tsent = ttl.Sentence(text)
#         words = self.tokenize(text)
#         tsent.import_tokens(words)
#         for tk, pos in zip(tsent, [pos for w, pos in self.pos_tag(words)]):
#             tk.pos = pos
#             tk.lemma = self.wnl.lemmatize(tk.text, pos=self.pos2wnpos(pos))
#         return tsent
# 
# class JapaneseAnalyser(Analyser):
# 
#     def __init__(self):
#         super().__init__(lang="jpn")
# 
#     def tokenize(self, sent):
#         return deko_tokenize(sent)
# 
#     def lemmatize(self, words):
#         msent = txt2mecab(' '.join(words))
#         return [m.root for m in msent if not m.is_eos]
# 
#     def pos_tag(self, words):
#         msent = txt2mecab(' '.join(words))
#         return [(m.surface, m.pos3()) for m in msent]
# 
#     def analyse(self, sent):
#         msent = txt2mecab(sent)
#         return msent.to_ttl()


# Path: test/test_shallow.py
import unittest
import logging
from lelesk import LeLeskWSD, LeskCache
from coolisf.shallow import Analyser, EnglishAnalyser, JapaneseAnalyser

        lemmas = a.lemmatize(words)
        tags = a.pos_tag(words)
        tsent = a.analyse(txt)
        self.assertEqual(words, ['Some', 'dogs', 'barked.'])
        self.assertEqual(lemmas, ['Some', 'dogs', 'barked.'])
        self.assertEqual(tags, [('Some', 'n'), ('dogs', 'n'), ('barked.', 'n')])
        twords = [t.text for t in tsent]
        self.assertEqual(twords, ['Some', 'dogs', 'barked.'])
        for t in tsent:
            self.assertEqual(t.text, txt[t.cfrom:t.cto])

    def test_eng(self):
        a = EnglishAnalyser()
        txt = 'Some dogs barked.'
        words = a.tokenize(txt)
        lemmas = a.lemmatize(words)
        tags = a.pos_tag(words)
        tsent = a.analyse(txt)
        self.assertEqual(words, ['Some', 'dogs', 'barked', '.'])
        self.assertEqual(lemmas, ['Some', 'dog', 'bark', '.'])
        self.assertEqual(tags, [('Some', 'DT'), ('dogs', 'NNS'), ('barked', 'VBD'), ('.', '.')])
        twords = [t.text for t in tsent]
        self.assertEqual(twords, ['Some', 'dogs', 'barked', '.'])
        for tk, lm, tg in zip(tsent, lemmas, tags):
            self.assertEqual(tk.text, txt[tk.cfrom:tk.cto])
            self.assertEqual(tk.lemma, lm)
            self.assertEqual(tk.pos, tg[1])

    def test_wsd_shallow(self):
        txt = 'The dogs barked.'

        a = EnglishAnalyser()