frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

09-TextProcessing-WordSegment-Case

1•zhousg•6h ago
This article introduces how to use @kit.NaturalLanguageKit in HarmonyOS for text word segmentation and implement a simple sentiment analysis function. By creating a TextProcessingWordSegment component, users can input evaluation text, click a button to perform sentiment analysis, and finally display the sentiment tendency (positive, negative, or neutral) of the evaluation.

import { textProcessing } from '@kit.NaturalLanguageKit';

@Entry @Component struct TextProcessingWordSegment { @State comment: string = 'The logistics is fast, the packaging is good, and I am particularly satisfied with the product'; @State label: string = ''

  build() { 
    Column({ space: 20 }) { 
      TextArea({ text: this.comment }) 
        .height(200) 
      Text('Evaluation Nature: ' + this.label) 
      Button('Sentiment Analysis') 
        .onClick(async () => { 
          const results = await textProcessing.getWordSegment(this.comment) 
          const words = results.map(item => item.word) 
          const service = new SentimentAnalysisService() 
          this.label = service.analyze(words) 
        }) 
    } 
    .padding(15) 
    .height('100%') 
    .width('100%') 
  } 
}

// Sentiment Analysis Service Class class SentimentAnalysisService { private positiveWords = ['good', 'satisfied', 'great', 'excellent', 'fast']; private negativeWords = ['bad', 'slow', 'expensive', 'awful', 'unsatisfied'];

  analyze(words: string[]) { 
    let score = 0.5; 
    words.forEach(word => { 
      if (this.positiveWords.includes(word)) { 
        score += 0.1; 
      } 
      if (this.negativeWords.includes(word)) { 
        score -= 0.1; 
      } 
    }); 
    score = Math.max(0, Math.min(1, score)); 
    const label = score > 0.6 ? 'Positive' : score < 0.4 ? 'Negative' : 'Neutral'; 
    return label; 
  } 
}

The State of Search in the AI Era with Don MacKinnon [audio]

https://www.thecloudgambit.com/2236725/episodes/17341364-the-state-of-search-in-the-ai-era-with-don-mackinnon
1•mooreds•1m ago•0 comments

Developing an Internal Tool for Our Puzzle Editor

https://open.nytimes.com/developing-an-internal-tool-for-our-puzzle-editor-d5dc7a9a6464
1•japrozs•2m ago•0 comments

Detection of cancers three years prior to diagnosis using plasma cell-free DNA

https://aacrjournals.org/cancerdiscovery/article-abstract/doi/10.1158/2159-8290.CD-25-0375/762609/Detection-of-cancers-three-years-prior-to
2•ahlCVA•2m ago•1 comments

Toady is a Python CLI tool that simplifies GitHub pull request reviews

https://github.com/tonyblank/toady-cli
1•mooreds•2m ago•0 comments

Introducing: KitchenEDU

https://www.thefoodcorridor.com/blog/introducing-kitchenedu/
1•mooreds•3m ago•0 comments

'AI is not doing its job and should leave us alone' says Gartner's top analyst

https://www.theregister.com/2025/06/17/ai_not_doing_its_job/
1•rntn•5m ago•0 comments

Kneading Dough Is Chaotic

https://www.youtube.com/watch?v=Tsg5RdjJ1OY&list=TLPQMTYwNjIwMjXUVmX8aBpJ0A
1•ash_grimnebulin•5m ago•0 comments

Ask HN: In a guide to inner work for founders and engs, what topics to cover?

1•cjbarber•5m ago•0 comments

Why it costs India so little to reach the Moon and Mars

https://www.bbc.com/news/articles/cn9xlgnnpzvo
2•andsoitis•5m ago•0 comments

Language Models in Plato's Cave

https://sergeylevine.substack.com/p/language-models-in-platos-cave
1•julianh65•5m ago•0 comments

Animal Crossing for the GameCube has been decompiled

https://gbatemp.net/threads/animal-crossing-for-the-gamecube-has-been-decompiled.672373/
1•OuterVale•5m ago•0 comments

Visual History of the Latin Alphabet

https://uclab.fh-potsdam.de/arete/en
1•speckx•6m ago•0 comments

The Best For the Most for the Least

https://www.theparisreview.org/blog/2017/06/14/the-best-for-the-most-for-the-least/
1•bookofjoe•6m ago•0 comments

Bioinformatics CLI like agrep running on GPU in the language mojo

https://github.com/BioRadOpenSource/ish
1•cariaso•6m ago•1 comments

Oxford Street to be pedestrianised as quick as possible, London Mayor says

https://www.bbc.co.uk/news/articles/cy5e555g5qro
1•v5v3•7m ago•0 comments

Adobe made a mobile app for its Firefly generative AI tools

https://www.theverge.com/news/688080/adobe-firefly-ai-app-iphone-ios-android-availability
1•thm•7m ago•0 comments

Many of Dead Sea scrolls may be older than thought

https://www.theguardian.com/science/2025/jun/04/many-of-dead-sea-scrolls-may-be-older-that-thought-experts-say
1•gmays•7m ago•0 comments

Tongue Move – Instant Brain Reset [video]

https://www.youtube.com/shorts/2iV1vntgnKI
1•keepamovin•7m ago•0 comments

Please add an option to block or disable "AI" · Issue #740 · codecov/feedback

https://github.com/codecov/feedback/issues/740
3•cratermoon•8m ago•0 comments

Google's Advanced Protection Arrives on Android: Should You Use It?

https://www.eff.org/deeplinks/2025/06/googles-advanced-protection-arrives-android-should-you-use-it
2•leephillips•9m ago•0 comments

Fartcoin Bucks Market Trend, Jumps 12% on Coinbase Listing Plan

https://www.coindesk.com/markets/2025/06/06/fartcoin-bucks-market-trend-jumps-12-on-coinbase-listing-plan
2•PaulHoule•9m ago•0 comments

"This guy's arrogance takes your breath away" (J W Backus and E W Dijkstra 1979)

https://medium.com/@acidflask/this-guys-arrogance-takes-your-breath-away-5b903624ca5f
2•antiquark•11m ago•0 comments

Equal Salaries for Remote Workers: What Is Equal, Anyway?

https://eidel.io/equal-salaries-for-remote-workers-what-is-equal-anyway/
1•olieidel•12m ago•0 comments

Radio 4 Longwave will NOT go quiet at the end of June, BBC suggests

https://keeplongwave.co.uk/2025/06/16/radio-4-longwave-will-not-go-quiet-at-the-end-of-june-bbc-suggests/
1•austinallegro•14m ago•0 comments

Show HN: LlamaBot – Turn any Rails app into an autonomous AI agent in 2 minutes

https://github.com/KodyKendall/llama_bot_rails
1•kody_06•16m ago•1 comments

Scaling On-Device GPU Inference for Large Generative Models

https://arxiv.org/abs/2505.00232
1•Anon84•16m ago•0 comments

NASA data reveals dramatic rise in intensity of weather events

https://www.theguardian.com/world/2025/jun/17/nasa-data-reveals-dramatic-rise-in-intensity-of-weather-events
3•andsoitis•18m ago•0 comments

Planetary waves linked to wild summer weather have tripled since 1950

https://apnews.com/article/extreme-weather-climate-change-heatwave-flooding-drought-cc4c3d93e178b6f4ab13cb7788998801
3•cratermoon•18m ago•0 comments

Noir is a language for private and verifiable computing

https://noir-lang.org/
1•sigalor•19m ago•0 comments

Sub-Second Postgres to Iceberg Mirroring

https://github.com/Mooncake-Labs/moonlink
1•rywalker•20m ago•0 comments