Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ai.bareun.tagger:bareun

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai.bareun.tagger:bareun

Java client for bareun

  • 1.4.3
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

bareun

What is this?

bareun is the java library for bareun.

Bareun is a Korean NLP, which provides tokenizing, POS tagging for Korean.

How to get bareun server

  • Go to https://ai.bareun.protos/.
    • With registration, for the first time, you can get a free license for 3 months.
    • If you are a student or a researcher, you can get also a free license for 1 year, which is able to renew after 1 year.
  • Or use docker image.
docker pull bareunai/bareun:latest

How to use

package ai.bareun.test;

import static org.junit.Assert.assertTrue;

import java.nio.file.Path;
import java.util.List;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;

import ai.bareun.tagger.*;
import groovy.ui.Console;
import ai.bareun.protos.AnalyzeSyntaxRequest;
import ai.bareun.protos.AnalyzeSyntaxResponse;
import ai.bareun.protos.CustomDictionary;
import ai.bareun.protos.CustomDictionaryMeta;
import ai.bareun.protos.Document;
import ai.bareun.protos.LanguageServiceGrpc;

/**
 * Unit test for simple App.
 */
public class AppTest 
{
    private static Logger logger = LoggerFactory.getLogger(AppTest.class.getSimpleName());

    void log(Object str){
       
        if( str instanceof String ) {
            logger.info(str.toString());
        }  else {
            Gson gson = new Gson();
            logger.info(gson.toJson(str));
        }
  
    }
    /**
     * Rigorous Test :-)
     */
    @Test
    public void shouldAnswerWithTrue()
    {

        LanguageServiceClient conn = new ai.bareun.tagger.LanguageServiceClient("localhost","api-key");
        AnalyzeSyntaxResponse response =  conn.analyze_syntax("아버지가 방에 들어가신다.");
        String str = conn.toJson();
        assertTrue( !str.isEmpty() );
        logger.info(str);
    }

    static String TestString = "아버지가 방에 들어가신다.";
    // "윤석열 대통령이 취임 220일차인 오는 15일 대국민 소통의 일환으로 ‘국정과제 점검회의’를 진행한다.\n 취임 후 처음 국민과 대면해 생방송으로 대화를 나눈다는 점에서 취지에 걸맞는 소통이 얼마나 이뤄질지 관심이다.";


    @Test
    public void pos() {
        Tagged tag = new Tagger("localhost","api-key").tag(TestString);
        
        List<?> ret;
        Boolean flatten = true, join = true, detail = true;
        ret = tag.pos(flatten, join, detail);
        assertTrue(!ret.isEmpty());
        log(String.format("flatten = %B, join = %B, detail = %B", flatten , join , detail));
        log(ret);


        flatten = true;
        join = true;
        detail = false;
        ret = tag.pos(flatten, join, detail);
        assertTrue(!ret.isEmpty());
        log(String.format("flatten = %B, join = %B, detail = %B", flatten , join , detail));
        log(ret);

        flatten = true;
        join = false;
        detail = true;
        ret = tag.pos(flatten, join, detail);
        assertTrue(!ret.isEmpty());
        log(String.format("flatten = %B, join = %B, detail = %B", flatten , join , detail));
        log(ret);


        flatten = false;
        join = true;
        detail = true;
        ret = tag.pos(flatten, join, detail);
        assertTrue(!ret.isEmpty());
        log(String.format("flatten = %B, join = %B, detail = %B", flatten , join , detail));
        log(ret);

        flatten = false;
        join = false;
        detail = true;
        ret = tag.pos(flatten, join, detail);
        assertTrue(!ret.isEmpty());
        log(String.format("flatten = %B, join = %B, detail = %B", flatten , join , detail));
        log(ret);
    }

    
    @Test
    public void morphs() {
        Tagged tag = new Tagger("localhost","api-key").tag(TestString);

        List<String> ret = tag.morphs();
        assertTrue(!ret.isEmpty());
        log("morphs()");
        log(ret);

        ret = tag.nouns();
        assertTrue(!ret.isEmpty());
        log("nouns()");
        log(ret);

        ret = tag.verbs();
        assertTrue(!ret.isEmpty());
        log("verbs()");
        log(ret);
    }

    @Test
    public void testCustomDict() {
        CustomDict dict = new CustomDict("game", "localhost","api-key");

        log("testCustomDict()");
        log("read file.");

        String curdir = System.getProperty("user.dir");
        Path path = Path.of( curdir, "testdict.txt");
        if( dict.read_np_set_from_file(path.toString()) <= 0 ) {
            log("file io error : " + path.toString());
            return ;
        }
        log(dict.getSet("np_set"));

        Boolean r = dict.update();
        assertTrue(r);

        dict.load();
        log("update and load.");
        log(dict.getSet("np_set"));

        log("get list ");
        List<CustomDictionaryMeta> list = dict.get_list();
        for(CustomDictionaryMeta meta: list) {
            log(meta.getDomainName());
        }
        
    }

    static public void main() {
        AppTest theApp = new AppTest();
        theApp.shouldAnswerWithTrue();
        theApp.pos();
        theApp.morphs();
        theApp.testCustomDict();
    }
}
    

License

BSD 3-Clause License

FAQs

Package last updated on 04 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc