public int getNumberOfSentences() { return this.sentences().size(); }
public int getNumberOfSentences() { return this.sentences().size(); }
public Sentence getSentence(int sentenceId) { return this.sentences().get(sentenceId); }
public Sentence getSentence(int sentenceId) { return this.sentences().get(sentenceId); }
@Override public int hashCode() { int hashCode = this.corpusId.hashCode() * 13 + this.id.hashCode() * 17 + this.text.hashCode() * 19 + (tokens == null ? 0 : Arrays.hashCode(tokens) * 43) + (this.sentences().hashCode() * 31); hashCode += (this.attributes == null ? 0 : this.attributes.hashCode() * 13); return hashCode; }
@Override public int hashCode() { int hashCode = this.corpusId.hashCode() * 13 + this.id.hashCode() * 17 + this.text.hashCode() * 19 + (tokens == null ? 0 : Arrays.hashCode(tokens) * 43) + (this.sentences().hashCode() * 31); hashCode += (this.attributes == null ? 0 : this.attributes.hashCode() * 13); return hashCode; }
public static List<String> getSentenceList(TextAnnotation ta) { List<String> sentencesList = new ArrayList<>(); for (Sentence sentence : ta.sentences()) { String sentenceString = sentence.getTokenizedText().trim(); sentencesList.add(sentenceString); } return sentencesList; }
public static List<String> getSentenceList(TextAnnotation ta) { List<String> sentencesList = new ArrayList<>(); for (Sentence sentence : ta.sentences()) { String sentenceString = sentence.getTokenizedText().trim(); sentencesList.add(sentenceString); } return sentencesList; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof TextAnnotation)) return false; TextAnnotation that = (TextAnnotation) obj; if (!this.corpusId.equals(that.corpusId) || !this.id.equals(that.id) || !this.text.equals(that.text)) return false; if (this.attributes == null && that.attributes != null) return false; if (this.attributes != null && that.attributes == null) return false; if (this.attributes != null && !this.attributes.equals(that.attributes)) return false; if (this.tokens == null && that.tokens == null) return true; else if (this.tokens == null) return false; else if (that.tokens == null) return false; if (this.tokens.length != that.tokens.length) return false; for (int i = 0; i < this.tokens.length; i++) { if (!this.tokens[i].equals(that.tokens[i])) return false; } return this.sentences().equals(that.sentences()); }
public List<Sentence> getSentenceFromTokens(Set<Integer> tokens) { List<Sentence> mySentences = new ArrayList<>(); Set<Integer> sentencesSeen = new HashSet<>(); for (Sentence s : sentences()) { for (int token : tokens) { if (s.getSentenceConstituent().doesConstituentCover(token)) { if (!sentencesSeen.contains(s.getStartSpan())) { mySentences.add(s); sentencesSeen.add(s.getStartSpan()); } break; } } } return mySentences; }
public List<Sentence> getSentenceFromTokens(Set<Integer> tokens) { List<Sentence> mySentences = new ArrayList<>(); Set<Integer> sentencesSeen = new HashSet<>(); for (Sentence s : sentences()) { for (int token : tokens) { if (s.getSentenceConstituent().doesConstituentCover(token)) { if (!sentencesSeen.contains(s.getStartSpan())) { mySentences.add(s); sentencesSeen.add(s.getStartSpan()); } break; } } } return mySentences; }
public static void main(String[] args) { String text = "สตาร์คราฟต์ เป็นวิดีโอเกมประเภทวางแผนเรียลไทม์และบันเทิงคดีวิทยาศาสตร์การทหาร พัฒนาและจัดจำหน่ายโดยบลิซซาร์ด เอ็นเตอร์เทนเมนต์ ออกบนระบบปฏิบัติการไมโครซอฟท์ วินโดวส์เมื่อวันที่ 31 มีนาคม 2541 ต่อมา เกมขยายเป็นแฟรนไชส์ และเป็นเกมแรกของซีรีส์สตาร์คราฟต์ รุ่นแมคโอเอสออกในเดือนมีนาคม 2542 และรุ่นดัดแปลงนินเทนโด 64 ซึ่งพัฒนาร่วมกับแมสมีเดีย ออกในวันที่ 13 มิถุนายน 2543 การพัฒนาเกมนี้เริ่มขึ้นไม่นานหลังวอร์คราฟต์ 2: ไทด์สออฟดาร์กเนส ออกในปี 2538 สตาร์คราฟต์เปิดตัวในงานอี3 ปี 2539 ซึ่งเป็นที่ชื่นชอบน้อยกว่าวอร์คราฟต์ 2 ฉะนั้น โครงการจึงถูกพลิกโฉมทั้งหมดแล้วแสดงต่อสาธารณะในต้นปี 2540 ซึ่งได้รับการตอบรับดีกว่ามาก"; text = " 2507 การสืบสวนของคณะกรรมการสมาชิกผู้แทนราษฎรสหรัฐว่าด้วยการลอบสังหารประธานาธิบดี (hsca) ระหว่าง - พศ 2522 และการสืบสวนของรัฐบาล สรุปว่าประธานาธิบดีถูกลอบสังหารโดยลี ฮาร์วีย์ ออสวอลด์ ซึ่งในเวล\n"; ThaiTokenizer token = new ThaiTokenizer(); TextAnnotation ta = token.getTextAnnotation(text); for(Sentence sen: ta.sentences()){ System.out.println(sen.getTokenizedText()); } }
public static void main(String[] args) { String text = "สตาร์คราฟต์ เป็นวิดีโอเกมประเภทวางแผนเรียลไทม์และบันเทิงคดีวิทยาศาสตร์การทหาร พัฒนาและจัดจำหน่ายโดยบลิซซาร์ด เอ็นเตอร์เทนเมนต์ ออกบนระบบปฏิบัติการไมโครซอฟท์ วินโดวส์เมื่อวันที่ 31 มีนาคม 2541 ต่อมา เกมขยายเป็นแฟรนไชส์ และเป็นเกมแรกของซีรีส์สตาร์คราฟต์ รุ่นแมคโอเอสออกในเดือนมีนาคม 2542 และรุ่นดัดแปลงนินเทนโด 64 ซึ่งพัฒนาร่วมกับแมสมีเดีย ออกในวันที่ 13 มิถุนายน 2543 การพัฒนาเกมนี้เริ่มขึ้นไม่นานหลังวอร์คราฟต์ 2: ไทด์สออฟดาร์กเนส ออกในปี 2538 สตาร์คราฟต์เปิดตัวในงานอี3 ปี 2539 ซึ่งเป็นที่ชื่นชอบน้อยกว่าวอร์คราฟต์ 2 ฉะนั้น โครงการจึงถูกพลิกโฉมทั้งหมดแล้วแสดงต่อสาธารณะในต้นปี 2540 ซึ่งได้รับการตอบรับดีกว่ามาก"; text = " 2507 การสืบสวนของคณะกรรมการสมาชิกผู้แทนราษฎรสหรัฐว่าด้วยการลอบสังหารประธานาธิบดี (hsca) ระหว่าง - พศ 2522 และการสืบสวนของรัฐบาล สรุปว่าประธานาธิบดีถูกลอบสังหารโดยลี ฮาร์วีย์ ออสวอลด์ ซึ่งในเวล\n"; ThaiTokenizer token = new ThaiTokenizer(); TextAnnotation ta = token.getTextAnnotation(text); for(Sentence sen: ta.sentences()){ System.out.println(sen.getTokenizedText()); } }
private void findRoots() { if (roots == null) roots = new TIntObjectHashMap<>(); for (int i = 0; i < this.textAnnotation.sentences().size(); ++i) if(null == roots.get(i)) roots.put(i, getTreeRoot(this.textAnnotation.getSentence(i))); }
private void findRoots() { if (roots == null) roots = new TIntObjectHashMap<>(); for (int i = 0; i < this.textAnnotation.sentences().size(); ++i) if(null == roots.get(i)) roots.put(i, getTreeRoot(this.textAnnotation.getSentence(i))); }
private static void writeSentences(TextAnnotation ta, JsonObject json) { JsonObject object = new JsonObject(); SpanLabelView sentenceView = (SpanLabelView) ta.getView(ViewNames.SENTENCE); writeString("generator", sentenceView.getViewGenerator(), object); writeDouble("score", sentenceView.getScore(), object); int numSentences = sentenceView.getNumberOfConstituents(); int[] sentenceEndPositions = new int[numSentences]; int id = 0; for (Sentence sentence : ta.sentences()) { sentenceEndPositions[id++] = sentence.getEndSpan(); } writeIntArray("sentenceEndPositions", sentenceEndPositions, object); json.add("sentences", object); }
private static void writeSentences(TextAnnotation ta, JsonObject json) { JsonObject object = new JsonObject(); SpanLabelView sentenceView = (SpanLabelView) ta.getView(ViewNames.SENTENCE); writeString("generator", sentenceView.getViewGenerator(), object); writeDouble("score", sentenceView.getScore(), object); int numSentences = sentenceView.getNumberOfConstituents(); int[] sentenceEndPositions = new int[numSentences]; int id = 0; for (Sentence sentence : ta.sentences()) { sentenceEndPositions[id++] = sentence.getEndSpan(); } writeIntArray("sentenceEndPositions", sentenceEndPositions, object); json.add("sentences", object); }
/** * Process each sentence individually. This potentially allows for failure at an individual * sentence level, without failing for the whole text. THIS REQUIRES THAT ALL RELATIONS ARE * INTRA-SENTENCE. Any that are *not* will be omitted for the sentence-level processing. * * @param annotator Annotator to apply * @param textAnnotation TextAnnotation to augment * @return */ public void processBySentence(Annotator annotator, TextAnnotation textAnnotation) { logger.debug("in processBySentence()..."); for (int sentenceId = 0; sentenceId < textAnnotation.sentences().size(); ++sentenceId) { TextAnnotation sentTa = TextAnnotationUtilities.getSubTextAnnotation(textAnnotation, sentenceId); try { annotator.getView(sentTa); int start = textAnnotation.getSentence(sentenceId).getStartSpan(); int end = textAnnotation.getSentence(sentenceId).getEndSpan(); TextAnnotationUtilities.copyViewFromTo(annotator.getViewName(), sentTa, textAnnotation, start, end, start); } catch (AnnotatorException e) { e.printStackTrace(); } } return; }
private static void writeSentences(TextAnnotation ta, TextAnnotationProto.Builder taBuilder) { SentenceProto.Builder sentenceBuilder = SentenceProto.newBuilder(); SpanLabelView sentenceView = (SpanLabelView) ta.getView(ViewNames.SENTENCE); sentenceBuilder.setGenerator(sentenceView.getViewGenerator()); sentenceBuilder.setScore(sentenceView.getScore()); for (Sentence sentence: ta.sentences()) { sentenceBuilder.addSentenceEndPositions(sentence.getEndSpan()); } taBuilder.setSentences(sentenceBuilder); }
private static void writeSentences(TextAnnotation ta, TextAnnotationProto.Builder taBuilder) { SentenceProto.Builder sentenceBuilder = SentenceProto.newBuilder(); SpanLabelView sentenceView = (SpanLabelView) ta.getView(ViewNames.SENTENCE); sentenceBuilder.setGenerator(sentenceView.getViewGenerator()); sentenceBuilder.setScore(sentenceView.getScore()); for (Sentence sentence: ta.sentences()) { sentenceBuilder.addSentenceEndPositions(sentence.getEndSpan()); } taBuilder.setSentences(sentenceBuilder); }