Coder Social home page Coder Social logo

hashtags-3's Introduction

HashTags

Golang GoDoc Go Report Issues Size Tag License

Purpose

Sometimes one might want to search and find socalled #hashtags or @mentions in ones texts (in a broader sense) and store them for later retrieval. This package offers that facility. It provides the THashList class which can be used to parse texts for the occurance of both #hashtags and @mentions and store the hits in an internal list for later lookup; that list can be both, stored in a file and later read from a file.

Installation

You can use Go to install this package for you:

go get -u github.com/mwat56/hashtags

Usage

In principle for each #hashtag or @mention a list of IDs is maintained. These IDs can be any (string) data that identifies the text in which the #hashtag or @mention was found, e.g. a filename or some database record reference. The only condition is that it is unique as far as the program using this package is concerned.

Note that both #hashtag and @mention are stored lower-cased to allow for case-insensitive searches.

To get a THashList instance there's a simple way:

fName := "mytags.lst"
htl, err := hashtags.New(fName)
if nil != err {
    log.PrintF("Problem loading file '%s': %v", fName, err)
}
    // …
    // do something with the list
    // …
written, err := htl.Store()
if nil != err {
    log.PrintF("Problem writing file '%s': %v", fName, err)
}

The package provides a boolean variable called UseBinaryStorage which is true by default. It determines whether the data written by Store() and read by Load() use a plain text format (i.e. UseBinaryStorage := false) or a binary data. The advantage of the plain text format is that it can be inspected by any text related tool (like e.g. diff). The advantage of the binary format is that it is about three times as fast when loading/storing data and it uses a few bytes less than the text format. For this reasons it's used by default (i.e. UseBinaryStorage == true); during development of your own application using this package, however, you might want to change to text format for diagnostic purposes.

For more details please refer to the package documentation.

Licence

    Copyright © 2019 M.Watermann, 10247 Berlin, Germany
                    All rights reserved
                EMail : <[email protected]>

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 software 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.

You should have received a copy of the GNU General Public License along with this program. If not, see the GNU General Public License for details.

hashtags-3's People

Contributors

mwat56 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.