def __init__(self):
     self.zh_pattern = re.compile("[\u4e00-\u9fff]+")
     self.en_pattern = re.compile("[a-zA-Z]+")
     self.fr_pattern = re.compile("[a-zA-ZÀ-ÿ]")
     self.parser = nltk.CoreNLPParser()
     self.java_keywords = set([w.strip('*') for w in """
     abstract    continue    for     new     switch
     assert   default     goto*   package     synchronized
     boolean     do  if  private     this
     break   double  implements  protected   throw
     byte    else    import  public  throws
     case    enum****    instanceof  return  transient
     catch   extends     int     short   try
     char    final   interface   static  void
     class   finally     long    strictfp**  volatile
     const*  float   native  super   while
     """.split()])
     self.customized_stop_words = set(
         "druid version alibaba add update pull copyright "
         "select where when where count over branch "
         "alter todo merge request johnhuang cn master fixed bug canal"
         "马云 什么 现在 急着 直接 指点 可能 时候 "
         "如果 这边 怎么 那些 这些 有助于 好像 没啥 干脆 "
         "因此 可以 是否 哪里 可否 最近 貌似 很多 出现 这个"
         " 但是 还没 这时候 出现 大佬 解答 一下 假设 并且 "
         "一直 但是 郁闷 希望 尽快 没有 由于 学生 来说 有点 "
         "哈哈哈 温绍 周五 下午 写道 一个啥 问题 求助 信息么"
         " 想法 感谢 自己 判断 为什么 义乌 是的 怎么了"
         " 为什么 之后 就是 别人 看到 的话 谢谢 关于 今天"
         " 发现 问题 请问 一旦 这时 能否 大家 快呀 请教 如何"
         " 期待 支持 变得 诡异 起来 使用 导致 比如 一般 需要  "
         "原来 可是 并不 这样 尊敬 大师 您好 学习者 目前 如何"
         " 避免 合并 作者 在一起 这样 一些 其他 很多 绝大部分"
         " 来源于 下面 给做 里面 估计 玩意 误导 我了 不应该 奇怪"
         " 所有 真是 秒回啊 然后 无可 理喻 想问 什么样 另外 帮忙"
         " 看下 看看 以便 然而 求教 各位 如下 以前 为啥 这么 "
         "有影响 林夕 还是 时不时 于是 仍然 十分 想要 以上 不知道 "
         "不需要 上午 不了 孙健 个人 认为 对于 比如说 然后 之前 "
         "因为 后来 温少 此时 感觉 名字 好酷 中文 翻译 德鲁伊 "
         "听到 感觉 里面 英雄 德鲁伊 哈哈 不过 应该 因为 炉石 传说 "
         "里面 难道 因为 项目 创始人 非常 喜欢 卡牌 职业 表示 非常 "
         "好奇 得到 官方 回复 当时 老板 喜欢 名字 好吧 因为 开源 "
         "项目 如此 非常 抽出 宝贵 时间 回答 含量 或者是 像是 一些 怎么办 非常 已经 而非 不然".split())
 def __init__(self):
     self.parser = nltk.CoreNLPParser(url="http://localhost:9000")
Esempio n. 3
0
            clean_tweets.append(tweet)
    return clean_tweets


def strip_html_tags(tweets):
    for tweet in tweets:
        tweet.trim_tags()


if __name__ == "__main__":

    sys.stdout = codecs.getwriter('utf8')(sys.stdout)
    sys.stderr = codecs.getwriter('utf8')(sys.stderr)

    # Validate that Stanford Core NLP Server is Running
    parser = nltk.CoreNLPParser(url="http://localhost:9000", tagtype="pos")

    # Positive and negative word lexicon from:
    #
    # Minqing Hu and Bing Liu.
    # "Mining and Summarizing Customer Reviews." Proceedings of the ACM SIGKDD International Conference
    #   on Knowledge Discovery and Data Mining(KDD - 2004), Aug 22 - 25, 2004, Seattle, Washington, USA,

    pos_words = open("opinion-lexicon-English/positive-words.txt",
                     'r').readlines()
    neg_words = open("opinion-lexicon-English/negative-words.txt",
                     'r').readlines()

    for i, word in enumerate(pos_words):
        pos_words[i] = word.replace('\r\n', '')
 def post_tag_word(word):
     tagger = nltk.CoreNLPParser('http://localhost:9003', tagtype='pos')
     post_tag = tagger.tag([word])
     tag = post_tag[0][1]
     return tag
 def complete_tagger(self,
                     text,
                     tags='tokenize,ssplit,pos,lemma,ner,depparse,coref'):
     self.tagger = nltk.CoreNLPParser(url='http://localhost:9003')
     self.tagger.parser_annotator = tags
     return self.tagger.api_call(text)
 def __init__(self):
     self.tagger = nltk.CoreNLPParser('http://localhost:9003',
                                      tagtype='pos')
Esempio n. 7
0
    return ' '.join(cleantext.split())


def cleantext(text):
    result = text + "\n"
    while text != result:
        text = result
        result.replace("\n\n", "\n")
        result.replace("\t", " ")
        result.replace("  ", " ")
    return result


with open("/local/fever-common/data/cswiki-20200520-pages-articles.xml") as file, \
        open("wiki-pages/wiki-001.jsonl", "w") as out:
    st = nltk.CoreNLPParser()
    for line in file:
        if not reading and is_article_beginning(line):
            article, reading = line, True
        elif reading and is_article_ending(line):
            try:
                et = xmltodict.parse(article + "</text></revision></page>")
                sentences = sent_tokenize(
                    cleanhtml(
                        e.wiki2text(et["page"]["revision"]["text"]["#text"])),
                    "czech")
                sentences = [
                    " ".join(word_tokenize(sentence, language="czech"))
                    for sentence in sentences
                ]
Esempio n. 8
0
import nltk
import spacy
from nltk.stem.snowball import SnowballStemmer
from textblob import TextBlob
from sklearn.feature_extraction.text import TfidfVectorizer, TfidfTransformer
import numpy as np
import re
import sys, io
import ranking
import copy
from fuzzywuzzy import fuzz
import answer_wh

parse = nltk.CoreNLPParser(url="http://localhost:9090")
wh_words = set(
    ['why', 'which', 'whose', 'who', 'whom', 'where', 'when', 'what', 'how'])

#change to large?
en_nlp = spacy.load('en_core_web_sm')

parse = nltk.CoreNLPParser(url="http://localhost:9000")
wh_words = set(
    ['why', 'which', 'whose', 'who', 'whom', 'where', 'when', 'what', 'how'])


#input: a list of sentences
#return: a list of nltk trees, with root node removed
def get_nlp_tree(sentences):
    lst = []
    for s in sentences:
        s_parse_tree = parse.raw_parse(s)
Esempio n. 9
0
 def __init__(self):
     self.parser = nltk.CoreNLPParser(url="http://localhost:9000")
     self.svaError = 0
     self.verbError = 0
     return
Esempio n. 10
0
 def __init__(self):
     self.parser = nltk.CoreNLPParser(url="http://localhost:9000")
     #self.depParser = nltk.CoreNLPDependencyParser(url="http://localhost:9000")
     return;